Add Dockerfile
This commit is contained in:
32
Dockerfile
Normal file
32
Dockerfile
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
# 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"]
|
||||||
Reference in New Issue
Block a user