Skip to content

Commit

Permalink
image on diet :-)
Browse files Browse the repository at this point in the history
  • Loading branch information
pdelebarre committed Aug 23, 2024
1 parent 745e5a0 commit c9e21c2
Showing 1 changed file with 22 additions and 5 deletions.
27 changes: 22 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,8 +1,25 @@
FROM maven:3.8.5-openjdk-17
# FROM maven:3.8.2-jdk-8 # for Java 8
# Stage 1: Build the application
FROM maven:3.8.5-openjdk-17 AS build

WORKDIR /app
COPY . .
RUN mvn clean install

CMD mvn spring-boot:run
# Copy pom.xml and download dependencies only
COPY pom.xml ./
COPY src ./src

# Download dependencies and build the application
RUN mvn clean package -DskipTests

# Stage 2: Create a minimal runtime image
FROM openjdk:17-jdk-slim

WORKDIR /app

# Copy only the built jar from the build stage
COPY --from=build /app/target/*.jar app.jar

# Expose the port your Spring Boot app runs on
EXPOSE 8080

# Run the Spring Boot application
CMD ["java", "-jar", "app.jar"]

0 comments on commit c9e21c2

Please sign in to comment.