Skip to content

Commit 17fbc4a

Browse files
committed
add eclipse temurin jre 17
1 parent e4eb8f1 commit 17fbc4a

File tree

1 file changed

+160
-0
lines changed

1 file changed

+160
-0
lines changed

Dockerfile-tomcat-temurin-jre

Lines changed: 160 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,160 @@
1+
FROM alpine:latest AS stage-0
2+
3+
# Download jdk binary from temurin github (in future add sha checksum verification)
4+
# Use jlink and we can use it remove more default modules and reduce image size
5+
6+
# see https://www.apache.org/dist/tomcat/tomcat-$TOMCAT_MAJOR/KEYS
7+
# see also "update.sh" (https://github.com/docker-library/tomcat/blob/master/update.sh)
8+
# ENV GPG_KEYS 05AB33110949707C93A279E3D3EFE6B686867BA6 07E48665A34DCAFAE522E5E6266191C37C037D42 47309207D818FFD8DCD3F83F1931D684307A10A5 541FBE7D8F78B25E055DDEE13C370389288584E7 61B832AC2F1C5A90F0F9B00A1C506407564C17A3 79F7026C690BAA50B92CD8B66A3AD3F4F22C4FED 9BA44C2621385CB966EBA586F72C284D731FABEE A27677289986DB50844682F8ACB77FC2E86E29AC A9C5DF4D22E99998D9875A5110C01C5A2F6059E7 DCFD35E0BF8CA7344752DE8B6FB21E8933C60243 F3A04C595DB5B6A5F1ECA43E3B7BBB100D811BBE F7DA48BB64BCB84ECBA7EE6935CD23C10D498E23
9+
10+
ENV JDK_MAJOR 17
11+
ENV JDK_VERSION 17_35
12+
ENV JDK_DOWNLOAD_URL https://github.com/adoptium/temurin17-binaries/releases/download/jdk-17%2B35/OpenJDK17-jdk_x64_alpine-linux_hotspot_17_35.tar.gz
13+
ENV JDK_SHA512_URL https://github.com/adoptium/temurin17-binaries/releases/download/jdk-17%2B35/OpenJDK17-jdk_x64_alpine-linux_hotspot_17_35.tar.gz.sha256.txt
14+
# https://github.com/adoptium/temurin17-binaries/releases/download/jdk-17%2B35/OpenJDK17-jdk_x64_alpine-linux_hotspot_17_35.tar.gz.sha256.txt
15+
# ENV TOMCAT_SHA512 307ca646bac267e529fb0862278f7133fe80813f0af64a44aed949f4c7a9a98aeb9bd7f08b087645b40c6fefdd3a7fe519e4858a3dbf0a19c38c53704f92b575
16+
17+
WORKDIR /root
18+
19+
# Download JDK
20+
RUN set -eux;\
21+
mkdir -p target/alpine-linux/x64/hotspot/ \
22+
&& wget "$JDK_DOWNLOAD_URL" -qO target/alpine-linux/x64/hotspot/OpenJDK17-jdk_x64_alpine-linux_hotspot_${JDK_VERSION}.tar.gz\
23+
# && wget -qO- "$JDK_SHA512_URL" | sha512sum -c -\
24+
&& tar -xf target/alpine-linux/x64/hotspot/OpenJDK17-jdk_x64_alpine-linux_hotspot_${JDK_VERSION}.tar.gz --strip-components=1
25+
26+
RUN set -eux \
27+
&& ./bin/jlink --output /usr/lib/jvm/default-jvm/jre/bin/jre --compress=2 --no-header-files --no-man-pages --strip-java-debug-attributes --module-path ../jmods --add-modules jdk.xml.dom,java.management,java.management.rmi,java.naming,java.net.http,java.prefs,java.rmi,java.scripting,java.se,java.security.jgss,java.security.sasl,java.smartcardio,java.sql,java.sql.rowset,java.transaction.xa,java.xml,java.xml.crypto
28+
29+
FROM alpine:latest
30+
MAINTAINER "Prasad CH <[email protected]>"
31+
ENV OS_RELEASE="Alpine Linux v3.14.2"
32+
33+
# Installed main dependencies:
34+
# ca-certificates-20191127-r5 x86_64: for certificate management to support SSL
35+
# openjdk11: OpenJDK 64-Bit Server VM Temurin-17+35 (build 17+35, mixed mode)
36+
# fontconfig-2.13.1-r4 x86_64 : For supporting UI/ Fonts for reporting purposes
37+
# freetype-2.10.4-r1 x86_64: To support freetype fonts
38+
# Tomcat: Java Runtime Container
39+
40+
# https://adoptopenjdk.net/installation.html#x64_linux-jre
41+
# Set JRE_HOME not JAVA_HOME as we don't intend to run tomcat in debug mode
42+
ENV JRE_HOME=/usr/lib/jvm/default-jvm/jre
43+
COPY --from=stage-0 /usr/lib/jvm/default-jvm/jre/bin/jre ${JRE_HOME}
44+
ENV PATH=${JRE_HOME}/bin:$PATH
45+
ENV JAVA_VERSION=17+35
46+
47+
RUN set -eux;\
48+
49+
# CIS-4.7 Ensure update instructions are not use alone in the Dockerfile
50+
# apk update \
51+
# && apk upgrade \
52+
# && apk add --no-cache ca-certificates\
53+
54+
# Now Add Support for cacerts
55+
# https://hackernoon.com/alpine-docker-image-with-secured-communication-ssl-tls-go-restful-api-128eb6b54f1f
56+
apk add --no-cache ca-certificates\
57+
58+
# Now Add Support for UI/Font configurations
59+
# java.lang.UnsatisfiedLinkError: /usr/local/openjdk-11/lib/libfontmanager.so: libfreetype.so.6: cannot open shared object file: No such file or directory
60+
# java.lang.NoClassDefFoundError: Could not initialize class sun.awt.X11FontManager
61+
# https://github.com/docker-library/openjdk/pull/235#issuecomment-424466077
62+
\fontconfig freetype\
63+
64+
&& rm -rf /var/cache/apk/*
65+
66+
# COPY ./org-cacert-bundle.crt /usr/local/share/ca-certificates/mycert.crt
67+
# COPY --from stage-0 /usr/local/share/ca-certificates /usr/local/share/ca-certificates
68+
RUN set -eux;\
69+
chmod 755 /usr/local/share/ca-certificates\
70+
&& update-ca-certificates\
71+
# Load Organisational fonts
72+
&& mkdir -p /usr/share/fonts/default/TrueType
73+
# COPY --from stage-0 /tmp/custom-fonts/ /usr/share/fonts/default/TrueType
74+
75+
76+
# Inspired from https://github.com/docker-library/tomcat/blob/d570ad0cee10e4526bcbb03391b2c0e322b59313/9.0/jdk11/openjdk-slim/Dockerfile
77+
ENV CATALINA_HOME /usr/local/tomcat
78+
ENV PATH $CATALINA_HOME/bin:$PATH
79+
RUN mkdir -p "$CATALINA_HOME"
80+
81+
WORKDIR $CATALINA_HOME
82+
83+
# let "Tomcat Native" live somewhere isolated
84+
ENV TOMCAT_NATIVE_LIBDIR $CATALINA_HOME/native-jni-lib
85+
ENV LD_LIBRARY_PATH ${LD_LIBRARY_PATH:+$LD_LIBRARY_PATH:}$TOMCAT_NATIVE_LIBDIR
86+
87+
# see https://www.apache.org/dist/tomcat/tomcat-$TOMCAT_MAJOR/KEYS
88+
# see also "update.sh" (https://github.com/docker-library/tomcat/blob/master/update.sh)
89+
ENV GPG_KEYS 05AB33110949707C93A279E3D3EFE6B686867BA6 07E48665A34DCAFAE522E5E6266191C37C037D42 47309207D818FFD8DCD3F83F1931D684307A10A5 541FBE7D8F78B25E055DDEE13C370389288584E7 61B832AC2F1C5A90F0F9B00A1C506407564C17A3 79F7026C690BAA50B92CD8B66A3AD3F4F22C4FED 9BA44C2621385CB966EBA586F72C284D731FABEE A27677289986DB50844682F8ACB77FC2E86E29AC A9C5DF4D22E99998D9875A5110C01C5A2F6059E7 DCFD35E0BF8CA7344752DE8B6FB21E8933C60243 F3A04C595DB5B6A5F1ECA43E3B7BBB100D811BBE F7DA48BB64BCB84ECBA7EE6935CD23C10D498E23
90+
91+
ENV TOMCAT_MAJOR 9
92+
ENV TOMCAT_VERSION 9.0.54
93+
ENV TOMCAT_DOWNLOAD_URL https://downloads.apache.org/tomcat/tomcat-${TOMCAT_MAJOR}/v${TOMCAT_VERSION}/bin/apache-tomcat-${TOMCAT_VERSION}.tar.gz
94+
ENV TOMCAT_SHA512_URL https://downloads.apache.org/tomcat/tomcat-${TOMCAT_MAJOR}/v${TOMCAT_VERSION}/bin/apache-tomcat-${TOMCAT_VERSION}.tar.gz.sha512
95+
# https://downloads.apache.org/tomcat/tomcat-${TOMCAT_MAJOR}/v${TOMCAT_VERSION}/bin/apache-tomcat-${TOMCAT_VERSION}.tar.gz.sha512
96+
# ENV TOMCAT_SHA512 307ca646bac267e529fb0862278f7133fe80813f0af64a44aed949f4c7a9a98aeb9bd7f08b087645b40c6fefdd3a7fe519e4858a3dbf0a19c38c53704f92b575
97+
98+
# Install Tomcat
99+
RUN set -eux;\
100+
wget "$TOMCAT_DOWNLOAD_URL" -qO apache-tomcat-${TOMCAT_VERSION}.tar.gz\
101+
&& wget -qO- "$TOMCAT_SHA512_URL" | sha512sum -c -\
102+
&& mkdir -p /usr/local/tomcat\
103+
&& tar -xf apache-tomcat-${TOMCAT_VERSION}.tar.gz --strip-components=1\
104+
&& rm bin/*.bat\
105+
&& rm apache-tomcat-${TOMCAT_VERSION}.tar.gz*\
106+
&& rm -rf webapps\
107+
&& mkdir webapps\
108+
&& find ./bin/ -name '*.sh' -exec sed -ri 's|^#!/bin/sh$|#!/usr/bin/env sh|' '{}' + \
109+
&& chmod -R +rX . \
110+
&& chmod 777 logs temp work
111+
112+
#Create config and log folders
113+
RUN mkdir -p ${CATALINA_HOME}/conf/ ${CATALINA_HOME}/logs/ ${CATALINA_HOME}/config/
114+
115+
# Copy Custom init scripts if required
116+
# COPY bin/setenv.sh ${CATALINA_HOME}/bin/setenv.sh
117+
118+
# Remove default Tomcat installation files
119+
RUN rm -rf ${CATALINA_HOME}/webapps/*
120+
# COPY conf/context.xml $CATALINA_HOME/conf/context.xml
121+
# COPY conf/server.xml $CATALINA_HOME/conf/server.xml
122+
# COPY conf/web.xml $CATALINA_HOME/conf/web.xml
123+
# COPY conf/logging.properties $CATALINA_HOME/conf/logging.properties
124+
# Copy any additional organisational default files to override tomcat default config files
125+
126+
# User Management
127+
# Add custom group tomcat with 61000 as a groupid to avoid conflicts with any existing groups
128+
RUN addgroup -g 61000 tomcat
129+
130+
# Add custom user tomcat with same uid 61000 as gid to avoid conflict with exist user
131+
# User with no home directory, no password, group as tomcat and username as tomcat
132+
RUN adduser -H -D -G tomcat -u 61000 tomcat
133+
134+
# We put the tomcat user as the owner of the folder of tomcat to limit access to tomcat process on container resources
135+
RUN set -eux;\
136+
chown -R tomcat:tomcat /usr/local/tomcat\
137+
# Users cannot modify configuration of tomcat
138+
&& chmod -R g+r /usr/local/tomcat/conf\
139+
# Users can modify the other folders
140+
&& chmod -R g+w /usr/local/tomcat/logs\
141+
&& chmod -R g+w /usr/local/tomcat/temp\
142+
&& chmod -R g+w /usr/local/tomcat/webapps\
143+
&& chmod -R g+w /usr/local/tomcat/work\
144+
# Activate the sticky-bit for new files keep permissions defined:
145+
&& chmod -R g+s /usr/local/tomcat/conf\
146+
&& chmod -R g+s /usr/local/tomcat/logs\
147+
&& chmod -R g+s /usr/local/tomcat/temp\
148+
&& chmod -R g+s /usr/local/tomcat/webapps\
149+
&& chmod -R g+s /usr/local/tomcat/work
150+
151+
# Set Execute permissions on init script
152+
# RUN chown tomcat:tomcat ${CATALINA_HOME}/bin/setenv.sh
153+
# RUN chmod 750 ${CATALINA_HOME}/bin/setenv.sh
154+
155+
# Set user as tocmat by uid to be compatible with kubernetes psp
156+
USER 61000
157+
158+
EXPOSE 8080
159+
160+
CMD [ "catalina.sh", "run" ]

0 commit comments

Comments
 (0)