refactor: restructure Dockerfile.gatekeeper into base, builder, and runner stages for improved multi-stage build.
This commit is contained in:
@@ -1,14 +1,11 @@
|
||||
FROM node:20-alpine AS builder
|
||||
|
||||
FROM node:20-alpine AS base
|
||||
RUN apk add --no-cache libc6-compat curl
|
||||
WORKDIR /app
|
||||
|
||||
# Enable pnpm
|
||||
RUN corepack enable pnpm
|
||||
|
||||
# Step 2: Install dependencies
|
||||
# We copy everything first because we have a .dockerignore
|
||||
# and we need the workspace structure for pnpm to work correctly
|
||||
# Step 2: Builder stage
|
||||
FROM base AS builder
|
||||
# Copy source (honoring .dockerignore)
|
||||
COPY . .
|
||||
|
||||
# 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) && \
|
||||
pnpm i --frozen-lockfile
|
||||
|
||||
# Copy source
|
||||
COPY . .
|
||||
|
||||
# Build Gatekeeper
|
||||
RUN pnpm --filter @mintel/gatekeeper build
|
||||
|
||||
# Runner
|
||||
# Step 3: Runner stage
|
||||
FROM base AS runner
|
||||
WORKDIR /app
|
||||
ENV NODE_ENV=production
|
||||
|
||||
Reference in New Issue
Block a user