summaryrefslogtreecommitdiffstats
path: root/pkg/docker/master-server_dockerfile
diff options
context:
space:
mode:
Diffstat (limited to 'pkg/docker/master-server_dockerfile')
-rw-r--r--pkg/docker/master-server_dockerfile60
1 files changed, 60 insertions, 0 deletions
diff --git a/pkg/docker/master-server_dockerfile b/pkg/docker/master-server_dockerfile
new file mode 100644
index 0000000..5e8c519
--- /dev/null
+++ b/pkg/docker/master-server_dockerfile
@@ -0,0 +1,60 @@
+FROM ubuntu:focal
+
+ARG MASTER_SERVER_FILE
+ARG MASTER_CONFIG_FILE_GLOBAL
+ARG MASTER_CONFIG_FILE_DATABASE
+ARG MASTER_KEYSTORE_FILE
+ARG MASTER_KEYSTORE_ALIAS
+ARG MASTER_KEYSTORE_KEY_SIZE
+ARG MASTER_KEYSTORE_PASSWORD
+
+ARG MASTER_SERVER_PATH=/opt/bwLehrpool
+ARG MASTER_VSTORE_PATH=/mnt/bwLehrpool
+ARG MASTER_FILE_TRANSFER_PORT_PLAIN=9050
+ARG MASTER_FILE_TRANSFER_PORT_SSL=9051
+ARG MASTER_THRIFT_PORT_PLAIN=9090
+ARG MASTER_THRIFT_PORT_SSL=9091
+ARG MASTER_KEYSTORE_DC=master
+ARG MASTER_KEYSTORE_OU=bwLehrpool
+ARG MASTER_KEYSTORE_CN=master-server
+ENV MASTER_DATABASE_HOST=localhost
+ENV MASTER_DATABASE_PORT=3306
+ENV MASTER_DATABASE_CONNECTION_WAIT_TIMEOUT=1m
+
+# install required packages
+RUN apt-get update -y && \
+ apt-get install -y openjdk-8-jre-headless wget
+
+# make folder for master Java server application and VMs
+RUN mkdir -p ${MASTER_SERVER_PATH}
+RUN mkdir -p ${MASTER_VSTORE_PATH}
+
+# change working directory
+WORKDIR ${MASTER_SERVER_PATH}
+
+# install dockerize
+ENV DOCKERIZE_VERSION=v0.6.1
+RUN wget -q https://github.com/jwilder/dockerize/releases/download/${DOCKERIZE_VERSION}/dockerize-linux-amd64-${DOCKERIZE_VERSION}.tar.gz && \
+ tar -C /usr/local/bin -xzvf dockerize-linux-amd64-${DOCKERIZE_VERSION}.tar.gz && \
+ rm dockerize-linux-amd64-${DOCKERIZE_VERSION}.tar.gz
+
+# copy application into the image
+COPY ${MASTER_SERVER_FILE} master-server.jar
+
+# create config directory
+RUN mkdir -p config
+
+# copy global configuration template into the image
+COPY ${MASTER_CONFIG_FILE_GLOBAL} config/global.properties.tmpl
+
+# copy local configuration template into the image
+COPY ${MASTER_CONFIG_FILE_DATABASE} config/mysql.properties.tmpl
+
+# generate Java keystore
+RUN keytool -genkey -alias ${MASTER_KEYSTORE_ALIAS} -keyalg RSA -storetype PKCS12 -keystore ${MASTER_KEYSTORE_FILE} -storepass ${MASTER_KEYSTORE_PASSWORD} -keysize ${MASTER_KEYSTORE_KEY_SIZE} -dname "cn=${MASTER_KEYSTORE_CN},ou=${MASTER_KEYSTORE_OU},dc=${MASTER_KEYSTORE_DC}"
+
+# expose network ports
+EXPOSE ${MASTER_FILE_TRANSFER_PORT_PLAIN} ${MASTER_FILE_TRANSFER_PORT_SSL} ${MASTER_THRIFT_PORT_PLAIN} ${MASTER_THRIFT_PORT_SSL}
+
+# finalize configuration from environment variables and run the master-server
+CMD dockerize -template config/global.properties.tmpl:config/global.properties -template config/mysql.properties.tmpl:config/mysql.properties -wait tcp://${MASTER_DATABASE_HOST}:${MASTER_DATABASE_PORT} -timeout ${MASTER_DATABASE_CONNECTION_WAIT_TIMEOUT} java -jar master-server.jar