AquaDX/Dockerfile

33 lines
1.0 KiB
Docker
Raw Normal View History

2023-12-21 14:27:18 +08:00
# Use a multi-stage build to keep the image size small
# Start with a Gradle image for building the project
2024-04-02 02:04:19 +08:00
FROM gradle:jdk21-alpine as builder
2023-12-21 14:27:18 +08:00
# 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
# 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
2024-04-02 02:04:19 +08:00
FROM eclipse-temurin:21-jre-alpine
2023-12-21 14:27:18 +08:00
# Set the deployment directory
WORKDIR /app
# Copy only the built JAR from the builder image
2024-04-02 02:04:19 +08:00
COPY --from=builder /home/gradle/build/libs/AquaDX-*.jar /app/
2023-12-21 14:27:18 +08:00
# The command to run the application
2024-04-02 02:04:19 +08:00
CMD java -jar AquaDX-*.jar