-
Notifications
You must be signed in to change notification settings - Fork 11
/
Dockerfile
executable file
·136 lines (107 loc) · 4.65 KB
/
Dockerfile
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
136
###
## Build:
#
# if passing LUCEE_VERSION, it must include modifier, e.g. -SNAPSHOT, -RC, if there is one
# you can also set the value to CUSTOM and place a Lucee JAR file in resources/catalina-base/lib
# if passing LUCEE_EXTENSIONS, the value has to be in double quotes
#
# docker image build \
# --build-arg LUCEE_VERSION=5.3.8.133-SNAPSHOT \
# --build-arg LUCEE_ADMIN_PASSWORD=changeit \
# --build-arg LUCEE_EXTENSIONS="3F9DFF32-B555-449D-B0EB5DB723044045;name=WebSocket" \
# --build-arg GROUP_ID=$(id -g) \
# -t isapir/lucee-538 .
#
# docker push isapir/lucee-538
#
###
## Run:
#
# HOST_WEBROOT=/work/webroot
#
# docker container run -d --rm -p 8080:8080 --name lucee-8080 \
# -v $HOST_WEBROOT:/srv/www/app/webroot \
# -e LUCEE_PRESERVE_CASE=true \
# -e CATALINA_OPTS="-Xmx4g"
# isapir/lucee-538
#
###
## Project home: https://github.com/isapir/lucee-docker
#
# Allow to specify the base Tomcat image (must have curl)
ARG TOMCAT_IMAGE_TAG=9-jdk11
FROM tomcat:$TOMCAT_IMAGE_TAG AS Lucee
# Set default LUCEE_VERSION
# Override at build time with --build-arg LUCEE_VERSION=5.2.9.38-SNAPSHOT
ARG LUCEE_VERSION=5.3.10.97
# Allow to specify the Lucee Admin Password at build time with --build-arg LUCEE_ADMIN_PASSWORD=changeit
ARG LUCEE_ADMIN_PASSWORD=
# Install optional Lucee extensions in the comma separated format {extension-uuid};name=X;label=XY;version=m.n
# e.g. "3F9DFF32-B555-449D-B0EB5DB723044045;name=WebSocket"
ARG LUCEE_EXTENSIONS=
# Pass JVM options when Tomcat starts, e.g. --build-arg CATALINA_OPTS="-Xmx2g"
ARG CATALINA_OPTS=
# Allow to set a custom webroot directory
ARG SERVER_WEBROOT=/srv/www/app/webroot
# Set Target Env for post warmup file copy, default is DEV - files will be copied from resources/target-envs/DEV
ARG TARGET_ENV=DEV
# Pass a host user Group ID, e.g. --build-arg GROUP_ID=$(id -g) to make file sharing easy
ARG GROUP_ID=0
ENV LUCEE_EXTENSIONS ${LUCEE_EXTENSIONS}
ENV CATALINA_OPTS ${CATALINA_OPTS}
ENV SERVER_WEBROOT ${SERVER_WEBROOT}
ENV BASE_DIR /srv/www
# Map a host directory for web app, which must have a webroot subdirectory, with
# -v <host-directory-app>:${BASE_DIR}/app
ENV CATALINA_HOME /usr/local/tomcat
ENV CATALINA_BASE ${BASE_DIR}/catalina-base
ENV WEBAPP_BASE ${BASE_DIR}/app
ENV LUCEE_DOWNLOAD http://release.lucee.org/rest/update/provider/loader/
# Lucee server directory
ENV LUCEE_SERVER ${CATALINA_BASE}/lucee-server
ENV TARGET_ENV ${TARGET_ENV}
ENV GROUP_ID ${GROUP_ID}
# displays the OS version and Lucee Server path
# calls makebase.sh and downloads Lucee if the version is not set to CUSTOM
RUN cat /etc/os-release \
&& $CATALINA_HOME/bin/makebase.sh $CATALINA_BASE \
&& if [ "$LUCEE_VERSION" != "CUSTOM" ] ; then \
echo Downloading Lucee ${LUCEE_VERSION}... \
&& curl -L -o "${CATALINA_BASE}/lib/${LUCEE_VERSION}.jar" "${LUCEE_DOWNLOAD}${LUCEE_VERSION}" \
; fi
# copy the files from resources/catalina_base to the image
COPY resources/catalina-base ${CATALINA_BASE}
# copy the files from app, including the required subdirectory webroot, to the image
COPY app ${WEBAPP_BASE}
# create password.txt file if password is set
RUN if [ "$LUCEE_ADMIN_PASSWORD" != "" ] ; then \
mkdir -p "${LUCEE_SERVER}/context" \
&& echo $LUCEE_ADMIN_PASSWORD > "${LUCEE_SERVER}/context/password.txt" \
; else \
echo "Set Lucee Admin at ${LUCEE_SERVER}/context/password.txt" \
; fi
WORKDIR ${BASE_DIR}
RUN if [ "$LUCEE_VERSION" \> "5.3.10" ] || [ "$LUCEE_VERSION" \> "5.3.6" ] || [ "$LUCEE_VERSION" == "CUSTOM" ] ; then \
echo "Enabled LUCEE_ENABLE_WARMUP" \
&& export LUCEE_ENABLE_WARMUP=true \
&& export LUCEE_EXTENSIONS \
&& catalina.sh run \
; else \
echo "Start Tomcat and wait 20 seconds to shut down" \
&& catalina.sh start \
&& sleep 20 \
&& catalina.sh stop \
; fi
RUN if [ "${GROUP_ID}" \> "0" ] ; then \
DIRS_PERMISSION="/srv/www" \
&& useradd --uid ${GROUP_ID} --user-group --shell /bin/bash lucee \
&& chown :${GROUP_ID} -R ${DIRS_PERMISSION} \
&& chmod -R g+srw ${DIRS_PERMISSION} \
&& echo "Set permissions for group ${GROUP_ID} to ${DIRS_PERMISSION}" \
; fi
## run as user lucee, for terminal access with docker container exec add `-u root`
USER ${GROUP_ID}
# copy additional lucee-server and lucee-web after the warmup completes
# for some reason this creates a Web Context at /srv/www/catalina-base/lucee-server/context which
# creates a conflict of two different web context with the same config dir so commenting out for now
# COPY resources/target-envs/${TARGET_ENV} ${CATALINA_BASE}