Skip to content

Commit

Permalink
hotfix: reduce size docker image file.
Browse files Browse the repository at this point in the history
  • Loading branch information
LeonardoMeireles55 committed Jan 26, 2025
1 parent 5bd6b98 commit 20b3b14
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 57 deletions.
27 changes: 4 additions & 23 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,17 +1,4 @@
# Stage 1: Build custom Java runtime using jlink
FROM eclipse-temurin:21 as jre-build

# Create a custom Java runtime
RUN $JAVA_HOME/bin/jlink \
--add-modules java.base \
--strip-debug \
--no-man-pages \
--no-header-files \
--compress=2 \
--output /javaruntime

# Stage 2: Build the application
FROM eclipse-temurin:21-jdk-alpine AS build
FROM eclipse-temurin:21-jre-alpine AS build

RUN apk add --no-cache maven

Expand All @@ -23,19 +10,13 @@ RUN mvn clean package -DskipTests -U \
&& rm -rf /root/.m2 \
&& rm -rf /app/src

# Stage 3: Create the final image with the custom Java runtime and application
FROM debian:buster-slim
ENV JAVA_HOME=/opt/java/openjdk
ENV PATH="${JAVA_HOME}/bin:${PATH}"
COPY --from=jre-build /javaruntime $JAVA_HOME
# Run stage
FROM eclipse-temurin:21-jre-alpine

# Copy the application JAR from the build stage
WORKDIR /usr/src/app
COPY --from=build /app/target/QualityLabPro-0.7.jar ./app.jar

# Set environment variables
ENV SPRING_PROFILES_ACTIVE=prod \
SERVER_PORT=8080

# Expose the application port
EXPOSE ${SERVER_PORT}
EXPOSE ${SERVER_PORT}
12 changes: 0 additions & 12 deletions Dockerfile_OLD

This file was deleted.

22 changes: 0 additions & 22 deletions Dockerfile_OLD_2

This file was deleted.

0 comments on commit 20b3b14

Please sign in to comment.