Fix: add CMD node server.js for Next.js standalone build
This commit is contained in:
13
Dockerfile
13
Dockerfile
@@ -9,7 +9,7 @@ FROM base AS deps
|
||||
RUN apk add --no-cache libc6-compat python3 make g++
|
||||
WORKDIR /app
|
||||
|
||||
# Copy package files only - skip postinstall scripts (prisma generate runs in builder stage)
|
||||
# Copy package files - skip postinstall (prisma generate runs in builder stage)
|
||||
COPY package*.json ./
|
||||
RUN npm ci --legacy-peer-deps --ignore-scripts
|
||||
|
||||
@@ -19,17 +19,16 @@ WORKDIR /app
|
||||
COPY --from=deps /app/node_modules ./node_modules
|
||||
COPY . .
|
||||
|
||||
# Set environment variables for build
|
||||
ENV NEXT_TELEMETRY_DISABLED=1
|
||||
ENV NODE_ENV=production
|
||||
|
||||
# Generate Prisma Client (schema is now available from COPY . .)
|
||||
# Generate Prisma Client (schema is available from COPY . .)
|
||||
RUN npx prisma generate
|
||||
|
||||
# Build the application (DATABASE_URL will be available via Coolify env vars)
|
||||
# Build the application
|
||||
RUN npm run build
|
||||
|
||||
# Production image, copy all the files and run next
|
||||
# Production image
|
||||
FROM base AS runner
|
||||
WORKDIR /app
|
||||
|
||||
@@ -39,12 +38,10 @@ ENV NEXT_TELEMETRY_DISABLED=1
|
||||
RUN addgroup --system --gid 1001 nodejs
|
||||
RUN adduser --system --uid 1001 nextjs
|
||||
|
||||
# Copy built application
|
||||
COPY --from=builder /app/public ./public
|
||||
COPY --from=builder --chown=nextjs:nodejs /app/.next/standalone ./
|
||||
COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static
|
||||
|
||||
# Copy Prisma files for runtime
|
||||
COPY --from=builder /app/node_modules/.prisma ./node_modules/.prisma
|
||||
COPY --from=builder /app/node_modules/@prisma ./node_modules/@prisma
|
||||
COPY --from=builder /app/prisma ./prisma
|
||||
@@ -56,3 +53,5 @@ EXPOSE 3000
|
||||
ENV PORT=3000
|
||||
ENV HOSTNAME="0.0.0.0"
|
||||
|
||||
CMD ["node", "server.js"]
|
||||
|
||||
|
||||
Reference in New Issue
Block a user