-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
31 lines (22 loc) · 1.07 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
# Use Amazon Corretto as the base image for Java
ARG JAVA_VERSION=21
FROM amazoncorretto:${JAVA_VERSION}-alpine AS build
# Copy the project files to the Docker image
COPY . /home/src
# Set the working directory
WORKDIR /home/src
# Ensure logback.xml is handled correctly
RUN mv src/main/resources/logback.xml src/main/resources/logback-local.xml || echo "logback.xml not found"
RUN mv src/main/resources/logback-docker.xml src/main/resources/logback.xml || echo "logback-docker.xml not found"
# Build the application
RUN --mount=type=cache,target=/root/.gradle ./gradlew --no-daemon clean build
# Runtime stage
FROM amazoncorretto:${JAVA_VERSION}-alpine
# Set the working directory for the runtime container
WORKDIR /home/app
# Copy the built application to the runtime image
COPY --from=build /home/src/build/libs/*.jar /home/app/application.jar
# Expose the application port
EXPOSE 8080
# Define the entry point for the application
ENTRYPOINT ["java", "-server", "-XX:+Use", "-XX:+UnlockExperimentalVMOptions", "-XX:+UseContainerSupport", "-XX:", "-jar", "/home/app/application.jar"]