From da59627f9742a014f466157b99713f12d1a975ea Mon Sep 17 00:00:00 2001 From: anhefti Date: Tue, 27 Aug 2019 09:13:33 +0200 Subject: [PATCH] prepare prod with application properties --- docker/prod/standalone/selfsigned/Dockerfile | 24 +------------------ .../selfsigned/application.properties | 18 ++++++++++++++ .../standalone/selfsigned/docker-compose.yml | 15 ++++-------- .../sebserver/webservice/WebserviceInfo.java | 21 +++++++++------- .../config/application-prod.properties | 8 +++---- 5 files changed, 39 insertions(+), 47 deletions(-) create mode 100644 docker/prod/standalone/selfsigned/application.properties diff --git a/docker/prod/standalone/selfsigned/Dockerfile b/docker/prod/standalone/selfsigned/Dockerfile index d37cd713..8261242c 100644 --- a/docker/prod/standalone/selfsigned/Dockerfile +++ b/docker/prod/standalone/selfsigned/Dockerfile @@ -26,29 +26,7 @@ COPY --from=1 /sebserver/target/seb-server-"$SEBSERVER_VERSION".jar /sebserver ARG SEBSERVER_VERSION ENV SEBSERVER_VERSION=${SEBSERVER_VERSION} -ENV SERVER_ADDRESS=0.0.0.0 -ENV SERVER_PORT=80 -ENV DBSERVER_ADDRESS=localhost -ENV DBSERVER_PORT=3306 -ENV DBSERVER_PWD= -ENV GUICLIENT_PWD= -ENV INTERNAL_PWD= -ENV KEYSTORE_PWD= -ENTRYPOINT exec java \ - -Dfile.encoding=UTF-8 \ - -Djavax.net.ssl.keyStore=seb-server-keystore.pkcs12 \ - -Djavax.net.ssl.keyStorePassword="${KEYSTORE_PWD}" \ - -Djavax.net.ssl.trustStore=seb-server-truststore.pkcs12 \ - -Djavax.net.ssl.trustStorePassword="${KEYSTORE_PWD}" \ - -jar seb-server-"${SEBSERVER_VERSION}".jar \ - --server.port="${SERVER_PORT}" \ - --spring.config.location=classpath:/config/ \ - --spring.profiles.active=prod \ - --datastore.mariadb.server.address="${DBSERVER_ADDRESS}" \ - --datastore.mariadb.server.port="${DBSERVER_PORT}" \ - --spring.datasource.password="${DBSERVER_PWD}" \ - --sebserver.webservice.api.admin.clientSecret="${GUICLIENT_PWD}" \ - --sebserver.webservice.internalSecret="${INTERNAL_PWD}" +ENTRYPOINT exec java -jar seb-server-"${SEBSERVER_VERSION}".jar --spring.config.location=classpath:/config/,file:. EXPOSE $PORT \ No newline at end of file diff --git a/docker/prod/standalone/selfsigned/application.properties b/docker/prod/standalone/selfsigned/application.properties new file mode 100644 index 00000000..329b91df --- /dev/null +++ b/docker/prod/standalone/selfsigned/application.properties @@ -0,0 +1,18 @@ +spring.profiles.active=prod + +file.encoding=UTF-8 + +javax.net.ssl.keyStore=seb-server-keystore.pkcs12 +javax.net.ssl.keyStorePassword=[SET_PWD] +javax.net.ssl.trustStore=seb-server-truststore.pkcs12 +javax.net.ssl.trustStorePassword=[SET_PWD] + +server.port=80 + +datastore.mariadb.server.address=seb-server-mariadb +datastore.mariadb.server.port=3306 +spring.datasource.password=[SET_PWD] +sebserver.webservice.api.admin.clientSecret=[SET_PWD] +sebserver.webservice.internalSecret=[SET_PWD] + +sebserver.test.property=Init Properties Found \ No newline at end of file diff --git a/docker/prod/standalone/selfsigned/docker-compose.yml b/docker/prod/standalone/selfsigned/docker-compose.yml index f3c1a7a9..8dd0ca47 100644 --- a/docker/prod/standalone/selfsigned/docker-compose.yml +++ b/docker/prod/standalone/selfsigned/docker-compose.yml @@ -8,7 +8,7 @@ services: volumes: - ./certs:/certs environment: - - KEYSTORE_PWD=somePW + - KEYSTORE_PWD=[SET_PWD] mariadb: image: "mariadb/server:10.3" @@ -18,7 +18,7 @@ services: - ./certs:/etc/mysql/certs - seb-server-mariadb-data:/var/lib/mysql environment: - - MYSQL_ROOT_PASSWORD=somePW + - MYSQL_ROOT_PASSWORD=[SET_PWD] ports: - 3306:3306 networks: @@ -33,15 +33,8 @@ services: - GIT_TAG= - SEBSERVER_VERSION=0.4.1-beta-SNAPSHOT container_name: seb-server - environment: - - SERVER_ADDRESS=0.0.0.0 - - SERVER_PORT=80 - - DBSERVER_ADDRESS=seb-server-mariadb - - DBSERVER_PORT=3306 - - DBSERVER_PWD=somePW - - GUICLIENT_PWD=somePW - - INTERNAL_PWD=somePW - - KEYSTORE_PWD=somePW + volumes: + - .:/sebserver ports: - 80:80 networks: diff --git a/src/main/java/ch/ethz/seb/sebserver/webservice/WebserviceInfo.java b/src/main/java/ch/ethz/seb/sebserver/webservice/WebserviceInfo.java index 776a9dfe..8b1c0805 100644 --- a/src/main/java/ch/ethz/seb/sebserver/webservice/WebserviceInfo.java +++ b/src/main/java/ch/ethz/seb/sebserver/webservice/WebserviceInfo.java @@ -26,6 +26,7 @@ import ch.ethz.seb.sebserver.gbl.profile.WebServiceProfile; @WebServiceProfile public class WebserviceInfo { + private static final String WEB_SERVICE_TEST_PROPERTY = "sebserver.test.property"; private static final String WEB_SERVICE_SERVER_NAME_KEY = "sebserver.webservice.http.server.name"; private static final String WEB_SERVICE_HTTP_SCHEME_KEY = "sebserver.webservice.http.scheme"; private static final String WEB_SERVICE_HOST_ADDRESS_KEY = "server.address"; @@ -33,6 +34,7 @@ public class WebserviceInfo { private static final String WEB_SERVICE_EXAM_API_DISCOVERY_ENDPOINT_KEY = "sebserver.webservice.api.exam.endpoint.discovery"; + private final String testProperty; private final String httpScheme; private final String hostAddress; // internal private final String serverName; // external @@ -44,6 +46,7 @@ public class WebserviceInfo { private final boolean isDistributed; public WebserviceInfo(final Environment environment) { + this.testProperty = environment.getProperty(WEB_SERVICE_TEST_PROPERTY, "NOT_AVAILABLE"); this.httpScheme = environment.getRequiredProperty(WEB_SERVICE_HTTP_SCHEME_KEY); this.hostAddress = environment.getRequiredProperty(WEB_SERVICE_HOST_ADDRESS_KEY); this.serverName = environment.getProperty(WEB_SERVICE_SERVER_NAME_KEY, ""); @@ -63,6 +66,10 @@ public class WebserviceInfo { Constants.FALSE_STRING)); } + public String getTestProperty() { + return this.testProperty; + } + public String getHttpScheme() { return this.httpScheme; } @@ -128,7 +135,9 @@ public class WebserviceInfo { @Override public String toString() { final StringBuilder builder = new StringBuilder(); - builder.append("WebserviceInfo [httpScheme="); + builder.append("WebserviceInfo [testProperty="); + builder.append(this.testProperty); + builder.append(", httpScheme="); builder.append(this.httpScheme); builder.append(", hostAddress="); builder.append(this.hostAddress); @@ -140,14 +149,8 @@ public class WebserviceInfo { builder.append(this.discoveryEndpoint); builder.append(", serverURLPrefix="); builder.append(this.serverURLPrefix); - builder.append(", getLocalHostName()="); - builder.append(getLocalHostName()); - builder.append(", getLocalHostAddress()="); - builder.append(getLocalHostAddress()); - builder.append(", getLoopbackHostName()="); - builder.append(getLoopbackHostName()); - builder.append(", getLoopbackHostAddress()="); - builder.append(getLoopbackHostAddress()); + builder.append(", isDistributed="); + builder.append(this.isDistributed); builder.append("]"); return builder.toString(); } diff --git a/src/main/resources/config/application-prod.properties b/src/main/resources/config/application-prod.properties index eb1f5b6b..5df4b00f 100644 --- a/src/main/resources/config/application-prod.properties +++ b/src/main/resources/config/application-prod.properties @@ -6,7 +6,7 @@ server.servlet.context-path=/ datastore.mariadb.server.address=[TO SET] -security.require-ssl=true -server.ssl.key-store-type=PKCS12 -server.ssl.key-store=file:/sebserver/seb-server-keystore.pkcs12 -server.ssl.key-alias=1 \ No newline at end of file +#security.require-ssl=true +#server.ssl.key-store-type=PKCS12 +#server.ssl.key-store=file:/sebserver/seb-server-keystore.pkcs12 +#server.ssl.key-alias=1 \ No newline at end of file