refactor: Refactor dockerfile
This commit is contained in:
parent
3113eee414
commit
9778a1e6d5
1 changed files with 0 additions and 12 deletions
|
@ -1,32 +1,20 @@
|
|||
# First stage: Build the application
|
||||
FROM gradle:jdk22 AS builder
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
# Copy only Gradle wrapper and configuration files first (for caching efficiency)
|
||||
COPY gradlew build.gradle.kts settings.gradle.kts ./
|
||||
COPY gradle gradle
|
||||
|
||||
# Give execute permissions to Gradle wrapper
|
||||
RUN chmod +x gradlew
|
||||
|
||||
# Download dependencies first (improves caching)
|
||||
RUN ./gradlew dependencies
|
||||
|
||||
# Copy the rest of the project files
|
||||
COPY src src
|
||||
|
||||
# Build the application (skipping tests for faster build)
|
||||
RUN ./gradlew clean build -x test
|
||||
|
||||
# Second stage: Run the application
|
||||
FROM openjdk:22-jdk-slim
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
# Copy the built JAR from the first stage
|
||||
COPY --from=builder /app/build/libs/*.jar app.jar
|
||||
|
||||
EXPOSE 8080
|
||||
|
||||
ENTRYPOINT ["java", "-jar", "app.jar"]
|
||||
|
|
Reference in a new issue