Split single build-and-deploy job into 4 jobs: build-backend, build-worker, build-frontend run in parallel (all 3 independent), deploy job has needs:[...] on all three. Removes ~2 min of sequential build time on warm cache runs. Also: scope GHA cache keys per image (backend-lean / worker-chromium / frontend) so builds don't invalidate each other's layer cache. Replace sleep 8 health-check with a 30-iteration polling loop (fails fast on bad deploy, doesn't over-wait on fast ones). Add --mount=type=cache to frontend npm ci for node_modules cache across builds.
36 lines
901 B
Docker
36 lines
901 B
Docker
# syntax=docker/dockerfile:1.7
|
|
|
|
# ---- deps ----
|
|
FROM node:20-alpine AS deps
|
|
WORKDIR /app
|
|
COPY package.json package-lock.json ./
|
|
# --legacy-peer-deps: Tailwind 4 alpha + React 19 peer-dep mismatches.
|
|
RUN --mount=type=cache,target=/root/.npm \
|
|
npm ci --legacy-peer-deps --no-audit --no-fund
|
|
|
|
|
|
# ---- builder ----
|
|
FROM node:20-alpine AS builder
|
|
WORKDIR /app
|
|
ENV NEXT_TELEMETRY_DISABLED=1
|
|
COPY --from=deps /app/node_modules ./node_modules
|
|
COPY . .
|
|
RUN npm run build
|
|
|
|
|
|
# ---- runner ----
|
|
FROM node:20-alpine AS runner
|
|
WORKDIR /app
|
|
ENV NODE_ENV=production \
|
|
NEXT_TELEMETRY_DISABLED=1 \
|
|
PORT=3000
|
|
|
|
# `node` user (uid 1000) ships with the alpine image.
|
|
COPY --from=builder --chown=node:node /app/public ./public
|
|
COPY --from=builder --chown=node:node /app/.next/standalone ./
|
|
COPY --from=builder --chown=node:node /app/.next/static ./.next/static
|
|
|
|
USER node
|
|
|
|
EXPOSE 3000
|
|
CMD ["node", "server.js"]
|