experimental smaller docker image
Build Images and Deploy / Update-PROD-Stack (push) Failing after 41s
Build Images and Deploy / Update-PROD-Stack (push) Failing after 41s
This commit is contained in:
+28
-11
@@ -1,23 +1,40 @@
|
|||||||
FROM node:20-alpine
|
FROM node:20-alpine AS base
|
||||||
|
|
||||||
WORKDIR /app
|
|
||||||
|
|
||||||
# Required for Prisma on Alpine
|
|
||||||
RUN apk add --no-cache openssl
|
RUN apk add --no-cache openssl
|
||||||
|
|
||||||
# Install all deps (including devDeps for tsx worker runtime + build tooling)
|
# ── deps: install production deps only ───────────────────────────────────────
|
||||||
|
FROM base AS deps
|
||||||
|
WORKDIR /app
|
||||||
|
COPY package*.json ./
|
||||||
|
COPY prisma ./prisma
|
||||||
|
RUN npm ci --omit=dev && npm run postinstall
|
||||||
|
|
||||||
|
# ── build: full install + compile ─────────────────────────────────────────────
|
||||||
|
FROM base AS builder
|
||||||
|
WORKDIR /app
|
||||||
COPY package*.json ./
|
COPY package*.json ./
|
||||||
COPY prisma ./prisma
|
COPY prisma ./prisma
|
||||||
RUN npm ci
|
RUN npm ci
|
||||||
|
|
||||||
# Copy source
|
|
||||||
COPY . .
|
COPY . .
|
||||||
|
|
||||||
# Generate Prisma client and build Next.js (postinstall handles prisma generate)
|
|
||||||
RUN npm run build
|
RUN npm run build
|
||||||
|
|
||||||
|
# ── runner: lean production image ─────────────────────────────────────────────
|
||||||
|
FROM base AS runner
|
||||||
|
WORKDIR /app
|
||||||
ENV NODE_ENV=production
|
ENV NODE_ENV=production
|
||||||
|
|
||||||
|
# Prisma client + schema (needed at runtime for db push and queries)
|
||||||
|
COPY --from=deps /app/node_modules ./node_modules
|
||||||
|
COPY --from=builder /app/.next ./.next
|
||||||
|
COPY --from=builder /app/public ./public
|
||||||
|
COPY --from=builder /app/package.json ./package.json
|
||||||
|
COPY --from=builder /app/next.config.mjs ./next.config.mjs
|
||||||
|
COPY --from=builder /app/prisma ./prisma
|
||||||
|
# Worker source (compiled to node_modules/.cache or run via tsx in prod)
|
||||||
|
COPY --from=builder /app/src/worker ./src/worker
|
||||||
|
COPY --from=builder /app/src/lib ./src/lib
|
||||||
|
COPY --from=builder /app/tsconfig.json ./tsconfig.json
|
||||||
|
|
||||||
EXPOSE 3000
|
EXPOSE 3000
|
||||||
|
|
||||||
# Default: run web server. Worker container overrides this CMD.
|
# Default: web server. Worker container overrides CMD.
|
||||||
CMD ["npm", "start"]
|
CMD ["npm", "start"]
|
||||||
|
|||||||
Reference in New Issue
Block a user