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
This commit is contained in:
2025-12-02 13:54:26 +00:00
parent 3a3db4195f
commit 60ebf13a9c
2 changed files with 5 additions and 55 deletions

View File

@@ -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"]