Fix runner stage: copy full node_modules for Prisma CLI
Cherry-picking modules missed @prisma/engines and other required binaries. Copy the entire node_modules to runner to ensure prisma migrate deploy works correctly. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
+4
-14
@@ -13,7 +13,7 @@ COPY . .
|
|||||||
RUN npx prisma generate
|
RUN npx prisma generate
|
||||||
RUN npm run build
|
RUN npm run build
|
||||||
|
|
||||||
# Stage 3: Production runner (standalone)
|
# Stage 3: Production runner
|
||||||
FROM node:20-alpine AS runner
|
FROM node:20-alpine AS runner
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
ENV NODE_ENV=production
|
ENV NODE_ENV=production
|
||||||
@@ -21,26 +21,16 @@ ENV NODE_ENV=production
|
|||||||
RUN addgroup --system --gid 1001 nodejs \
|
RUN addgroup --system --gid 1001 nodejs \
|
||||||
&& adduser --system --uid 1001 nextjs
|
&& adduser --system --uid 1001 nextjs
|
||||||
|
|
||||||
# Standalone output
|
# Full app: standalone output + all deps for Prisma CLI migrations
|
||||||
COPY --from=builder /app/.next/standalone ./
|
COPY --from=builder /app/.next/standalone ./
|
||||||
COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static
|
COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static
|
||||||
COPY --from=builder /app/public ./public
|
COPY --from=builder /app/public ./public
|
||||||
|
|
||||||
# Prisma: migrations + generated client
|
|
||||||
COPY --from=builder /app/prisma ./prisma
|
COPY --from=builder /app/prisma ./prisma
|
||||||
COPY --from=builder /app/src/generated ./src/generated
|
COPY --from=builder /app/src/generated ./src/generated
|
||||||
COPY --from=builder /app/prisma.config.ts ./prisma.config.ts
|
COPY --from=builder /app/prisma.config.ts ./prisma.config.ts
|
||||||
COPY --from=builder /app/tsconfig.json ./tsconfig.json
|
COPY --from=builder /app/tsconfig.json ./tsconfig.json
|
||||||
|
# Full node_modules needed for prisma CLI + all engine binaries
|
||||||
# Prisma CLI + adapters + pg driver for migrate deploy and runtime
|
COPY --from=builder /app/node_modules ./node_modules
|
||||||
COPY --from=builder /app/node_modules/.bin/prisma /usr/local/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/dotenv ./node_modules/dotenv
|
|
||||||
COPY --from=builder /app/node_modules/pg ./node_modules/pg
|
|
||||||
COPY --from=builder /app/node_modules/pg-pool ./node_modules/pg-pool
|
|
||||||
COPY --from=builder /app/node_modules/pg-protocol ./node_modules/pg-protocol
|
|
||||||
COPY --from=builder /app/node_modules/pg-types ./node_modules/pg-types
|
|
||||||
|
|
||||||
COPY entrypoint.sh ./entrypoint.sh
|
COPY entrypoint.sh ./entrypoint.sh
|
||||||
RUN chmod +x entrypoint.sh
|
RUN chmod +x entrypoint.sh
|
||||||
|
|||||||
+1
-1
@@ -2,7 +2,7 @@
|
|||||||
set -e
|
set -e
|
||||||
|
|
||||||
echo "Running database migrations..."
|
echo "Running database migrations..."
|
||||||
npx prisma migrate deploy
|
node /app/node_modules/.bin/prisma migrate deploy
|
||||||
|
|
||||||
echo "Starting Next.js..."
|
echo "Starting Next.js..."
|
||||||
exec node server.js
|
exec node server.js
|
||||||
|
|||||||
Reference in New Issue
Block a user