-
Notifications
You must be signed in to change notification settings - Fork 10
/
Dockerfile.dev
87 lines (71 loc) · 3.12 KB
/
Dockerfile.dev
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
###############################
# Score Client
###############################
FROM --platform=linux/amd64 ubuntu:22.04 as client
ENV CLIENT_DIST_DIR /score-client-dist
ENV JDK_DOWNLOAD_URL https://download.java.net/openjdk/jdk17/ri/openjdk-17+35_linux-x64_bin.tar.gz
ENV SCORE_CLIENT_HOME /score-client
ENV PATH /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:$SCORE_CLIENT_HOME/bin
ENV SCORE_USER score
# Add score user, update apt, add FUSE support and basic command line tools
RUN useradd $SCORE_USER \
&& apt-get update \
&& apt-get -y upgrade \
&& apt-get install -y libfuse-dev fuse curl wget software-properties-common \
&& mkdir $SCORE_CLIENT_HOME
COPY score-client/target/score-client-*-dist.tar.gz /score-client.tar.gz
# Install Open JDK 17, and remove unused things at runtime
RUN mkdir /usr/lib/jvm \
&& cd /usr/lib/jvm \
&& wget $JDK_DOWNLOAD_URL -O openjdk17.tar.gz \
&& tar zxvf openjdk17.tar.gz \
&& rm -rf openjdk17.tar.gz \
&& echo 'PATH=$PATH:/usr/lib/jvm/jdk-17/bin' >> /etc/environment \
&& echo 'JAVA_HOME=/usr/lib/jvm/jdk-17' >> /etc/environment \
&& rm -rf /usr/lib/jvm/jdk-17/jmods \
&& rm -rf /usr/lib/jvm/jdk-17/lib/src.zip \
&& update-alternatives --install "/usr/bin/java" "java" "/usr/lib/jvm/jdk-17/bin/java" 0 \
&& update-alternatives --install "/usr/bin/javac" "javac" "/usr/lib/jvm/jdk-17/bin/javac" 0 \
&& update-alternatives --set java /usr/lib/jvm/jdk-17/bin/java \
&& update-alternatives --set javac /usr/lib/jvm/jdk-17/bin/javac \
&& update-alternatives --list java \
&& update-alternatives --list javac \
&& java -version
RUN tar zxvf score-client.tar.gz -C /tmp \
&& rm -rf score-client.tar.gz \
&& mv -f /tmp/score-client-* /tmp/score-client-dist \
&& cp -r /tmp/score-client-dist $CLIENT_DIST_DIR \
&& mkdir -p $CLIENT_DIST_DIR/logs \
&& touch $CLIENT_DIST_DIR/logs/client.log \
&& chmod 777 $CLIENT_DIST_DIR/logs/client.log \
&& mkdir -p $SCORE_CLIENT_HOME \
&& mv $CLIENT_DIST_DIR/* $SCORE_CLIENT_HOME \
&& chown -R $SCORE_USER:$SCORE_USER $SCORE_CLIENT_HOME
# Set working directory for convenience with interactive usage
WORKDIR $SCORE_CLIENT_HOME
###############################
# Score Server
###############################
FROM adoptopenjdk/openjdk11:jre-11.0.6_10 as server
# Paths
ENV SCORE_HOME /score-server
ENV SCORE_LOGS $SCORE_HOME/logs
ENV JAR_FILE /score-server.jar
ENV SCORE_USER score
ENV SCORE_UID 9999
ENV SCORE_GID 9999
RUN addgroup --system --gid $SCORE_GID $SCORE_USER \
&& adduser --system --uid $SCORE_UID --ingroup $SCORE_USER $SCORE_USER \
&& mkdir $SCORE_HOME $SCORE_LOGS \
&& chown -R $SCORE_UID:$SCORE_GID $SCORE_HOME
# Prepare server jar
COPY score-server/target/score-server-*-dist.tar.gz /score-server.tar.gz
RUN tar zxvf score-server.tar.gz -C /tmp \
&& mv -f /tmp/score-server-* /tmp/score-server-dist \
&& cp -f /tmp/score-server-dist/lib/score-server.jar $JAR_FILE \
&& rm -rf /score-server.tar.gz
USER $SCORE_UID
WORKDIR $SCORE_HOME
CMD java -Dlog.path=$SCORE_LOGS \
-jar $JAR_FILE \
--spring.config.location=classpath:/application.yml,classpath:/bootstrap.properties