Created
October 19, 2024 13:53
-
-
Save ahndmal/fe456e7ee37b6938287ce71eb2163334 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Build our minimal JRE using jlink | |
FROM openjdk:17-oraclelinux8 as builder | |
USER root | |
RUN jlink \ | |
--module-path "$JAVA_HOME/jmods" \ | |
--add-modules java.compiler,java.sql,java.naming,java.management,java.instrument,java.rmi,java.desktop,jdk.internal.vm.compiler.management,java.xml.crypto,java.scripting,java.security.jgss,jdk.httpserver,java.net.http,jdk.naming.dns,jdk.crypto.cryptoki,jdk.unsupported \ | |
--verbose \ | |
--strip-debug \ | |
--compress 2 \ | |
--no-header-files \ | |
--no-man-pages \ | |
--output /opt/jre-minimal | |
USER app | |
# Now it is time for us to build our real image on top of an slim version of debian | |
FROM bitnami/minideb:bullseye | |
COPY --from=builder /opt/jre-minimal /opt/jre-minimal | |
ENV JAVA_HOME=/opt/jre-minimal | |
ENV PATH="$PATH:$JAVA_HOME/bin" | |
VOLUME /tmp | |
# Copy the JRE created in the last step into our $JAVA_HOME | |
# For gradle | |
# COPY build/libs/app-*.jar app.jar | |
# For maven | |
# COPY target/app-*.jar app.jar | |
ENTRYPOINT ["java","-jar","/app.jar"] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment