Repository navigation
Expand file tree
/
Copy pathDockerfile.dev
More file actions
135 lines (110 loc) · 5.02 KB
/
Copy pathDockerfile.dev
File metadata and controls
135 lines (110 loc) · 5.02 KB
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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
##
# Build Stage
#
FROM maven:3-eclipse-temurin-21 AS build
COPY ./dataexport /build/dataexport
##
# Build DataExport
WORKDIR /build/dataexport/dataexport-core
RUN --mount=type=cache,target=/root/.m2,sharing=locked \
mvn dependency:go-offline
RUN --mount=type=cache,target=/root/.m2,sharing=locked \
mvn clean install -DskipTests
WORKDIR /build/dataexport/
RUN --mount=type=cache,target=/root/.m2,sharing=locked \
mvn dependency:go-offline
RUN --mount=type=cache,target=/root/.m2,sharing=locked \
mvn clean install -DskipTests
RUN --mount=target=/var/lib/apt/lists,type=cache,sharing=locked \
--mount=target=/var/cache/apt,type=cache,sharing=locked \
rm -f /etc/apt/apt.conf.d/docker-clean \
&& sed -i 's|http://archive.ubuntu.com|http://azure.archive.ubuntu.com|g; s|http://security.ubuntu.com|http://azure.archive.ubuntu.com|g' \
/etc/apt/sources.list /etc/apt/sources.list.d/*.list 2>/dev/null || true \
&& apt-get -o Acquire::Retries=5 -o Acquire::http::Timeout=60 \
--allow-releaseinfo-change -y update \
&& apt-get -o Acquire::Retries=5 -o Acquire::http::Timeout=60 \
-y --no-install-recommends install \
git apache2-utils
##
# Copy Source Code
#
ADD ./pom.xml /build/pom.xml
ADD ./tools /build/tools
ADD ./src /build/src
ADD ./frontend/src/languages /build/frontend/src/languages
ADD ./dataexport /build/dataexport
WORKDIR /build
# OE Default Password
ARG DEFAULT_PW="adminADMIN!"
ADD ./install/createDefaultPassword.sh /build/install/createDefaultPassword.sh
RUN ./install/createDefaultPassword.sh -c -p ${DEFAULT_PW}
##
# Build the Project
#
WORKDIR /build
RUN --mount=type=cache,target=/root/.m2,sharing=locked \
mvn dependency:go-offline
RUN --mount=type=cache,target=/root/.m2,sharing=locked \
mvn clean install -DskipTests -Dspotless.check.skip=true -Dmaven.test.skip=true
##
# Tomcat's client certificate trust manager (see tomcat/oe_server.xml)
#
FROM maven:3-eclipse-temurin-21 AS tomcat-lib
COPY ./tomcat/client-certificates /build/client-certificates
RUN mkdir -p /build/classes \
&& javac --release 21 -d /build/classes $(find /build/client-certificates -name '*.java') \
&& jar cf /build/openelis-client-certificates.jar -C /build/classes .
##
# Run Stage
#
FROM tomcat:10-jre21 AS dev-runtime
ADD install/createDefaultPassword.sh ./
COPY --from=tomcat-lib /build/openelis-client-certificates.jar /usr/local/tomcat/lib/
#Clean out unneccessary files from tomcat (especially pre-existing applications)
RUN rm -rf /usr/local/tomcat/webapps/* \
/usr/local/tomcat/conf/Catalina/localhost/manager.xml
#Deploy the war into tomcat image and point root to it
ADD install/tomcat-resources/ROOT.war /usr/local/tomcat/webapps/ROOT.war
#rewrite cataline.properties with our catalina.properties so it contains:
# org.apache.catalina.STRICT_SERVLET_COMPLIANCE=true
# org.apache.catalina.connector.RECYCLE_FACADES=true
# org.apache.catalina.connector.CoyoteAdapter.ALLOW_BACKSLASH=false
# org.apache.tomcat.util.buf.UDecoder.ALLOW_ENCODED_SLASH=false
# org.apache.coyote.USE_CUSTOM_STATUS_MSG_IN_HEADER=false
ADD install/tomcat-resources/catalina.properties /usr/local/tomcat/conf/catalina.properties
ADD install/tomcat-resources/logging.properties /usr/local/tomcat/conf/logging.properties
#replace ServerInfo.properties with a less informative one
RUN mkdir -p /usr/local/tomcat/lib/org/apache/catalina/util
ADD install/tomcat-resources/ServerInfo.properties /usr/local/tomcat/lib/org/apache/catalina/util/ServerInfo.properties
#restrict files
#GID AND UID must be kept the same as setupTomcat.sh (if using default certificate group)
RUN groupadd tomcat; \
groupadd tomcat-ssl-cert -g 8443; \
useradd -M -s /bin/bash -u 8443 tomcat_admin; \
usermod -a -G tomcat,tomcat-ssl-cert tomcat_admin; \
chown -R tomcat_admin:tomcat $CATALINA_HOME; \
chmod g-w,o-rwx $CATALINA_HOME; \
chmod g-w,o-rwx $CATALINA_HOME/conf; \
chmod o-rwx $CATALINA_HOME/logs; \
chmod o-rwx $CATALINA_HOME/temp; \
chmod g-w,o-rwx $CATALINA_HOME/bin; \
chmod g-w,o-rwx $CATALINA_HOME/webapps; \
chmod 770 $CATALINA_HOME/conf/catalina.policy; \
chmod g-w,o-rwx $CATALINA_HOME/conf/catalina.properties; \
chmod g-w,o-rwx $CATALINA_HOME/conf/context.xml; \
chmod g-w,o-rwx $CATALINA_HOME/conf/logging.properties; \
chmod g-w,o-rwx $CATALINA_HOME/conf/server.xml; \
chmod g-w,o-rwx $CATALINA_HOME/conf/tomcat-users.xml; \
chmod g-w,o-rwx $CATALINA_HOME/conf/web.xml
ADD install/openelis_healthcheck.sh /healthcheck.sh
RUN chown tomcat_admin:tomcat /healthcheck.sh; \
chmod 770 /healthcheck.sh;
ADD install/docker-entrypoint.sh /docker-entrypoint.sh
RUN chown tomcat_admin:tomcat /docker-entrypoint.sh; \
chmod 770 /docker-entrypoint.sh;
USER root
ENTRYPOINT [ "/docker-entrypoint.sh" ]
# The local launcher mounts its already-built WAR onto the same runtime stage.
# Published development images retain the complete application.
FROM dev-runtime AS packaged
COPY --from=build /build/target/OpenELIS-Global.war /usr/local/tomcat/webapps/OpenELIS-Global.war