Skip to content

Commit 637bc28

Browse files
committed
Update Dockerfile for JRE 8
1 parent fb32cc3 commit 637bc28

File tree

1 file changed

+120
-0
lines changed

1 file changed

+120
-0
lines changed

Dockerfile-tomcat-jre-8

Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
# docker build -t prasad1210/tomcat-custom:9.0.35.1-alpine-jre-1.8.0-242-b08 . -f Dockerfile-tomcat-jre-8 --no-cache
2+
FROM alpine:latest
3+
4+
MAINTAINER Prasad CH<[email protected]>
5+
6+
# Installed main dependencies:
7+
# ca-certificates-cacert-20191127-r1 x86_64: for certificate management to support SSL
8+
# openjdk8-jre-8.242.08-r2: OpenJDK built by Simon Frankenberger <[email protected]> from https://hg.openjdk.java.net/jdk-updates/jdk11u
9+
# fontconfig-2.13.1-r2 x86_64 : For supporting UI/ Fonts for reporting purposes
10+
# freetype-2.10.1-r0 x86_64: To support freetype fonts
11+
# Tomcat: Run a Java Container
12+
13+
# https://adoptopenjdk.net/installation.html#x64_linux-jre
14+
RUN mkdir -p /usr/lib/jvm/jre/bin
15+
RUN apk --no-cache --virtual add openjdk8-jre --repository=http://dl-cdn.alpinelinux.org/alpine/edge/community
16+
ENV PATH=/usr/lib/jvm/default-jre/bin:$PATH
17+
ENV JAVA_HOME=/usr/lib/jvm/default-jre/
18+
ENV JAVA_VERSION=11.0.7+11-alpine-r1
19+
20+
RUN set -eux;\
21+
apk update \
22+
# Now Add Support for cacerts
23+
# https://hackernoon.com/alpine-docker-image-with-secured-communication-ssl-tls-go-restful-api-128eb6b54f1f
24+
&& apk add --no-cache ca-certificates\
25+
26+
# Now Add Support for UI/Font configurations
27+
# java.lang.UnsatisfiedLinkError: /usr/local/openjdk-11/lib/libfontmanager.so: libfreetype.so.6: cannot open shared object file: No such file or directory
28+
# java.lang.NoClassDefFoundError: Could not initialize class sun.awt.X11FontManager
29+
# https://github.com/docker-library/openjdk/pull/235#issuecomment-424466077
30+
\fontconfig freetype\
31+
32+
&& rm -rf /var/cache/apk/*
33+
34+
# COPY ./org-cacert-bundle.crt /usr/local/share/ca-certificates/mycert.crt
35+
# COPY --from stage-0 /usr/local/share/ca-certificates /usr/local/share/ca-certificates
36+
RUN set -eux;\
37+
chmod 755 /usr/local/share/ca-certificates\
38+
&& update-ca-certificates\
39+
# Load Organisational fonts
40+
&& mkdir -p /usr/share/fonts/default/TrueType
41+
# COPY --from stage-0 /tmp/custom-fonts/ /usr/share/fonts/default/TrueType
42+
43+
44+
# Inspired from https://github.com/docker-library/tomcat/blob/d570ad0cee10e4526bcbb03391b2c0e322b59313/9.0/jdk11/openjdk-slim/Dockerfile
45+
ENV CATALINA_HOME /usr/local/tomcat
46+
ENV PATH $CATALINA_HOME/bin:$PATH
47+
RUN mkdir -p "$CATALINA_HOME"
48+
49+
WORKDIR $CATALINA_HOME
50+
51+
# let "Tomcat Native" live somewhere isolated
52+
ENV TOMCAT_NATIVE_LIBDIR $CATALINA_HOME/native-jni-lib
53+
ENV LD_LIBRARY_PATH ${LD_LIBRARY_PATH:+$LD_LIBRARY_PATH:}$TOMCAT_NATIVE_LIBDIR
54+
55+
# see https://www.apache.org/dist/tomcat/tomcat-$TOMCAT_MAJOR/KEYS
56+
# see also "update.sh" (https://github.com/docker-library/tomcat/blob/master/update.sh)
57+
ENV GPG_KEYS 05AB33110949707C93A279E3D3EFE6B686867BA6 07E48665A34DCAFAE522E5E6266191C37C037D42 47309207D818FFD8DCD3F83F1931D684307A10A5 541FBE7D8F78B25E055DDEE13C370389288584E7 61B832AC2F1C5A90F0F9B00A1C506407564C17A3 79F7026C690BAA50B92CD8B66A3AD3F4F22C4FED 9BA44C2621385CB966EBA586F72C284D731FABEE A27677289986DB50844682F8ACB77FC2E86E29AC A9C5DF4D22E99998D9875A5110C01C5A2F6059E7 DCFD35E0BF8CA7344752DE8B6FB21E8933C60243 F3A04C595DB5B6A5F1ECA43E3B7BBB100D811BBE F7DA48BB64BCB84ECBA7EE6935CD23C10D498E23
58+
59+
ENV TOMCAT_MAJOR 9
60+
ENV TOMCAT_VERSION 9.0.35
61+
ENV TOMCAT_DOWNLOAD_URL https://downloads.apache.org/tomcat/tomcat-9/v9.0.35/bin/apache-tomcat-9.0.35.tar.gz
62+
ENV TOMCAT_SHA512 0db27185d9fc3174f2c670f814df3dda8a008b89d1a38a5d96cbbe119767ebfb1cf0bce956b27954aee9be19c4a7b91f2579d967932207976322033a86075f98
63+
64+
# Install Tomcat
65+
RUN set -eux;\
66+
wget "$TOMCAT_DOWNLOAD_URL"\
67+
&& echo "$TOMCAT_SHA512 *apache-tomcat-9.0.35.tar.gz" | sha512sum -c -\
68+
&& mkdir -p /usr/local/tomcat\
69+
&& tar -xf apache-tomcat-9.0.35.tar.gz --strip-components=1\
70+
&& rm bin/*.bat\
71+
&& rm apache-tomcat-9.0.35.tar.gz*\
72+
&& rm -rf webapps\
73+
&& mkdir webapps\
74+
&& find ./bin/ -name '*.sh' -exec sed -ri 's|^#!/bin/sh$|#!/usr/bin/env sh|' '{}' + \
75+
&& chmod -R +rX . \
76+
&& chmod 777 logs temp work
77+
78+
#Create config and log folders
79+
RUN mkdir -p ${CATALINA_HOME}/conf/ ${CATALINA_HOME}/logs/ ${CATALINA_HOME}/config/
80+
81+
# Copy Custom init scripts if required
82+
# COPY bin/setenv.sh ${CATALINA_HOME}/bin/setenv.sh
83+
# RUN chmod 750 ${CATALINA_HOME}/bin/setenv.sh
84+
85+
# Remove default Tomcat installation files
86+
RUN rm -rf ${CATALINA_HOME}/webapps/*
87+
# Copy any additional organisational default files to override tomcat default config files
88+
89+
90+
# User Management
91+
# Add custom group tomcat with 61000 as a groupid to avoid conflicts with any existing groups
92+
RUN addgroup -g 61000 tomcat
93+
94+
# Add custom user tomcat with same uid 61000 as gid to avoid conflict with exist user
95+
# User with no home directory, no password, group as tomcat and username as tomcat
96+
RUN adduser -H -D -G tomcat -u 61000 tomcat
97+
98+
# We put the tomcat user as the owner of the folder of tomcat to limit access to tomcat process on container resources
99+
RUN set -eux;\
100+
chown -R tomcat:tomcat /usr/local/tomcat\
101+
# Users cannot modify configuration of tomcat
102+
&& chmod -R g+r /usr/local/tomcat/conf\
103+
# Users can modify the other folders
104+
&& chmod -R g+w /usr/local/tomcat/logs\
105+
&& chmod -R g+w /usr/local/tomcat/temp\
106+
&& chmod -R g+w /usr/local/tomcat/webapps\
107+
&& chmod -R g+w /usr/local/tomcat/work\
108+
# Activate the sticky-bit for new files keep permissions defined:
109+
&& chmod -R g+s /usr/local/tomcat/conf\
110+
&& chmod -R g+s /usr/local/tomcat/logs\
111+
&& chmod -R g+s /usr/local/tomcat/temp\
112+
&& chmod -R g+s /usr/local/tomcat/webapps\
113+
&& chmod -R g+s /usr/local/tomcat/work
114+
115+
# Set user as tocmat by uid to be compatible with kubernetes psp
116+
USER 61000
117+
118+
EXPOSE 8080
119+
120+
CMD ["catalina.sh", "run"]

0 commit comments

Comments
 (0)