fix: use npm ci --omit=dev in runner (resolves all transitive prisma deps)
This commit is contained in:
+20
-15
@@ -1,11 +1,11 @@
|
||||
# Étape 1 : dépendances
|
||||
# Étape 1 : dépendances complètes (dev incluses pour le build)
|
||||
FROM node:20-alpine AS deps
|
||||
WORKDIR /app
|
||||
RUN apk add --no-cache python3 make g++
|
||||
COPY package*.json ./
|
||||
RUN npm ci
|
||||
|
||||
# Étape 2 : build
|
||||
# Étape 2 : build Next.js
|
||||
FROM node:20-alpine AS builder
|
||||
WORKDIR /app
|
||||
RUN apk add --no-cache python3 make g++
|
||||
@@ -20,31 +20,36 @@ FROM node:20-alpine AS runner
|
||||
WORKDIR /app
|
||||
ENV NODE_ENV=production
|
||||
|
||||
# Outils natifs requis pour better-sqlite3
|
||||
RUN apk add --no-cache python3 make g++
|
||||
|
||||
RUN addgroup --system --gid 1001 nodejs \
|
||||
&& adduser --system --uid 1001 nextjs
|
||||
|
||||
# Installer uniquement les dépendances de production
|
||||
# (résout automatiquement toutes les dépendances transitives : effect, dotenv, etc.)
|
||||
COPY package*.json ./
|
||||
RUN npm ci --omit=dev
|
||||
|
||||
# Ajouter le CLI Prisma (devDependency → non installé par --omit=dev)
|
||||
COPY --from=builder /app/node_modules/prisma ./node_modules/prisma
|
||||
RUN ln -sf /app/node_modules/prisma/build/index.js /app/node_modules/.bin/prisma
|
||||
|
||||
# Client Prisma généré (spécifique à la plateforme linux/alpine)
|
||||
COPY --from=builder /app/node_modules/.prisma ./node_modules/.prisma
|
||||
|
||||
# Artifacts du build Next.js
|
||||
COPY --from=builder /app/public ./public
|
||||
COPY --from=builder /app/.next/standalone ./
|
||||
COPY --from=builder /app/.next/static ./.next/static
|
||||
|
||||
# Schema + migrations Prisma
|
||||
COPY --from=builder /app/prisma ./prisma
|
||||
COPY --from=builder /app/prisma.config.ts ./prisma.config.ts
|
||||
# Prisma 7 CLI : le package complet (contient les WASM)
|
||||
COPY --from=builder /app/node_modules/prisma ./node_modules/prisma
|
||||
# Recréer le symlink .bin/prisma → ../prisma/build/index.js
|
||||
# (COPY résoudrait le symlink en fichier physique, cassant __dirname/WASM resolution)
|
||||
RUN mkdir -p node_modules/.bin && \
|
||||
ln -sf /app/node_modules/prisma/build/index.js node_modules/.bin/prisma && \
|
||||
chmod +x node_modules/.bin/prisma
|
||||
COPY --from=builder /app/node_modules/.prisma ./node_modules/.prisma
|
||||
COPY --from=builder /app/node_modules/@prisma ./node_modules/@prisma
|
||||
COPY --from=builder /app/node_modules/better-sqlite3 ./node_modules/better-sqlite3
|
||||
COPY --from=builder /app/node_modules/@prisma/adapter-better-sqlite3 ./node_modules/@prisma/adapter-better-sqlite3
|
||||
COPY --from=builder /app/node_modules/dotenv ./node_modules/dotenv
|
||||
|
||||
COPY scripts/start.sh ./start.sh
|
||||
|
||||
RUN mkdir -p data && chown -R nextjs:nodejs data .
|
||||
RUN mkdir -p data && chown -R nextjs:nodejs data . && chmod +x start.sh
|
||||
|
||||
USER nextjs
|
||||
EXPOSE 3000
|
||||
|
||||
Reference in New Issue
Block a user