Skip to content

Instantly share code, notes, and snippets.

@taufiqpsumarna
Created September 19, 2024 06:22
Show Gist options
  • Save taufiqpsumarna/125c7fd2ad58e2aee3decdd01991864a to your computer and use it in GitHub Desktop.
Save taufiqpsumarna/125c7fd2ad58e2aee3decdd01991864a to your computer and use it in GitHub Desktop.
Lightweight Docker Image Java Apps
# Stage 1: Build the application
FROM maven:3.9-eclipse-temurin-17-alpine AS build
WORKDIR /build
COPY . .
RUN mvn package
#Stage 2: Create the final lightweight image
FROM eclipse-temurin:17-jre-alpine
WORKDIR /app
COPY --from=build /build/target/hello-world.jar .
ENTRYPOINT ["java","-jar","hello-world.jar"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment