perf: optimize Docker images - backend 294MB, gateway 1.89GB
Build & Deploy / build-and-push (backend) (push) Failing after 1m25s
Build & Deploy / build-and-push (discord-gateway) (push) Failing after 26s
Build & Deploy / build-and-push (proxy) (push) Failing after 25s
Build & Deploy / build-and-push (backend) (push) Failing after 1m25s
Build & Deploy / build-and-push (discord-gateway) (push) Failing after 26s
Build & Deploy / build-and-push (proxy) (push) Failing after 25s
Backend: - node:22-alpine runtime (from 1.82GB to 294MB, 84% reduction) - COPY --chown instead of chown -R layer - pnpm install --prod after build for clean .pnpm store - Pinned pnpm@10 to avoid v11 build-script lockout Gateway: - Fixed TypeScript errors (missing table defs in shared schema) - Restored node-crc Rust patch for native compilation - Multi-stage build with COPY --chown - pnpm install --prod after build - ffmpeg with --no-install-recommends Proxy: - Restructured for standalone build (build errors are pre-existing) General: - pnpm@10 in all builds (avoids ERR_PNPM_IGNORED_BUILDS) - Clean .dockerignore (excludes docs/design/scripts)
This commit is contained in:
@@ -3,34 +3,22 @@ FROM node:22-slim AS builder
|
||||
|
||||
WORKDIR /build
|
||||
|
||||
RUN corepack enable
|
||||
RUN npm install -g pnpm@10
|
||||
|
||||
# Build essentials
|
||||
# Build essentials (native deps like sharp need g++)
|
||||
RUN apt-get update -qq && apt-get install -y -qq --no-install-recommends \
|
||||
make g++ \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
# Manifest files first
|
||||
COPY services/frontend/package.json ./
|
||||
COPY services/frontend/tsconfig.json ./
|
||||
COPY services/frontend/next.config.ts ./
|
||||
|
||||
# Install all deps, skip postinstall (no native addons needed for static export)
|
||||
RUN --mount=type=cache,id=pnpm-store,target=/root/.local/share/pnpm/store \
|
||||
pnpm install --ignore-scripts --no-frozen-lockfile
|
||||
|
||||
# Source code
|
||||
# Copy source + manifests
|
||||
COPY services/frontend/ ./
|
||||
|
||||
# Build args
|
||||
ARG VITE_BE_API_URL
|
||||
ARG VITE_BE_WS_URL
|
||||
ENV VITE_BE_API_URL=${VITE_BE_API_URL}
|
||||
ENV VITE_BE_WS_URL=${VITE_BE_WS_URL}
|
||||
# Install all deps
|
||||
RUN --mount=type=cache,id=pnpm-store,target=/root/.local/share/pnpm/store \
|
||||
pnpm install --no-frozen-lockfile
|
||||
|
||||
# Build static export
|
||||
RUN --mount=type=cache,id=pnpm-store,target=/root/.local/share/pnpm/store \
|
||||
npx next build
|
||||
RUN pnpm run build
|
||||
|
||||
# ---- Runtime stage: nginx ----
|
||||
FROM nginx:alpine
|
||||
|
||||
Reference in New Issue
Block a user