refactor(web): use BuildKit cache mounts for node_modules and Next.js cache

This commit is contained in:
Collin Barrett 2025-06-15 14:26:05 -05:00
parent c787e67a0e
commit 53a5c6c44d
2 changed files with 8 additions and 3 deletions

View file

@ -34,6 +34,9 @@ jobs:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to the Container registry
if: github.event_name == 'push'
uses: docker/login-action@v3
@ -50,6 +53,8 @@ jobs:
tags: |
${{ env.CONTAINER_REGISTRY }}/${{ env.CONTAINER_REPOSITORY }}:${{ env.CONTAINER_IMAGE_TAG_UNIQUE }}
${{ env.CONTAINER_REGISTRY }}/${{ env.CONTAINER_REPOSITORY }}:latest
cache-from: type=gha
cache-to: type=gha,mode=max
deploy:
name: Deploy

View file

@ -1,6 +1,6 @@
# https://github.com/vercel/next.js/blob/canary/examples/with-docker/Dockerfile
# syntax=docker/dockerfile:1
# syntax=docker.io/docker/dockerfile:1
# https://github.com/vercel/next.js/blob/canary/examples/with-docker/Dockerfile
FROM node:24-alpine AS base
@ -12,7 +12,7 @@ WORKDIR /app
# Install dependencies based on the preferred package manager
COPY package.json yarn.lock* package-lock.json* pnpm-lock.yaml* .npmrc* ./
RUN \
RUN --mount=type=cache,target=/app/.next/cache \
if [ -f yarn.lock ]; then yarn --frozen-lockfile; \
elif [ -f package-lock.json ]; then npm ci; \
elif [ -f pnpm-lock.yaml ]; then corepack enable pnpm && pnpm i --frozen-lockfile; \