Skip to content

Commit 88f3d56

Browse files
committed
ci: use multistage container build to reduce image size
1 parent 4da17af commit 88f3d56

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

packages/tar/src/main/container/Dockerfile

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,17 @@
1+
#
2+
# This container only created a minimalistic JVM runtime environment suitable for running dCache.
3+
#
4+
FROM almalinux:9-minimal as builder
5+
6+
# Add JRE
7+
RUN microdnf -y install java-21-openjdk-devel java-21-openjdk-jmods binutils
8+
RUN jlink --compress=zip-6 --strip-debug --no-header-files --no-man-pages --add-modules java.base,java.compiler,java.instrument,java.logging,java.management,java.naming,java.security.jgss,java.transaction.xa,java.xml,jdk.jfr,jdk.security.auth,jdk.unsupported,java.desktop,java.sql,jdk.naming.dns,java.rmi,jdk.crypto.cryptoki --output /jlink-runtime
9+
110

211
# Minimalistic Java image
312
FROM almalinux:9-minimal
13+
COPY --from=builder /jlink-runtime /jlink-runtime
14+
RUN ln -s /jlink-runtime/bin/java /usr/bin/java
415

516
ENV DCACHE_INSTALL_DIR=/opt/dcache
617

@@ -19,7 +30,7 @@ RUN echo "dcache:x:994:1000::/home/dcache:/bin/bash" >> /etc/passwd
1930
RUN echo "dcache:!!:18438::::::" >> /etc/shadow
2031

2132
# Add JRE
22-
RUN microdnf -y install java-21-openjdk-headless hostname which procps-ng tar gzip
33+
RUN microdnf -y install hostname which procps-ng tar gzip
2334

2435
# Add dCache
2536
COPY maven /opt/dcache
@@ -54,7 +65,7 @@ RUN chown -R dcache:dcache ${DCACHE_INSTALL_DIR}/var /pool
5465

5566
# add s3hsm for fake tape interraction
5667
RUN curl -s -L -o /tmp/s3hsm.tar.gz https://github.com/kofemann/s3hsm/releases/download/v0.1.0/s3hsm_0.1.0_linux_amd64.tar.gz
57-
RUN cd /usr/bin && tar xzf /tmp/s3hsm.tar.gz s3hsm
68+
RUN cd /usr/bin && tar xzf /tmp/s3hsm.tar.gz s3hsm && rm /tmp/s3hsm.tar.gz
5869

5970
# the data log files must survive container restarts
6071
VOLUME ${DCACHE_INSTALL_DIR}/var

0 commit comments

Comments
 (0)