Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docker 자동 배포 pipeline 시간 단축 #54

Merged
merged 10 commits into from
Jan 21, 2025
Merged

Conversation

ezcolin2
Copy link
Collaborator

@ezcolin2 ezcolin2 commented Jan 20, 2025

🔖 연관된 이슈

📂 작업 내용

  • octodocs-modules base 이미지를 자기 자신으로 설정하여 layer pull, layer push 시간 단축
  • 원격 저장소에 자기 자신이 없거나 layer 수가 너무 많으면 node 이미지를 base로 사용
  • 여러 이미지 build, push 병렬 처리 하여 시간 단축
  • multi stage build로 COPY 명령어 줄여서 layer 수 감소

octodocs-modules는 websocket, backend, frontend에서 사용하는 모든 패키지를 가지고 있고 각 workspace 이미지는 이 이미지를 base로 사용하기 때문에 패키지 중복이 발생하지 않습니다.

octodocs-modules 이미지를 빌드할 때 octodocs-modules 이미지를 base로 사용하면 패키지가 추가되었을 때 추가된 패키지만 별도의 layer로 생성하여 기존 이미지에 쌓기 때문에 기존 yarn install layer를 그대로 사용할 수 있습니다.

하지만 이미지 빌드가 거듭되면 layer 수가 너무 늘어나기 때문에 일정 수가 넘어가면 모든 패키지를 다시 설치하여 layer 수를 초기화하도록 구현했습니다.

그리고 websocket, backend, nginx 빌드의 경우 모두 octodocs-modules 이미지에 의존하지만 독립적이기 때문에 병렬 build를 적용했습니다.

그리고 multi stage build를 적용하여 COPY 명령어 개수를 4개에서 1개로 줄였습니다.

octodocs-modules 이미지 push 시간 71초 감소 (83s -> 12s)
octodocs-modules 이미지 pull 시간 54초 감소 (68s -> 14)
octodocs-modules 이미지 빌드할 때마다 늘어나던 layer 수 4개 감소 (6개 -> 2개)
websocket, backend, websocket 이미지 빌드 시간 9초 감소 (45s -> 36s)
websocket, backend, websocket 이미지 푸시 시간 6초 감소 (12s -> 6s)

base 이미지를 node로 지정했을 때
image (19)
5분 50초
https://github.com/boostcampwm-2024/refactor-web39-OctoDocs/actions/runs/12855189480

base 이미지를 자기 자신으로 지정했을 때
image (20)
3분 33초
https://github.com/boostcampwm-2024/refactor-web39-OctoDocs/actions/runs/12855161978

📑 참고 자료

@ezcolin2 ezcolin2 linked an issue Jan 20, 2025 that may be closed by this pull request
2 tasks
@ezcolin2 ezcolin2 marked this pull request as draft January 20, 2025 08:37
@ezcolin2 ezcolin2 marked this pull request as ready for review January 20, 2025 08:52
@ezcolin2 ezcolin2 changed the title Refactor be #47 docker 자동 배포 pipeline 시간 단축 Jan 20, 2025
Copy link
Collaborator

@summersummerwhy summersummerwhy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@github-actions github-actions bot merged commit 80be0eb into develop Jan 21, 2025
15 checks passed
@github-actions github-actions bot deleted the refactor-be-#47 branch January 21, 2025 04:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

docker 자동 배포 pipeline 시간 단축
2 participants