Skip to content

Instantly share code, notes, and snippets.

@lopcode
Created September 24, 2022 10:27
Show Gist options
  • Save lopcode/5d69319854af308ee176f0dd64d9edb1 to your computer and use it in GitHub Desktop.
Save lopcode/5d69319854af308ee176f0dd64d9edb1 to your computer and use it in GitHub Desktop.
FROM --platform=$TARGETPLATFORM eclipse-temurin:18-jdk as jre-build
ARG jar
ARG docs
WORKDIR /app
RUN mkdir build
ADD $jar build/service.jar
RUN jdeps \
--ignore-missing-deps \
--multi-release 18 \
--print-module-deps \
build/service.jar > jre-deps.info
RUN echo -n ",jdk.crypto.ec" >> jre-deps.info # SHA256withECDSA support
RUN tr -d '[:space:]' <jre-deps.info >jre-deps-tr.info
RUN echo $(cat jre-deps-tr.info)
RUN jlink \
--add-modules $(cat jre-deps-tr.info) \
--compress 2 \
--strip-debug \
--no-header-files \
--no-man-pages \
--output jre
FROM --platform=$TARGETPLATFORM debian:stable-20220912-slim
WORKDIR /deploy
ARG docs
ARG jar
COPY $docs docs/
COPY --from=jre-build /app/jre jre
ADD $jar service.jar
RUN chmod -R 555 docs
USER nobody
ENV APP_PORT=8080
ENV ACCESS_TOKEN=""
ENV SERVING_PREFIX=""
EXPOSE $APP_PORT
ENTRYPOINT ["jre/bin/java", "-jar", "service.jar"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment