-
Notifications
You must be signed in to change notification settings - Fork 66
/
Dockerfile
36 lines (26 loc) · 1.16 KB
/
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
36
# Use a multi-stage build to keep the image size small
# Start with a Gradle image for building the project
#FROM gradle:jdk21-alpine as builder
FROM gradle:8.8.0-jdk21 as builder
# Copy the Gradle wrapper and configuration files separately to leverage Docker cache
COPY --chown=gradle:gradle gradlew /home/gradle/
COPY --chown=gradle:gradle gradle /home/gradle/gradle
COPY --chown=gradle:gradle build.gradle.kts settings.gradle.kts /home/gradle/
# Set working directory
WORKDIR /home/gradle
# Replace CRLF with LF in gradlew to make it work on Linux
RUN sed -i 's/\r$//' ./gradlew
# Download dependencies - cached if build.gradle.kts and settings.gradle.kts are unchanged
RUN ./gradlew dependencies
# Copy the project source, this layer is rebuilt whenever a file has changed
COPY --chown=gradle:gradle src /home/gradle/src
# Build the application
RUN ./gradlew build -x test
# Start with a fresh image for the runtime
FROM eclipse-temurin:21-jre-alpine
# Set the deployment directory
WORKDIR /app
# Copy only the built JAR from the builder image
COPY --from=builder /home/gradle/build/libs/AquaDX-*.jar /app/
# The command to run the application
CMD java -jar AquaDX-*.jar