prepare prod with application properties

This commit is contained in:
anhefti 2019-08-27 09:13:33 +02:00
parent 32c97e5b4d
commit da59627f97
5 changed files with 39 additions and 47 deletions

View file

@ -26,29 +26,7 @@ COPY --from=1 /sebserver/target/seb-server-"$SEBSERVER_VERSION".jar /sebserver
ARG SEBSERVER_VERSION ARG SEBSERVER_VERSION
ENV SEBSERVER_VERSION=${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 \ ENTRYPOINT exec java -jar seb-server-"${SEBSERVER_VERSION}".jar --spring.config.location=classpath:/config/,file:.
-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}"
EXPOSE $PORT EXPOSE $PORT

View file

@ -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

View file

@ -8,7 +8,7 @@ services:
volumes: volumes:
- ./certs:/certs - ./certs:/certs
environment: environment:
- KEYSTORE_PWD=somePW - KEYSTORE_PWD=[SET_PWD]
mariadb: mariadb:
image: "mariadb/server:10.3" image: "mariadb/server:10.3"
@ -18,7 +18,7 @@ services:
- ./certs:/etc/mysql/certs - ./certs:/etc/mysql/certs
- seb-server-mariadb-data:/var/lib/mysql - seb-server-mariadb-data:/var/lib/mysql
environment: environment:
- MYSQL_ROOT_PASSWORD=somePW - MYSQL_ROOT_PASSWORD=[SET_PWD]
ports: ports:
- 3306:3306 - 3306:3306
networks: networks:
@ -33,15 +33,8 @@ services:
- GIT_TAG= - GIT_TAG=
- SEBSERVER_VERSION=0.4.1-beta-SNAPSHOT - SEBSERVER_VERSION=0.4.1-beta-SNAPSHOT
container_name: seb-server container_name: seb-server
environment: volumes:
- SERVER_ADDRESS=0.0.0.0 - .:/sebserver
- SERVER_PORT=80
- DBSERVER_ADDRESS=seb-server-mariadb
- DBSERVER_PORT=3306
- DBSERVER_PWD=somePW
- GUICLIENT_PWD=somePW
- INTERNAL_PWD=somePW
- KEYSTORE_PWD=somePW
ports: ports:
- 80:80 - 80:80
networks: networks:

View file

@ -26,6 +26,7 @@ import ch.ethz.seb.sebserver.gbl.profile.WebServiceProfile;
@WebServiceProfile @WebServiceProfile
public class WebserviceInfo { 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_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_HTTP_SCHEME_KEY = "sebserver.webservice.http.scheme";
private static final String WEB_SERVICE_HOST_ADDRESS_KEY = "server.address"; 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 = private static final String WEB_SERVICE_EXAM_API_DISCOVERY_ENDPOINT_KEY =
"sebserver.webservice.api.exam.endpoint.discovery"; "sebserver.webservice.api.exam.endpoint.discovery";
private final String testProperty;
private final String httpScheme; private final String httpScheme;
private final String hostAddress; // internal private final String hostAddress; // internal
private final String serverName; // external private final String serverName; // external
@ -44,6 +46,7 @@ public class WebserviceInfo {
private final boolean isDistributed; private final boolean isDistributed;
public WebserviceInfo(final Environment environment) { 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.httpScheme = environment.getRequiredProperty(WEB_SERVICE_HTTP_SCHEME_KEY);
this.hostAddress = environment.getRequiredProperty(WEB_SERVICE_HOST_ADDRESS_KEY); this.hostAddress = environment.getRequiredProperty(WEB_SERVICE_HOST_ADDRESS_KEY);
this.serverName = environment.getProperty(WEB_SERVICE_SERVER_NAME_KEY, ""); this.serverName = environment.getProperty(WEB_SERVICE_SERVER_NAME_KEY, "");
@ -63,6 +66,10 @@ public class WebserviceInfo {
Constants.FALSE_STRING)); Constants.FALSE_STRING));
} }
public String getTestProperty() {
return this.testProperty;
}
public String getHttpScheme() { public String getHttpScheme() {
return this.httpScheme; return this.httpScheme;
} }
@ -128,7 +135,9 @@ public class WebserviceInfo {
@Override @Override
public String toString() { public String toString() {
final StringBuilder builder = new StringBuilder(); 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(this.httpScheme);
builder.append(", hostAddress="); builder.append(", hostAddress=");
builder.append(this.hostAddress); builder.append(this.hostAddress);
@ -140,14 +149,8 @@ public class WebserviceInfo {
builder.append(this.discoveryEndpoint); builder.append(this.discoveryEndpoint);
builder.append(", serverURLPrefix="); builder.append(", serverURLPrefix=");
builder.append(this.serverURLPrefix); builder.append(this.serverURLPrefix);
builder.append(", getLocalHostName()="); builder.append(", isDistributed=");
builder.append(getLocalHostName()); builder.append(this.isDistributed);
builder.append(", getLocalHostAddress()=");
builder.append(getLocalHostAddress());
builder.append(", getLoopbackHostName()=");
builder.append(getLoopbackHostName());
builder.append(", getLoopbackHostAddress()=");
builder.append(getLoopbackHostAddress());
builder.append("]"); builder.append("]");
return builder.toString(); return builder.toString();
} }

View file

@ -6,7 +6,7 @@ server.servlet.context-path=/
datastore.mariadb.server.address=[TO SET] datastore.mariadb.server.address=[TO SET]
security.require-ssl=true #security.require-ssl=true
server.ssl.key-store-type=PKCS12 #server.ssl.key-store-type=PKCS12
server.ssl.key-store=file:/sebserver/seb-server-keystore.pkcs12 #server.ssl.key-store=file:/sebserver/seb-server-keystore.pkcs12
server.ssl.key-alias=1 #server.ssl.key-alias=1