refactor: restructure Dockerfile.gatekeeper into base, builder, and runner stages for improved multi-stage build.

This commit is contained in:
2026-02-04 12:10:51 +01:00
parent a94ddcfbb2
commit 0ccb15a929

View File

@@ -1,14 +1,11 @@
FROM node:20-alpine AS builder FROM node:20-alpine AS base
RUN apk add --no-cache libc6-compat curl RUN apk add --no-cache libc6-compat curl
WORKDIR /app WORKDIR /app
# Enable pnpm
RUN corepack enable pnpm RUN corepack enable pnpm
# Step 2: Install dependencies # Step 2: Builder stage
# We copy everything first because we have a .dockerignore FROM base AS builder
# and we need the workspace structure for pnpm to work correctly # Copy source (honoring .dockerignore)
COPY . . COPY . .
# Use a secret for NPM_TOKEN to authenticate with private registry # Use a secret for NPM_TOKEN to authenticate with private registry
@@ -17,13 +14,10 @@ RUN --mount=type=cache,target=/root/.local/share/pnpm/store/v3 \
export NPM_TOKEN=$(cat /run/secrets/NPM_TOKEN) && \ export NPM_TOKEN=$(cat /run/secrets/NPM_TOKEN) && \
pnpm i --frozen-lockfile pnpm i --frozen-lockfile
# Copy source
COPY . .
# Build Gatekeeper # Build Gatekeeper
RUN pnpm --filter @mintel/gatekeeper build RUN pnpm --filter @mintel/gatekeeper build
# Runner # Step 3: Runner stage
FROM base AS runner FROM base AS runner
WORKDIR /app WORKDIR /app
ENV NODE_ENV=production ENV NODE_ENV=production