Skip to content

Commit

Permalink
Merge pull request #11 from musabbozkurt/dockerfile-changes
Browse files Browse the repository at this point in the history
Update Dockerfile to decrease the size of image
  • Loading branch information
musabbozkurt authored Aug 29, 2024
2 parents 59eb06e + 0d081cf commit 377611c
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,27 @@ COPY .. ${PROJECT_DIR}
# Download dependencies (this layer will be cached if pom.xml doesn't change)
RUN --mount=type=cache,target=/root/.m2 mvn -f $PROJECT_DIR/pom.xml clean package -DskipTests

# Create a custom Java runtime
RUN $JAVA_HOME/bin/jlink \
--add-modules jdk.unsupported,java.base,java.sql,java.naming,java.desktop,java.management,java.security.jgss,java.instrument \
--strip-debug \
--no-man-pages \
--no-header-files \
--compress=2 \
--output /mbjavaruntime

### Package stage ###

# Use an official OpenJDK image as the base image
FROM openjdk:21-jdk-slim
FROM debian:stretch-slim

ENV PROJECT_NAME=inventory-management-service
ENV PROJECT_JAR_FILE_NAME=${PROJECT_NAME}-0.0.1-SNAPSHOT
ENV PROJECT_DIR=/home/projects/${PROJECT_NAME}
ENV JAVA_HOME /home/java/jdk21
ENV PATH $JAVA_HOME/bin:$PATH

COPY --from=maven-builder /mbjavaruntime $JAVA_HOME

# Define the location of the New Relic agent JAR
ARG NEW_RELIC_AGENT_JAR_PATH
Expand Down

0 comments on commit 377611c

Please sign in to comment.