๐Ÿ‹๐ŸƒSpringBoot + DockerFile : Multi-Stage

๊น€์„ฑ์ธยท2023๋…„ 9์›” 22์ผ
0

[DevOps] ๐ŸณDocker & Kubernetes

๋ชฉ๋ก ๋ณด๊ธฐ
9/62

./gradlew ์‚ฌ์šฉํ•ด์„œ ์‹คํ–‰
https://sangchul.kr/entry/%EC%9B%90%EB%8F%84%EC%9A%B0-Spring-Boot-%ED%94%84%EB%A1%9C%EC%A0%9D%ED%8A%B8-Gradle%EB%A1%9C-Docker-%EC%9D%B4%EB%AF%B8%EC%A7%80-%EB%B9%8C%EB%93%9C%ED%95%98%EA%B8%B0

gradle ์‚ฌ์šฉํ•ด์„œ ์‹คํ–‰
https://tweety1121.tistory.com/entry/Dockerfile-%EB%82%B4%EC%97%90%EC%84%9C-gradle-%EB%B9%8C%EB%93%9C-%ED%9B%84-spring-boot-%EC%9D%B4%EB%AF%B8%EC%A7%80-%EC%83%9D%EC%84%B1-Multi-Stage

์ฐธ๊ณ  git
https://gist.github.com/msauza/6a906e879549e218c54868d81161afcb

๊ณต์‹๋ฌธ์„œ
https://docs.docker.com/build/building/multi-stage/#differences-between-legacy-builder-and-buildkit

FROM gradle:6.9.2-jdk11 AS BUILD

ENV APP_HOME=/app
WORKDIR $APP_HOME

COPY gradle $APP_HOME/gradle
COPY build.gradle settings.gradle gradlew $APP_HOME/
COPY src $APP_HOME/src

USER root
RUN chmod +x gradlew

RUN ./gradlew clean build

# Final Stage
FROM openjdk:11-jre-slim
ENV APP_HOME=/app
ENV JAR_FILE=/app/build/libs/*.jar

WORKDIR $APP_HOME

COPY --from=BUILD ${JAR_FILE} /app.jar

ENTRYPOINT ["java", "-jar", "-Dspring.profiles.active=${active}", "-Duser.timezone=Asia/Seoul", "/app.jar"]

์šฉ๋Ÿ‰ ์ด์Šˆ๋กœ ์ธํ•ด์„œ.... ๋„์ปคํŒŒ์ผ์ด๋ž‘ ํ”„๋กœ์ ํŠธ๋ฅผ ๋ชจ๋‘ ๋ฐฐํฌํ•˜๊ณ  ํ•˜๋˜์ง€ ํ•ด์•ผ๊ฒ ๋‹ค,, ๋จธ๋ฆฌ๊ฐ€ ๋„ˆ๋ฌด ์•„ํ”„๋„ค

profile
๊ฐœ๋ฐœ์ž๊ฐ€ ๊ฟˆ์ธ 25์‚ด ๋Œ€ํ•™์ƒ์ž…๋‹ˆ๋‹ค.

0๊ฐœ์˜ ๋Œ“๊ธ€