32 lines
697 B
Docker
32 lines
697 B
Docker
# Use a base image with Java 17
|
|
FROM openjdk:17-jdk-slim AS build
|
|
|
|
# Set the working directory in the container
|
|
WORKDIR /app
|
|
|
|
# Copy Gradle wrapper and configuration files
|
|
COPY gradlew .
|
|
COPY gradle/ gradle/
|
|
COPY build.gradle .
|
|
COPY settings.gradle .
|
|
|
|
# Copy the source code
|
|
COPY src/ src/
|
|
|
|
# Make Gradle wrapper executable and build the application
|
|
RUN ./gradlew build
|
|
|
|
# Use a smaller runtime image for the final build
|
|
FROM openjdk:17-jdk-slim
|
|
|
|
# Set the working directory in the container
|
|
WORKDIR /app
|
|
|
|
# Copy the built application from the build stage
|
|
COPY --from=build /app/build/libs/*.jar app.jar
|
|
|
|
# Expose port 8080
|
|
EXPOSE 8080
|
|
|
|
# Run the application
|
|
ENTRYPOINT ["java", "-jar", "app.jar"] |