-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
35 lines (25 loc) · 912 Bytes
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# Use a base image with JDK 17 and Gradle installed
FROM gradle:jdk17-jammy AS builder
# Set the working directory in the container
WORKDIR /app
# Copy only the Gradle-related files to optimize caching
COPY build.gradle .
COPY settings.gradle .
COPY gradlew .
COPY gradle ./gradle
# Download and cache the Gradle dependencies
#RUN ./gradlew --no-daemon --console=plain dependencies
# Copy the application source code
COPY . .
# Build the application
RUN gradle clean bootJar
# Use AdoptOpenJDK's JRE 17 slim image for the final runtime
FROM gradle:jdk17-jammy AS runtime
# Set the working directory in the container
WORKDIR /app
# Copy the built JAR from the builder stage to the final image
COPY --from=builder /app/build/libs/demo-0.0.1-SNAPSHOT.jar ./app.jar
# Expose the port that the Spring Boot app runs on
EXPOSE 8080
# Command to run the Spring Boot application
CMD ["java", "-jar", "app.jar"]