Skip to content

Commit 16daf81

Browse files
committed
[feature] Switch from Google Cloud Platform distroless Docker base image to Chainguard distroless base image. We now have latest JDK 8 and nonroot user operation
1 parent 5689648 commit 16daf81

File tree

4 files changed

+75
-132
lines changed

4 files changed

+75
-132
lines changed

exist-docker/pom.xml

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,10 @@
107107
<header>${project.parent.relativePath}/../elemental-parent/elemental-LGPL-21-ONLY-license.template.txt</header>
108108
<excludes>
109109
<exclude>pom.xml</exclude>
110-
<exclude>src/**</exclude>
110+
<exclude>src/assembly/**</exclude>
111+
<exclude>src/main/xslt/**</exclude>
112+
<exclude>src/test/**</exclude>
113+
<exclude>**.md</exclude>
111114
</excludes>
112115
</licenseSet>
113116

@@ -126,11 +129,7 @@
126129
</multi>
127130
<includes>
128131
<include>pom.xml</include>
129-
<include>src/main/resources-filtered/**</include>
130132
</includes>
131-
<excludes>
132-
<exclude>**.md</exclude>
133-
</excludes>
134133
</licenseSet>
135134

136135
<licenseSet>

exist-docker/src/main/resources-filtered/Dockerfile

Lines changed: 49 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -18,66 +18,53 @@
1818
# License along with this library; if not, write to the Free Software
1919
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
2020
#
21-
# NOTE: Parts of this file contain code from 'The eXist-db Authors'.
22-
# The original license header is included below.
23-
#
24-
# =====================================================================
25-
#
26-
# eXist-db Open Source Native XML Database
27-
# Copyright (C) 2001 The eXist-db Authors
28-
#
29-
30-
# http://www.exist-db.org
31-
#
32-
# This library is free software; you can redistribute it and/or
33-
# modify it under the terms of the GNU Lesser General Public
34-
# License as published by the Free Software Foundation; either
35-
# version 2.1 of the License, or (at your option) any later version.
36-
#
37-
# This library is distributed in the hope that it will be useful,
38-
# but WITHOUT ANY WARRANTY; without even the implied warranty of
39-
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
40-
# Lesser General Public License for more details.
41-
#
42-
# You should have received a copy of the GNU Lesser General Public
43-
# License along with this library; if not, write to the Free Software
44-
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
45-
#
4621

47-
# Install latest JRE 8 in Debian Stretch (which is the base of gcr.io/distroless/java:8)
48-
FROM debian:stretch-slim as updated-jre
49-
RUN echo "deb http://archive.debian.org/debian stretch main" > /etc/apt/sources.list
50-
RUN echo "deb http://archive.debian.org/debian stretch-backports main" >> /etc/apt/sources.list
51-
RUN apt-get update && apt-get -y dist-upgrade
52-
RUN apt-get install -y openjdk-8-jre-headless
53-
RUN apt-get install -y expat fontconfig # Install tools required by FOP
54-
55-
FROM gcr.io/distroless/java:8
56-
57-
# Copy over updated JRE from Debian Stretch
58-
COPY --from=updated-jre /etc/java-8-openjdk /etc/java-8-openjdk
59-
COPY --from=updated-jre /usr/lib/jvm/java-8-openjdk-amd64 /usr/lib/jvm/java-8-openjdk-amd64
60-
COPY --from=updated-jre /usr/share/gdb/auto-load/usr/lib/jvm/java-8-openjdk-amd64 /usr/share/gdb/auto-load/usr/lib/jvm/java-8-openjdk-amd64
61-
62-
# Copy over dependencies for Apache FOP, missing from GCR's JRE
63-
COPY --from=updated-jre /usr/lib/x86_64-linux-gnu/libfreetype.so.6 /usr/lib/x86_64-linux-gnu/libfreetype.so.6
64-
COPY --from=updated-jre /usr/lib/x86_64-linux-gnu/liblcms2.so.2 /usr/lib/x86_64-linux-gnu/liblcms2.so.2
65-
COPY --from=updated-jre /usr/lib/x86_64-linux-gnu/libpng16.so.16 /usr/lib/x86_64-linux-gnu/libpng16.so.16
66-
COPY --from=updated-jre /usr/lib/x86_64-linux-gnu/libfontconfig.so.1 /usr/lib/x86_64-linux-gnu/libfontconfig.so.1
67-
68-
# Copy dependencies for Apache Batik (used by Apache FOP to handle SVG rendering)
69-
COPY --from=updated-jre /etc/fonts /etc/fonts
70-
COPY --from=updated-jre /lib/x86_64-linux-gnu/libexpat.so.1 /lib/x86_64-linux-gnu/libexpat.so.1
71-
COPY --from=updated-jre /usr/share/fontconfig /usr/share/fontconfig
72-
COPY --from=updated-jre /usr/share/fonts/truetype/dejavu /usr/share/fonts/truetype/dejavu
22+
# Install latest JRE 8 in Chainguard Wolfi temporary builder image
23+
FROM cgr.dev/chainguard/wolfi-base AS builder
24+
25+
RUN apk update && apk upgrade
26+
# Install dependencies needed for JRE
27+
RUN apk add zlib libjpeg-turbo libpng lcms2 freetype ttf-dejavu fontconfig-config libfontconfig1 expat libuuid libbrotlicommon1 libbrotlidec1 libbrotlienc1 libcrypt1
28+
# Install latest JRE
29+
RUN apk add openjdk-8-jre
30+
31+
# Use Chainguard distroless glibc base for dynamically linked libraries
32+
FROM cgr.dev/chainguard/glibc-dynamic:latest
33+
34+
# Copy over dependencies for updated JRE from Wolfi
35+
COPY --from=builder /etc/ca-certificates /etc/ca-certificates
36+
COPY --from=builder /etc/ca-certificates.conf /etc/ca-certificates.conf
37+
COPY --from=builder /lib/libz.so.1 /lib/libz.so.1
38+
COPY --from=builder /usr/lib/libjpeg.so.8 /usr/lib/libjpeg.so.8
39+
COPY --from=builder /usr/lib/libturbojpeg.so.0 /usr/lib/libturbojpeg.so.0
40+
COPY --from=builder /usr/lib/libpng16.so.16 /usr/lib/libpng16.so.16
41+
COPY --from=builder /usr/lib/liblcms2.so.2 /usr/lib/liblcms2.so.2
42+
COPY --from=builder /usr/lib/libfreetype.so.6 /usr/lib/libfreetype.so.6
43+
COPY --from=builder /usr/share/fonts /usr/share/fonts
44+
COPY --from=builder /etc/fonts /etc/fonts
45+
COPY --from=builder /usr/share/fontconfig /usr/share/fontconfig
46+
COPY --from=builder /usr/share/gettext /usr/share/gettext
47+
COPY --from=builder /usr/share/xml /usr/share/xml
48+
COPY --from=builder /usr/lib/libfontconfig.so.1 /usr/lib/libfontconfig.so.1
49+
COPY --from=builder /usr/lib/libexpat.so.1 /usr/lib/libexpat.so.1
50+
COPY --from=builder /usr/lib/libuuid.so.1 /usr/lib/libuuid.so.1
51+
COPY --from=builder /usr/lib/libbrotlicommon.so.1 /usr/lib/libbrotlicommon.so.1
52+
COPY --from=builder /usr/lib/libbrotlidec.so.1 /usr/lib/libbrotlidec.so.1
53+
COPY --from=builder /usr/lib/libbrotlienc.so.1 /usr/lib/libbrotlienc.so.1
54+
55+
# Copy over updated JRE from Wolfi
56+
COPY --from=builder /usr/lib/jvm/java-1.8-openjdk /usr/lib/jvm/java-1.8-openjdk
57+
58+
# Switch to nonroot user
59+
USER nonroot
7360

7461
# Copy Elemental
7562
COPY LICENSE /elemental/LICENSE
7663
COPY autodeploy /elemental/autodeploy
7764
COPY etc /elemental/etc
7865
COPY lib /elemental/lib
79-
COPY logs /elemental/logs
80-
66+
COPY --chown=nonroot logs /elemental/logs
67+
COPY --chown=nonroot logs /elemental/data
8168

8269
# Build-time metadata as defined at http://label-schema.org
8370
# and used by autobuilder @hooks/build
@@ -97,26 +84,15 @@ ARG CACHE_MEM
9784
ARG MAX_BROKER
9885
ARG JVM_MAX_RAM_PERCENTAGE
9986

100-
ENV ELEMENTAL_HOME "/elemental"
101-
ENV EXIST_HOME "/elemental"
102-
ENV CLASSPATH=/elemental/lib/${elemental.uber.jar.filename}
103-
104-
ENV JAVA_TOOL_OPTIONS \
105-
-Dfile.encoding=UTF8 \
106-
-Dsun.jnu.encoding=UTF-8 \
107-
-Djava.awt.headless=true \
108-
-Dorg.exist.db-connection.cacheSize=${CACHE_MEM:-256}M \
109-
-Dorg.exist.db-connection.pool.max=${MAX_BROKER:-20} \
110-
-Dlog4j.configurationFile=/elemental/etc/log4j2.xml \
111-
-Dexist.home=/elemental \
112-
-Dexist.configurationFile=/elemental/etc/conf.xml \
113-
-Djetty.home=/elemental \
114-
-Dexist.jetty.config=/elemental/etc/jetty/standard.enabled-jetty-configs \
115-
-XX:+UseG1GC \
116-
-XX:+UseStringDeduplication \
117-
-XX:+UseContainerSupport \
118-
-XX:MaxRAMPercentage=${JVM_MAX_RAM_PERCENTAGE:-75.0} \
119-
-XX:+ExitOnOutOfMemoryError
87+
ENV ELEMENTAL_HOME="/elemental"
88+
ENV EXIST_HOME="/elemental"
89+
ENV CLASSPATH="/elemental/lib/${elemental.uber.jar.filename}"
90+
91+
ENV JAVA_HOME="/usr/lib/jvm/java-1.8-openjdk"
92+
93+
ENV JAVA_TOOL_OPTIONS="-Dfile.encoding=UTF8 -Dsun.jnu.encoding=UTF-8 -Djava.awt.headless=true -Dorg.exist.db-connection.cacheSize=${CACHE_MEM:-256}M -Dorg.exist.db-connection.pool.max=${MAX_BROKER:-20} -Dlog4j.configurationFile=/elemental/etc/log4j2.xml -Dexist.home=/elemental -Dexist.configurationFile=/elemental/etc/conf.xml -Djetty.home=/elemental -Dexist.jetty.config=/elemental/etc/jetty/standard.enabled-jetty-configs -XX:+UseG1GC -XX:+UseStringDeduplication -XX:+UseContainerSupport -XX:MaxRAMPercentage=${JVM_MAX_RAM_PERCENTAGE:-75.0} -XX:+ExitOnOutOfMemoryError"
94+
95+
ENV PATH="/usr/lib/jvm/java-1.8-openjdk/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
12096

12197
HEALTHCHECK CMD [ "java", \
12298
"org.exist.start.Main", "client", \

exist-docker/src/main/resources-filtered/Dockerfile-DEBUG

Lines changed: 21 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -18,46 +18,26 @@
1818
# License along with this library; if not, write to the Free Software
1919
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
2020
#
21-
# NOTE: Parts of this file contain code from 'The eXist-db Authors'.
22-
# The original license header is included below.
23-
#
24-
# =====================================================================
25-
#
26-
# eXist-db Open Source Native XML Database
27-
# Copyright (C) 2001 The eXist-db Authors
28-
#
29-
30-
# http://www.exist-db.org
31-
#
32-
# This library is free software; you can redistribute it and/or
33-
# modify it under the terms of the GNU Lesser General Public
34-
# License as published by the Free Software Foundation; either
35-
# version 2.1 of the License, or (at your option) any later version.
36-
#
37-
# This library is distributed in the hope that it will be useful,
38-
# but WITHOUT ANY WARRANTY; without even the implied warranty of
39-
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
40-
# Lesser General Public License for more details.
41-
#
42-
# You should have received a copy of the GNU Lesser General Public
43-
# License along with this library; if not, write to the Free Software
44-
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
45-
#
4621

47-
# Use JDK 8 in Debian Stretch (as our production image gcr.io/distroless/java:8 is based on Debian Stretch with just a JRE)
48-
FROM debian:stretch-slim
49-
RUN echo "deb http://archive.debian.org/debian stretch main" > /etc/apt/sources.list
50-
RUN echo "deb http://archive.debian.org/debian stretch-backports main" >> /etc/apt/sources.list
51-
RUN apt-get update && apt-get -y dist-upgrade
52-
RUN apt-get install -y openjdk-8-jdk-headless
53-
RUN apt-get install -y expat fontconfig # Install tools required by FOP
22+
# Use Chainguard Wolfi
23+
FROM cgr.dev/chainguard/wolfi-base
24+
25+
RUN apk update && apk upgrade
26+
# Install dependencies needed for JDK
27+
RUN apk add zlib libjpeg-turbo libpng lcms2 freetype ttf-dejavu fontconfig-config libfontconfig1 expat libuuid libbrotlicommon1 libbrotlidec1 libbrotlienc1 libcrypt1
28+
# Install latest JDK
29+
RUN apk add openjdk-8
30+
31+
# Switch to nonroot user
32+
USER nonroot
5433

5534
# Copy Elemental
5635
COPY LICENSE /elemental/LICENSE
5736
COPY autodeploy /elemental/autodeploy
5837
COPY etc /elemental/etc
5938
COPY lib /elemental/lib
60-
COPY logs /elemental/logs
39+
COPY --chown=nonroot logs /elemental/logs
40+
COPY --chown=nonroot logs /elemental/data
6141

6242
# Build-time metadata as defined at http://label-schema.org
6343
# and used by autobuilder @hooks/build
@@ -78,27 +58,15 @@ ARG MAX_BROKER
7858
ARG JVM_MAX_RAM_PERCENTAGE
7959
ARG JVM_JDWP_SUSPEND
8060

81-
ENV ELEMENTAL_HOME "/elemental"
82-
ENV EXIST_HOME "/elemental"
83-
ENV CLASSPATH=/elemental/lib/${elemental.uber.jar.filename}
61+
ENV ELEMENTAL_HOME="/elemental"
62+
ENV EXIST_HOME="/elemental"
63+
ENV CLASSPATH="/elemental/lib/${elemental.uber.jar.filename}"
64+
65+
ENV JAVA_HOME="/usr/lib/jvm/java-1.8-openjdk"
66+
67+
ENV JAVA_TOOL_OPTIONS="-Dfile.encoding=UTF8 -Dsun.jnu.encoding=UTF-8 -Djava.awt.headless=true -Dorg.exist.db-connection.cacheSize=${CACHE_MEM:-256}M -Dorg.exist.db-connection.pool.max=${MAX_BROKER:-20} -Dlog4j.configurationFile=/elemental/etc/log4j2.xml -Dexist.home=/elemental -Dexist.configurationFile=/elemental/etc/conf.xml -Djetty.home=/elemental -Dexist.jetty.config=/elemental/etc/jetty/standard.enabled-jetty-configs -XX:+UseG1GC -XX:+UseStringDeduplication -XX:+UseContainerSupport -XX:MaxRAMPercentage=${JVM_MAX_RAM_PERCENTAGE:-75.0} -XX:+ExitOnOutOfMemoryError -agentlib:jdwp=transport=dt_socket,server=y,suspend=${JVM_JDWP_SUSPEND:-n},address=5005"
8468

85-
ENV JAVA_TOOL_OPTIONS \
86-
-Dfile.encoding=UTF8 \
87-
-Dsun.jnu.encoding=UTF-8 \
88-
-Djava.awt.headless=true \
89-
-Dorg.exist.db-connection.cacheSize=${CACHE_MEM:-256}M \
90-
-Dorg.exist.db-connection.pool.max=${MAX_BROKER:-20} \
91-
-Dlog4j.configurationFile=/elemental/etc/log4j2.xml \
92-
-Dexist.home=/elemental \
93-
-Dexist.configurationFile=/elemental/etc/conf.xml \
94-
-Djetty.home=/elemental \
95-
-Dexist.jetty.config=/elemental/etc/jetty/standard.enabled-jetty-configs \
96-
-XX:+UseG1GC \
97-
-XX:+UseStringDeduplication \
98-
-XX:+UseContainerSupport \
99-
-XX:MaxRAMPercentage=${JVM_MAX_RAM_PERCENTAGE:-75.0} \
100-
-XX:+ExitOnOutOfMemoryError \
101-
-agentlib:jdwp=transport=dt_socket,server=y,suspend=${JVM_JDWP_SUSPEND:-n},address=5005
69+
ENV PATH="/usr/lib/jvm/java-1.8-openjdk/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
10270

10371
HEALTHCHECK CMD [ "java", \
10472
"org.exist.start.Main", "client", \

exist-docker/src/main/resources-filtered/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ ${project.description}
55

66
This module holds the source files for building a minimal docker image of the [Elemental](https://www.elemental.xyz)
77
NoSQL Database. Images are automatically updated as part of the build-test life-cycle.
8-
These images are based on Google Cloud Platform's ["Distroless" Docker Images](https://github.com/GoogleCloudPlatform/distroless).
8+
These images are based on Chainguard's ["Distroless" Docker Images](https://edu.chainguard.dev/chainguard/chainguard-images/about/getting-started-distroless/).
99

1010

1111
## Requirements

0 commit comments

Comments
 (0)