lorca-gestionale-be/Dockerfile

32 lines
682 B
Docker

# Step 1: Build the application using Eclipse Temurin JDK 21
FROM maven:3.9.8-eclipse-temurin-21 AS build
WORKDIR /app
# Copy Gradle wrapper and dependencies for caching
COPY gradle gradle
COPY gradlew .
COPY build.gradle.kts .
COPY settings.gradle.kts .
COPY src src
# Give execution permission to Gradle wrapper
RUN chmod +x ./gradlew
# Build the JAR file
RUN ./gradlew bootJar
# Step 2: Create a minimal runtime image (JDK is required for Spring Boot)
FROM openjdk:21
WORKDIR /app
# Copy the built JAR from the builder stage
COPY --from=build /app/build/libs/*.jar app.jar
# Expose port 8080
EXPOSE 8080
# Run the application
ENTRYPOINT ["java", "-jar", "/app/app.jar"]