From ff16860d8a1f0bec37b4346caa77afba36720ffe Mon Sep 17 00:00:00 2001 From: Paul Bailey Date: Tue, 2 Dec 2025 13:31:19 +0000 Subject: [PATCH] Revert to production build with proper cookie settings - Production build is more stable than dev mode - Cookie settings already fixed for HTTP - NextAuth v5 beta works better in production mode --- Dockerfile | 26 ++++++++++++++++---------- docker-compose.yml | 2 +- 2 files changed, 17 insertions(+), 11 deletions(-) diff --git a/Dockerfile b/Dockerfile index 423a964..27a4ed3 100644 --- a/Dockerfile +++ b/Dockerfile @@ -21,29 +21,35 @@ COPY . . # Generate Prisma Client for the correct platform (Debian) RUN npx prisma generate --generator client -# Don't build for development mode +# Build Next.js application ENV NEXT_TELEMETRY_DISABLED 1 -ENV AUTH_TRUST_HOST true +ENV AUTH_TRUST_HOST=true +RUN npm run build # Production image, copy all the files and run next FROM base AS runner RUN apt-get update && apt-get install -y openssl ca-certificates && rm -rf /var/lib/apt/lists/* WORKDIR /app -ENV NEXT_TELEMETRY_DISABLED 1 +ENV NODE_ENV=production +ENV NEXT_TELEMETRY_DISABLED=1 RUN addgroup --system --gid 1001 nodejs RUN adduser --system --uid 1001 nextjs -# Copy all files from builder -COPY --from=builder /app ./ +# Copy necessary files +COPY --from=builder --chown=nextjs:nodejs /app/public ./public +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/node_modules/.prisma ./node_modules/.prisma +COPY --from=builder --chown=nextjs:nodejs /app/node_modules/@prisma ./node_modules/@prisma +COPY --from=builder --chown=nextjs:nodejs /app/prisma ./prisma -# Don't switch to nextjs user for dev mode - needs write permissions -# USER nextjs +USER nextjs EXPOSE 3000 -ENV PORT 3000 -ENV HOSTNAME "0.0.0.0" +ENV PORT=3000 +ENV HOSTNAME="0.0.0.0" -CMD ["npm", "run", "dev"] +CMD ["node", "server.js"] diff --git a/docker-compose.yml b/docker-compose.yml index 40cca7f..2ebf3fb 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -6,7 +6,7 @@ services: ports: - "3500:3000" environment: - - NODE_ENV=development + - NODE_ENV=production - DATABASE_URL=${DATABASE_URL} - AUTH_URL=http://localhost:3500 - NEXTAUTH_URL=http://localhost:3500