forked from mikecroft/docker-payaraserver-full
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
91 lines (82 loc) · 4.18 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
FROM azul/zulu-openjdk:8u222
# Default payara ports to expose
# 4848: admin console
# 9009: debug port (JPDA)
# 8080: http
# 8181: https
EXPOSE 4848 9009 8080 8181
# Payara version (5.183+)
ARG PAYARA_VERSION=5.194
ARG PAYARA_PKG=https://search.maven.org/remotecontent?filepath=fish/payara/distributions/payara/${PAYARA_VERSION}/payara-${PAYARA_VERSION}.zip
ARG PAYARA_SHA1=ff13ccd3e7905e7cc54b574b8c44341352800961
ARG TINI_VERSION=v0.18.0
# Initialize the configurable environment variables
ENV HOME_DIR=/opt/payara\
PAYARA_DIR=/opt/payara/appserver\
SCRIPT_DIR=/opt/payara/scripts\
CONFIG_DIR=/opt/payara/config\
DEPLOY_DIR=/opt/payara/deployments\
PASSWORD_FILE=/opt/payara/passwordFile\
# Payara Server Domain options
DOMAIN_NAME=production\
ADMIN_USER=admin\
ADMIN_PASSWORD=admin \
# Utility environment variables
JVM_ARGS=\
PAYARA_ARGS=\
DEPLOY_PROPS=\
POSTBOOT_COMMANDS=/opt/payara/config/post-boot-commands.asadmin\
PREBOOT_COMMANDS=/opt/payara/config/pre-boot-commands.asadmin
ENV PATH="${PATH}:${PAYARA_DIR}/bin"
# Create and set the Payara user and working directory owned by the new user
RUN groupadd -g 1000 payara && \
useradd -u 1000 -M -s /bin/bash -d ${HOME_DIR} payara -g payara && \
echo payara:payara | chpasswd && \
mkdir -p ${DEPLOY_DIR} && \
mkdir -p ${CONFIG_DIR} && \
mkdir -p ${SCRIPT_DIR} && \
chown -R payara: ${HOME_DIR} && \
# Install required packages
apt-get update && \
apt-get install -y wget unzip && \
rm -rf /var/lib/apt/lists/*
# Install tini as minimized init system
RUN wget --no-verbose -O /tini https://github.com/krallin/tini/releases/download/${TINI_VERSION}/tini && \
wget --no-verbose -O /tini.asc https://github.com/krallin/tini/releases/download/${TINI_VERSION}/tini.asc && \
gpg --batch --keyserver "hkp://p80.pool.sks-keyservers.net:80" --recv-keys 595E85A6B1B4779EA4DAAEC70B588DFF0527A9B7 && \
gpg --batch --verify /tini.asc /tini && \
chmod +x /tini
USER payara
WORKDIR ${HOME_DIR}
# Download and unzip the Payara distribution
RUN wget --no-verbose -O payara.zip ${PAYARA_PKG} && \
echo "${PAYARA_SHA1} *payara.zip" | sha1sum -c - && \
unzip -qq payara.zip -d ./ && \
mv payara*/ appserver && \
# Configure the password file for configuring Payara
echo "AS_ADMIN_PASSWORD=\nAS_ADMIN_NEWPASSWORD=${ADMIN_PASSWORD}" > /tmp/tmpfile && \
echo "AS_ADMIN_PASSWORD=${ADMIN_PASSWORD}" >> ${PASSWORD_FILE} && \
# Configure the payara domain
${PAYARA_DIR}/bin/asadmin --user ${ADMIN_USER} --passwordfile=/tmp/tmpfile change-admin-password --domain_name=${DOMAIN_NAME} && \
${PAYARA_DIR}/bin/asadmin --user=${ADMIN_USER} --passwordfile=${PASSWORD_FILE} start-domain ${DOMAIN_NAME} && \
${PAYARA_DIR}/bin/asadmin --user=${ADMIN_USER} --passwordfile=${PASSWORD_FILE} enable-secure-admin && \
for MEMORY_JVM_OPTION in $(${PAYARA_DIR}/bin/asadmin --user=${ADMIN_USER} --passwordfile=${PASSWORD_FILE} list-jvm-options | grep "Xm[sx]"); do\
${PAYARA_DIR}/bin/asadmin --user=${ADMIN_USER} --passwordfile=${PASSWORD_FILE} delete-jvm-options $MEMORY_JVM_OPTION;\
done && \
# FIXME: when upgrading this container to Java 10+, this needs to be changed to '-XX:+UseContainerSupport' and '-XX:MaxRAMPercentage'
${PAYARA_DIR}/bin/asadmin --user=${ADMIN_USER} --passwordfile=${PASSWORD_FILE} create-jvm-options '-XX\:+UnlockExperimentalVMOptions:-XX\:+UseCGroupMemoryLimitForHeap:-XX\:MaxRAMFraction=1' && \
${PAYARA_DIR}/bin/asadmin --user=${ADMIN_USER} --passwordfile=${PASSWORD_FILE} set-log-attributes com.sun.enterprise.server.logging.GFFileHandler.logtoFile=false && \
${PAYARA_DIR}/bin/asadmin --user=${ADMIN_USER} --passwordfile=${PASSWORD_FILE} stop-domain ${DOMAIN_NAME} && \
# Cleanup unused files
rm -rf \
/tmp/tmpFile \
payara.zip \
${PAYARA_DIR}/glassfish/domains/${DOMAIN_NAME}/osgi-cache \
${PAYARA_DIR}/glassfish/domains/${DOMAIN_NAME}/logs \
${PAYARA_DIR}/glassfish/domains/domain1
# Copy across docker scripts
COPY --chown=payara:payara bin/*.sh ${SCRIPT_DIR}/
RUN mkdir -p ${SCRIPT_DIR}/init.d && \
chmod +x ${SCRIPT_DIR}/*
ENTRYPOINT ["/tini", "--"]
CMD ${SCRIPT_DIR}/entrypoint.sh