prepare demo with docker compose

This commit is contained in:
anhefti 2019-08-21 09:53:29 +02:00
parent ccc609a17b
commit 44f71c70c9
5 changed files with 78 additions and 23 deletions

View file

@ -3,7 +3,9 @@ FROM alpine/git
ARG GIT_TAG
WORKDIR /demo
RUN git clone -b "$GIT_TAG" --depth 1 https://github.com/SafeExamBrowser/seb-server.git
RUN if [ "x$arg" = "x" ] ; \
then git clone --depth 1 https://github.com/SafeExamBrowser/seb-server.git ; \
else git clone -b "$GIT_TAG" --depth 1 https://github.com/SafeExamBrowser/seb-server.git ; fi
FROM maven:3.5-jdk-8-alpine
@ -16,13 +18,20 @@ RUN mvn clean install -e -P Demo -DskipTests
FROM openjdk:8-jre-alpine
ARG SEBSERVER_VERSION
ENV SEBSERVER_VERSION ${SEBSERVER_VERSION}
ENV SEBSERVER_VERSION=${SEBSERVER_VERSION}
ENV SERVER_ADDRESS=0.0.0.0
ENV SERVER_PORT=8080
ENV DBSERVER_ADDRESS=seb-server-mariadb
ENV DBSERVER_PORT=3306
ENV DBSERVER_PWD=
ENV GUICLIENT_PWD=
ENV INTERNAL_PWD=
WORKDIR /demo
COPY --from=1 /demo/target/seb-server-"$SEBSERVER_VERSION".jar /demo
ENTRYPOINT ["sh", "-c"]
CMD ["java -jar seb-server-${SEBSERVER_VERSION}.jar --spring.config.location=classpath:/config/,file:/demo/externalResources/ --server.address=0.0.0.0 --spring.profiles.active=demo"]
CMD ["java -jar seb-server-${SEBSERVER_VERSION}.jar --server.address=${SERVER_ADDRESS} --server.port=${SERVER_PORT} --spring.config.location=classpath:/config/,file:/demo/externalResources/ --datastore.mariadb.server.address=${DBSERVER_ADDRESS} --datastore.mariadb.server.port${DBSERVER_PORT} --spring.profiles.active=demo --spring.datasource.password=${DBSERVER_PWD} --sebserver.webservice.api.admin.clientSecret={GUICLIENT_PWD} --sebserver.webservice.internalSecret=${INTERNAL_PWD}"]
EXPOSE 8080

View file

@ -0,0 +1,41 @@
version: '3'
services:
mariadb:
image: "mariadb/server:10.3"
container_name: seb-server-mariadb
volumes:
- seb-server-mariadb-data:/var/lib/mysql
environment:
- MYSQL_ROOT_PASSWORD=[TO SET]
ports:
- 3306:3306
networks:
- ralph
seb-server:
build:
context: .
args:
- GIT_TAG=
- SEBSERVER_VERSION=0.4.0-SNAPSHOT
container_name: seb-server
environment:
- SERVER_ADDRESS=0.0.0.0
- SERVER_PORT=8080
- DBSERVER_ADDRESS=seb-server-mariadb
- DBSERVER_PORT=3306
- ENV DBSERVER_PWD=[TO SET]
- ENV GUICLIENT_PWD=[TO SET]
- ENV INTERNAL_PWD=[TO SET]
ports:
- 8080:8080
networks:
- ralph
depends_on:
- "mariadb"
networks:
ralph:
volumes:
seb-server-mariadb-data:

View file

@ -24,25 +24,29 @@ ARG SEBSERVER_VERSION
WORKDIR /sebserver
COPY --from=1 /sebserver/target/seb-server-"$SEBSERVER_VERSION".jar /sebserver
ENTRYPOINT ["sh", "-c"]
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 KEYSTORE_PWD=
CMD 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 \
--spring.config.location=classpath:/config/,file:/sebserver/ \
--server.address="${SERVER_ADDRESS}" \
--spring.profiles.active=dev \
--datastore.mariadb.server.address="${DBSERVER_ADDRESS}" \
--datastore.mariadb.server.port="${DBSERVER_PORT}"
ENTRYPOINT ["sh", "-c"]
CMD ["java -jar seb-server-${SEBSERVER_VERSION}.jar --spring.config.location=classpath:/config/,file:/sebserver/ --server.address=${SERVER_ADDRESS} --spring.profiles.active=dev"]
# CMD 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 \
# --spring.config.location=classpath:/config/,file:/sebserver/ \
# --server.address="${SERVER_ADDRESS}" \
# --spring.profiles.active=dev \
# --datastore.mariadb.server.address="${DBSERVER_ADDRESS}" \
# --datastore.mariadb.server.port="${DBSERVER_PORT}"
EXPOSE $PORT

View file

@ -18,7 +18,7 @@ services:
- ./certs:/etc/mysql/certs
- seb-server-mariadb-data:/var/lib/mysql
environment:
- MYSQL_ROOT_PASSWORD=[TO SET]
- MYSQL_ROOT_PASSWORD=somePW
ports:
- 3306:3306
networks:
@ -34,11 +34,11 @@ services:
- SEBSERVER_VERSION=0.4.0-SNAPSHOT
container_name: seb-server
environment:
- SERVER_ADDRESS
- SERVER_PORT
- DBSERVER_ADDRESS
- DBSERVER_PORT
- KEYSTORE_PWD=[TO SET]
- SERVER_ADDRESS=0.0.0.0
- SERVER_PORT=80
- DBSERVER_ADDRESS=localhost
- DBSERVER_PORT=3306
- KEYSTORE_PWD=somePW
ports:
- 80:80
networks:

View file

@ -10,6 +10,7 @@ datastore.mariadb.server.address=seb-server-mariadb
datastore.mariadb.server.port=3306
# data source configuration
spring.datasource.username=root
spring.datasource.initialize=true
spring.datasource.initialization-mode=always
spring.datasource.url=jdbc:mariadb://${datastore.mariadb.server.address}:${datastore.mariadb.server.port}/SEBServer?useSSL=false&createDatabaseIfNotExist=true