From 60ebf13a9cda7584ebfb4189aaac8e14d4352ef9 Mon Sep 17 00:00:00 2001 From: Paul Bailey Date: Tue, 2 Dec 2025 13:54:26 +0000 Subject: [PATCH] Simplify Docker setup to fix constructor error - Remove standalone output mode from Next.js config - Use single-stage Docker build with npm start - Eliminate complex multi-stage build that was causing issues --- Dockerfile | 53 +++++--------------------------------------------- next.config.js | 7 ------- 2 files changed, 5 insertions(+), 55 deletions(-) diff --git a/Dockerfile b/Dockerfile index 7953530..f532abc 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,63 +1,20 @@ -# Use Node.js LTS version -FROM node:20-slim AS base +FROM node:20-slim -# Install dependencies only when needed -FROM base AS deps RUN apt-get update && apt-get install -y openssl ca-certificates && rm -rf /var/lib/apt/lists/* + WORKDIR /app -# Copy package files -COPY package.json package-lock.json* ./ -# Clean install dependencies -RUN npm ci --only=production --ignore-scripts && npm cache clean --force - -# Rebuild the source code only when needed -FROM base AS builder -RUN apt-get update && apt-get install -y openssl ca-certificates && rm -rf /var/lib/apt/lists/* -WORKDIR /app - -# Copy package files and install all dependencies (including dev) -COPY package.json package-lock.json* ./ +COPY package*.json ./ RUN npm ci -# Copy source code COPY . . - -# Generate Prisma Client for the correct platform RUN npx prisma generate - -# Build Next.js application -ENV NEXT_TELEMETRY_DISABLED=1 -ENV AUTH_TRUST_HOST=true -ENV NODE_ENV=production 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 NODE_ENV=production ENV NEXT_TELEMETRY_DISABLED=1 - -RUN addgroup --system --gid 1001 nodejs -RUN adduser --system --uid 1001 nextjs - -# Copy the 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/public ./public - -# Copy Prisma files -COPY --from=builder --chown=nextjs:nodejs /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 - -USER nextjs +ENV AUTH_TRUST_HOST=true EXPOSE 3000 -ENV PORT=3000 -ENV HOSTNAME="0.0.0.0" - -CMD ["node", "server.js"] +CMD ["npm", "start"] diff --git a/next.config.js b/next.config.js index eeffa6a..bf9040d 100644 --- a/next.config.js +++ b/next.config.js @@ -1,6 +1,5 @@ /** @type {import('next').NextConfig} */ const nextConfig = { - output: 'standalone', experimental: { optimizePackageImports: ['lucide-react'], }, @@ -9,18 +8,12 @@ const nextConfig = { exclude: ['error', 'warn'], } : false, }, - // Enable SWC minification for better performance swcMinify: true, - // Optimize images images: { formats: ['image/avif', 'image/webp'], - unoptimized: process.env.NODE_ENV === 'production', }, - // Enable compression compress: true, - // Production source maps (smaller) productionBrowserSourceMaps: false, - // Ensure proper handling in Docker trailingSlash: false, poweredByHeader: false, }