-
Notifications
You must be signed in to change notification settings - Fork 2
/
Dockerfile-multistage
78 lines (63 loc) · 2.45 KB
/
Dockerfile-multistage
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
ARG CHEMISTRY_PACKAGE=bbchem
FROM maven:3-openjdk-11 AS builder
FROM builder AS compile
ARG CHEMISTRY_PACKAGE
ENV CHEMISTRY_PACKAGE=${CHEMISTRY_PACKAGE}
ADD settings.xml /settings.xml
COPY pom.xml /src/pom.xml
WORKDIR /src
RUN --mount=type=cache,target=/root/.m2 mvn dependency:resolve -P ${CHEMISTRY_PACKAGE} -s /settings.xml
ADD . /src
# Slow Step - Caching this Layer Greatly Improves Build Time (~6x Faster)
RUN --mount=type=cache,target=/root/.m2 mvn clean && \
mvn compile war:war -P ${CHEMISTRY_PACKAGE}
FROM tomcat:9.0.97-jdk11-temurin-jammy
# Third and Last Step That Requires Significant (Relative) Amount of Time
RUN apt-get update && \
apt-get install -y \
curl \
libfreetype6 \
libfontconfig \
openssl
# Add nodejs for prepare config files
ENV NPM_CONFIG_LOGLEVEL=warn
ENV NODE_VERSION=20.x
# Second Slowest Step
RUN curl -fsSL https://deb.nodesource.com/setup_$NODE_VERSION | bash - && \
apt-get install -y nodejs && \
npm install -g \
ENV NODE_PATH=/usr/lib/node_modules
# Add runner user so we don't run as root
RUN useradd -u 1000 -ms /bin/bash runner && \
chown -R runner:runner /usr/local/tomcat/
# Allow certificates to be added by runner
RUN chgrp runner $JAVA_HOME/lib/security/cacerts && \
chmod g+w $JAVA_HOME/lib/security/cacerts && \
mkdir -p /usr/lib/jvm/java/jre/lib/security && \
ln -s $JAVA_HOME/lib/security/cacerts /usr/lib/jvm/java/jre/lib/security/cacerts
# Get acas-roo-server compiled code
COPY --chown=runner:runner --from=compile /src/target/acas*.war /usr/local/tomcat/webapps/acas.war
COPY --chown=runner:runner --from=compile /src/target/acas* /usr/local/tomcat/webapps/acas/
# Wait for it startup script
COPY --chown=runner:runner wait-for-it.sh ./wait-for-it.sh
RUN chmod 755 wait-for-it.sh
WORKDIR $CATALINA_HOME
ENV ACAS_HOME=/home/runner/build
ENV CATALINA_OPTS="-Xms512M -Xmx1536M -XX:MaxPermSize=512m"
# Prepare config files
COPY --chown=runner:runner ./PrepareConfigFiles.coffee /home/runner/build/src/javascripts/BuildUtilities/PrepareConfigFiles.coffee
# Become runner user so we don't run as root
USER runner
# Setup entrypoint
COPY entrypoint.sh /entrypoint.sh
ENTRYPOINT ["/bin/bash", "/entrypoint.sh"]
CMD ["catalina.sh", "run"]