perf(docker): Add BuildKit cache mounts for faster builds
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful

Added cache mounts for:
- pnpm store: Caches downloaded packages between builds
- TurboRepo: Caches build outputs between builds

This significantly speeds up subsequent builds:
- First build: Full download and compile
- Subsequent builds: Only changed packages are re-downloaded/rebuilt

Requires Docker BuildKit (default in Docker 23+).

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
2026-02-01 01:22:51 -06:00
parent 353f04f950
commit e045cb5a45
2 changed files with 18 additions and 6 deletions

View File

@@ -1,3 +1,6 @@
# syntax=docker/dockerfile:1
# Enable BuildKit features for cache mounts
# Base image for all stages
FROM node:20-alpine AS base
@@ -22,8 +25,9 @@ COPY packages/ui/package.json ./packages/ui/
COPY packages/config/package.json ./packages/config/
COPY apps/web/package.json ./apps/web/
# Install dependencies
RUN pnpm install --frozen-lockfile
# Install dependencies with pnpm store cache
RUN --mount=type=cache,id=pnpm-store,target=/root/.local/share/pnpm/store \
pnpm install --frozen-lockfile
# ======================
# Builder stage
@@ -45,7 +49,9 @@ ENV NEXT_PUBLIC_API_URL=${NEXT_PUBLIC_API_URL}
# Build the web app and its dependencies using TurboRepo
# This ensures @mosaic/shared and @mosaic/ui are built first
RUN pnpm turbo build --filter=@mosaic/web
# Cache TurboRepo build outputs for faster subsequent builds
RUN --mount=type=cache,id=turbo-cache,target=/app/.turbo \
pnpm turbo build --filter=@mosaic/web
# Ensure public directory exists (may be empty)
RUN mkdir -p ./apps/web/public