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

Build #BBB-142: CI/CD에 캐싱 적용 #59

Merged
merged 1 commit into from
Sep 23, 2024

Conversation

msjang4
Copy link
Contributor

@msjang4 msjang4 commented Sep 23, 2024

작업 개요

CI

 - uses: actions/setup-java@v4
    with:
      cache: gradle

이 캐싱은 gradle setup에 대한 것으로 기존의 gradle/actions/setup-gradle액션과 같은 기능을 합니다.


  - name: Cache jar
    uses: actions/cache/save@v4
    with:
      path: ~/app/external-api/build/libs
      key: ${{ runner.os }}-cached-jar-${{ hashFiles('app/external-api/build/libs/*.jar') }}

build로 나온 jar파일을 추후 CD에서 사용하기 위해 캐싱하는 액션입니다.

CD

  - name: Restore jar
    uses: actions/cache/restore@v4
    with:
      path: ~/app/external-api/build/libs
      restore-keys: ${{ runner.os }}-cached-jar-

CI에서 캐싱된 jar파일을 restore하는 액션입니다.

- name: Build and Push Image to Amazon ECR
  uses: docker/build-push-action@v3
  with:
    push: true
    tags: ${{ env.ECR_REGISTRY }}/${{ steps.login-ecr.outputs.registry }}:${{ github.sha }}
    platforms: linux/arm64
    cache-from: type=gha, mode=max
    cache-to: type=gha

docker build시에도 image layers 캐싱을 적용합니다.

.P.S github actions의 캐시사이즈는 10GB라고합니다.

image

.P.S github actions의 캐시는 7일 동안 접근되지 않으면 자동 삭제된다고 합니다.

image

전달 사항

참고 자료

[how to reuse gradle cache in GitHub workflow]

[Github Action에서 Docker Image Layers 캐싱하기]

[How to use Docker layer caching in GitHub Actions]

@msjang4 msjang4 self-assigned this Sep 23, 2024
@msjang4 msjang4 force-pushed the build/cd_with_cache#BBB-142 branch 5 times, most recently from c4f4aad to 137f69a Compare September 23, 2024 07:03
@msjang4 msjang4 changed the title Build #BBB-142: CI/CD에 Gradle 캐싱 적용 Build #BBB-142: CI/CD에 캐싱 적용 Sep 23, 2024
@msjang4 msjang4 force-pushed the build/cd_with_cache#BBB-142 branch 2 times, most recently from 7a61b2d to 2f75b6a Compare September 23, 2024 07:32
@msjang4 msjang4 force-pushed the build/cd_with_cache#BBB-142 branch from 2f75b6a to f268e7e Compare September 23, 2024 07:53
@msjang4 msjang4 merged commit 525a731 into develop Sep 23, 2024
1 check passed
@msjang4 msjang4 added the ⚙️Build 빌드 및 패키지 매니저 수정 label Sep 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
⚙️Build 빌드 및 패키지 매니저 수정
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant