Skip to content

Commit

Permalink
fix: actions에 pnpm install을 캐싱하도록 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
Fixtar committed Jan 5, 2025
1 parent 4cf5ce2 commit bc3dc05
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 7 deletions.
12 changes: 11 additions & 1 deletion .github/workflows/back-media-cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,14 @@ jobs:
node-version: ${{ matrix.node-version }}
cache: 'pnpm'

- name: 🔄 캐시 복원
uses: actions/cache@v3
with:
path: ~/.pnpm-store
key: ${{ runner.os }}-pnpm-${{ hashFiles('pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-
- name: ⬇️ 의존성 설치
run: pnpm install --frozen-lockfile

Expand Down Expand Up @@ -65,8 +73,10 @@ jobs:
- name: 🐳 Docker 빌드 및 푸시
run: |
echo "Starting Docker build..."
DOCKER_BUILDKIT=1 docker buildx build --progress=plain --no-cache -f apps/media/Dockerfile . -t my-media-app
DOCKER_BUILDKIT=1 docker buildx build --progress=plain --build-arg PNPM_CACHE_DIR=/root/.pnpm-store -f apps/media/Dockerfile . -t my-media-app
echo "Docker build completed."
- name: 🐳 Docker 실행
run: |
echo "Starting Docker container..."
Expand Down
16 changes: 10 additions & 6 deletions apps/media/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,11 @@ RUN pnpm install -g turbo@^2.2.3

# 의존성 파일만 우선 복사하여 캐시 활용
COPY package.json pnpm-lock.yaml ./
RUN --mount=type=cache,id=pnpm-store,target=/pnpm/store pnpm install --frozen-lockfile

# PNPM 캐시 디렉토리 전달
ARG PNPM_CACHE_DIR=/pnpm/store
RUN pnpm install --frozen-lockfile --store=${PNPM_CACHE_DIR}


# 소스 파일 전체 복사
COPY . .
Expand All @@ -38,15 +42,15 @@ WORKDIR /app
COPY --from=builder /app/out/json/ .
COPY --from=builder /app/out/pnpm-lock.yaml ./pnpm-lock.yaml

# 캐시 활용하여 의존성 설치
RUN --mount=type=cache,id=pnpm-store,target=/pnpm/store pnpm install --frozen-lockfile

# PNPM 캐시 디렉토리 전달
ARG PNPM_CACHE_DIR=/pnpm/store
RUN pnpm install --frozen-lockfile --store=${PNPM_CACHE_DIR}

# 전체 소스 복사 및 빌드
COPY --from=builder /app/out/full/ .

# 이곳에서 캐시를 활용하여 C++ 모듈의 컴파일 결과를 캐싱합니다.
RUN --mount=type=cache,id=build-cache,target=/root/.cache \
pnpm build:media
RUN pnpm build:media

# 환경 파일 복사
COPY --from=builder /app/apps/media/.env /app/apps/media/dist/.env
Expand Down

0 comments on commit bc3dc05

Please sign in to comment.