Last active
April 7, 2022 11:40
-
-
Save choi-ys/bd239e0519fe4fff84813093f93a662f to your computer and use it in GitHub Desktop.
Multi-Stage 방식의 docker image layer cache을 통한 SpringBoot Application의 image 경량화
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
# Dockerfile | |
FROM adoptopenjdk:11-jre-hotspot as builder | |
WORKDIR application | |
ARG JAR_FILE=build/libs/*.jar | |
COPY ${JAR_FILE} application.jar | |
RUN java -Djarmode=layertools -jar application.jar extract | |
FROM adoptopenjdk:11-jre-hotspot | |
WORKDIR application | |
COPY --from=builder application/dependencies/ ./ | |
COPY --from=builder application/spring-boot-loader/ ./ | |
COPY --from=builder application/snapshot-dependencies/ ./ | |
COPY --from=builder application/application/ ./ | |
ENTRYPOINT ["java", "org.springframework.boot.loader.JarLauncher"] | |
# Docker Image Build Command | |
- ECR Image Registry : docker build -f Dockerfile -t {IMAGE_REGISTRY_URI}:latest . | |
- Docker Hub Registry : docker build -f Dockerfile -t {DOCKER_HUB_ID}:latest . | |
# Docker Image Run Command | |
- docker run -d -p {external port}:{internal port} {IMAGE_REGISTRY_URI}:latest |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment