Skip to content
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ target/
*.iml
*.log
.DS_Store
README.md
README.md
31 changes: 22 additions & 9 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,27 +1,40 @@
# ---------- Build stage ----------
FROM eclipse-temurin:21-jdk AS build

WORKDIR /app

COPY . .
# Copy Maven wrapper and build configuration first for better layer caching
COPY mvnw pom.xml ./
COPY .mvn .mvn

RUN chmod +x mvnw
RUN ./mvnw -DskipTests package

# Download dependencies before copying application source
RUN ./mvnw -B dependency:go-offline

FROM eclipse-temurin:21-jre
COPY src ./src

RUN ./mvnw -B -DskipTests package


# ---------- Runtime stage ----------
FROM eclipse-temurin:21-jre AS runtime

WORKDIR /app

# curl is required by the existing Docker Compose healthcheck
RUN apt-get update \
&& apt-get install -y --no-install-recommends curl \
&& rm -rf /var/lib/apt/lists/*

RUN useradd --system --create-home appuser
&& rm -rf /var/lib/apt/lists/* \
&& groupadd --system --gid 10001 appuser \
&& useradd --system --uid 10001 --gid appuser \
--no-create-home appuser

COPY --from=build /app/target/*.jar app.jar
# Copy only the packaged application
COPY --from=build --chown=10001:10001 /app/target/*.jar /app/app.jar

USER appuser
USER 10001:10001

EXPOSE 8081

ENTRYPOINT ["java", "-jar", "app.jar"]
ENTRYPOINT ["java", "-jar", "/app/app.jar"]
Loading