-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(CD): prod, stage 설정 동일하게 적용
- Loading branch information
Showing
3 changed files
with
228 additions
and
313 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,32 @@ | ||
# Use the official OpenJDK 21 image from the Docker Hub | ||
FROM openjdk:21-jdk | ||
# 1. Build Stage | ||
FROM gradle:8.11.1-jdk21 AS build | ||
WORKDIR /app | ||
|
||
# Expose port 8080 to the outside world | ||
EXPOSE 8080 | ||
# Copy Gradle files and install dependencies | ||
COPY build.gradle settings.gradle /app/ | ||
RUN gradle dependencies --stacktrace | ||
|
||
# Copy the JAR file into the container | ||
COPY build/libs/clab.jar /clab.jar | ||
# Copy source code and build | ||
COPY src /app/src | ||
RUN gradle bootJar --no-daemon --stacktrace | ||
|
||
# Set the default active profile to 'stage'. Modify the 'spring.profiles.active' property to match your environment. | ||
# For example, use '-Dspring.profiles.active=production' for production environment. | ||
ENTRYPOINT ["java", "-jar", "-Dspring.profiles.active=prod", "/clab.jar"] | ||
# Extract layers from JAR file | ||
RUN java -Djarmode=layertools -jar build/libs/*.jar extract \ | ||
&& ls -l /app \ | ||
&& ls -l /app/dependencies \ | ||
&& ls -l /app/spring-boot-loader \ | ||
&& ls -l /app/snapshot-dependencies \ | ||
&& ls -l /app/application | ||
|
||
# 2. Runtime Stage | ||
FROM eclipse-temurin:21-jre AS runtime | ||
WORKDIR /app | ||
|
||
# Copy each layer | ||
COPY --from=build /app/dependencies/ ./ | ||
COPY --from=build /app/spring-boot-loader/ ./ | ||
COPY --from=build /app/snapshot-dependencies/ ./ | ||
COPY --from=build /app/application/ ./ | ||
|
||
# Run the application | ||
ENTRYPOINT ["java", "-Dspring.profiles.active=stage", "org.springframework.boot.loader.launch.JarLauncher"] |
Oops, something went wrong.