diff --git a/apps/api/Dockerfile b/apps/api/Dockerfile index 00c84ce..43535d2 100644 --- a/apps/api/Dockerfile +++ b/apps/api/Dockerfile @@ -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/api/package.json ./apps/api/ -# 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 @@ -41,7 +45,9 @@ COPY apps/api ./apps/api # Build the API app and its dependencies using TurboRepo # This ensures @mosaic/shared is built first, then prisma:generate, then the API -RUN pnpm turbo build --filter=@mosaic/api +# Cache TurboRepo build outputs for faster subsequent builds +RUN --mount=type=cache,id=turbo-cache,target=/app/.turbo \ + pnpm turbo build --filter=@mosaic/api # ====================== # Production stage diff --git a/apps/web/Dockerfile b/apps/web/Dockerfile index 8134b73..8da6c1f 100644 --- a/apps/web/Dockerfile +++ b/apps/web/Dockerfile @@ -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