summaryrefslogtreecommitdiffstats
path: root/pkg/docker/master-server_dockerfile
blob: 5e8c519e1c76e34cacc845b7e21a56e2a58edf26 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
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