Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dockerfile changed #39

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 15 additions & 31 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,36 +1,20 @@
FROM azul/zulu-openjdk-alpine:11 as packager
LABEL maintainer="gsasikumar@github"
# Stage 1: Build stage
FROM --platform=$BUILDPLATFORM openjdk:8-jdk-alpine as build

WORKDIR /app

RUN { \
java --version ; \
echo "jlink version:" && \
/usr/lib/jvm/zulu11/bin/jlink --version ; \
}
ENV JAVA_MINIMAL=/opt/jre
# build modules distribution
RUN /usr/lib/jvm/zulu11/bin/jlink \
--verbose \
--add-modules \
java.base,java.sql,java.naming,java.desktop,java.management,java.security.jgss,java.instrument \
# java.naming - javax/naming/NamingException
# java.desktop - java/beans/PropertyEditorSupport
# java.management - javax/management/MBeanServer
# java.security.jgss - org/ietf/jgss/GSSException
# java.instrument - java/lang/instrument/IllegalClassFormatException
--compress 2 \
--strip-debug \
--no-header-files \
--no-man-pages \
--output "$JAVA_MINIMAL"
# Copy source code and build
COPY . .

# Second stage, add only our minimal "JRE" distr and our app
FROM gcr.io/distroless/java11-debian11
RUN ./gradlew clean build

ENV JAVA_MINIMAL=/opt/jre
ENV PATH="$PATH:$JAVA_MINIMAL/bin"
COPY --from=packager "$JAVA_MINIMAL" "$JAVA_MINIMAL"
# Stage 2: Runtime stage
FROM --platform=$TARGETPLATFORM openjdk:8-jre-alpine

EXPOSE 8080
ADD ./build/libs/forwardsecrecy.jar forwardsecrecy.jar
ENTRYPOINT ["java","-Djava.security.egd=file:/dev/./urandom", "-jar","/forwardsecrecy.jar"]
WORKDIR /app

# Copy built artifacts from the build stage
COPY --from=build /app/build/libs/forwardsecrecy.jar .

# Command to run the application
CMD ["java", "-jar", "forwardsecrecy.jar"]