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
This commit is contained in:
2025-12-02 13:31:19 +00:00
parent 855abb98b7
commit ff16860d8a
2 changed files with 17 additions and 11 deletions

View File

@@ -21,29 +21,35 @@ COPY . .
# Generate Prisma Client for the correct platform (Debian) # Generate Prisma Client for the correct platform (Debian)
RUN npx prisma generate --generator client RUN npx prisma generate --generator client
# Don't build for development mode # Build Next.js application
ENV NEXT_TELEMETRY_DISABLED 1 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 # Production image, copy all the files and run next
FROM base AS runner FROM base AS runner
RUN apt-get update && apt-get install -y openssl ca-certificates && rm -rf /var/lib/apt/lists/* RUN apt-get update && apt-get install -y openssl ca-certificates && rm -rf /var/lib/apt/lists/*
WORKDIR /app WORKDIR /app
ENV NEXT_TELEMETRY_DISABLED 1 ENV NODE_ENV=production
ENV NEXT_TELEMETRY_DISABLED=1
RUN addgroup --system --gid 1001 nodejs RUN addgroup --system --gid 1001 nodejs
RUN adduser --system --uid 1001 nextjs RUN adduser --system --uid 1001 nextjs
# Copy all files from builder # Copy necessary files
COPY --from=builder /app ./ 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 EXPOSE 3000
ENV PORT 3000 ENV PORT=3000
ENV HOSTNAME "0.0.0.0" ENV HOSTNAME="0.0.0.0"
CMD ["npm", "run", "dev"] CMD ["node", "server.js"]

View File

@@ -6,7 +6,7 @@ services:
ports: ports:
- "3500:3000" - "3500:3000"
environment: environment:
- NODE_ENV=development - NODE_ENV=production
- DATABASE_URL=${DATABASE_URL} - DATABASE_URL=${DATABASE_URL}
- AUTH_URL=http://localhost:3500 - AUTH_URL=http://localhost:3500
- NEXTAUTH_URL=http://localhost:3500 - NEXTAUTH_URL=http://localhost:3500