From fab371228a567606fde80d593d253f9086664212 Mon Sep 17 00:00:00 2001 From: sepehr Date: Mon, 12 Jan 2026 00:27:04 +0100 Subject: [PATCH] fix: simplify Dockerfile with correct OpenSSL 3 setup for Debian 12 --- keep-notes/Dockerfile | 32 +++++++++----------------------- 1 file changed, 9 insertions(+), 23 deletions(-) diff --git a/keep-notes/Dockerfile b/keep-notes/Dockerfile index 3f1b371..8350d3c 100644 --- a/keep-notes/Dockerfile +++ b/keep-notes/Dockerfile @@ -1,42 +1,32 @@ -# Multi-stage build for Next.js 16 with Webpack (not Turbopack) -# Using Debian Slim for better Prisma compatibility +# Multi-stage build for Next.js 16 with Webpack + Prisma +# Using Debian Slim for OpenSSL 3.x compatibility FROM node:22-slim AS base -# Install dependencies only when needed + FROM base AS deps WORKDIR /app -# Install system dependencies for Prisma and sharp +# Install OpenSSL (already 3.x in Debian Slim) RUN apt-get update && apt-get install -y --no-install-recommends \ openssl \ && rm -rf /var/lib/apt/lists/* -# Install dependencies based on the preferred package manager +# Install dependencies COPY package.json package-lock.json* ./ RUN npm install --legacy-peer-deps -# Rebuild the source code only when needed FROM base AS builder WORKDIR /app COPY --from=deps /app/node_modules ./node_modules COPY . . -# Generate Prisma Client before build +# Generate Prisma Client (will use debian-openssl-3.0.x from schema) RUN npx prisma generate -# Build Next.js with Webpack (not Turbopack) to avoid Tailwind CSS issues +# Build Next.js with Webpack ENV NEXT_TELEMETRY_DISABLED=1 RUN npm run build -# Ensure Prisma binaries are in all search locations -RUN mkdir -p /app/prisma/client-generated && \ - cp -r node_modules/.prisma/client/* /app/prisma/client-generated/ && \ - mkdir -p /app/.prisma/client && \ - cp -r node_modules/.prisma/client/* /app/.prisma/client/ && \ - mkdir -p /app/.next/server && \ - cp -r node_modules/@prisma/engines/*.node /app/.next/server/ 2>/dev/null || true - -# Production image, copy all the files and run next FROM base AS runner WORKDIR /app @@ -48,18 +38,15 @@ RUN adduser --system --uid 1001 nextjs COPY --from=builder /app/public ./public -# Set the correct permission for prerender cache RUN mkdir .next RUN chown nextjs:nodejs .next -# Automatically leverage output traces to reduce image size +# Copy Next.js standalone output COPY --from=builder --chown=nextjs:nodejs /app/.next/standalone ./ COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static -COPY --from=builder --chown=nextjs:nodejs /app/.next/server ./.next/server -# Copy Prisma for runtime - ALL locations including the generated client AND engines +# Copy Prisma files - including generated binaries COPY --from=builder /app/prisma ./prisma -COPY --from=builder /app/.prisma ./.prisma COPY --from=builder --chown=nextjs:nodejs /app/node_modules/.prisma ./node_modules/.prisma COPY --from=builder --chown=nextjs:nodejs /app/node_modules/@prisma ./node_modules/@prisma @@ -70,5 +57,4 @@ EXPOSE 3000 ENV PORT=3000 ENV HOSTNAME="0.0.0.0" -# server.js is created by next build from the standalone output CMD ["node", "server.js"]