Skip to content

Commit

Permalink
refactor(CD): prod, stage 설정 동일하게 적용
Browse files Browse the repository at this point in the history
  • Loading branch information
limehee committed Nov 23, 2024
1 parent 1114dc0 commit ba4294c
Show file tree
Hide file tree
Showing 3 changed files with 228 additions and 313 deletions.
38 changes: 29 additions & 9 deletions jenkins/prod/Dockerfile
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"]
Loading

0 comments on commit ba4294c

Please sign in to comment.