32 lines
659 B
Docker
32 lines
659 B
Docker
# First stage: Build the application
|
|
FROM gradle:8.8 AS build
|
|
|
|
# Set the working directory
|
|
WORKDIR /app
|
|
|
|
# Copy the Gradle wrapper and build files
|
|
COPY gradlew .
|
|
COPY gradle gradle
|
|
COPY build.gradle.kts .
|
|
COPY settings.gradle.kts .
|
|
|
|
# Copy the source code
|
|
COPY src src
|
|
|
|
# Build the application
|
|
RUN ./gradlew build
|
|
|
|
# Second stage: Create the runtime image
|
|
FROM openjdk:21-jdk-slim
|
|
|
|
# Set the working directory
|
|
WORKDIR /app
|
|
|
|
# Copy the build artifacts from the first stage
|
|
COPY --from=build /app/build/libs/*.jar app.jar
|
|
|
|
# Expose the port the application runs on
|
|
EXPOSE 8080
|
|
|
|
# Specify the command to run the application
|
|
ENTRYPOINT ["java", "-jar", "app.jar"] |