diff --git a/Dockerfile b/Dockerfile index 6a8606dc..d0e8256b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -15,7 +15,6 @@ RUN apk add --no-cache imagemagick libwebp libwebp-tools ghostscript # Copy only the necessary files for installing dependencies COPY package.json pnpm-lock.yaml ./ - # Install ALL dependencies (including devDependencies needed for `next build`) # This leverages the Docker cache effectively. RUN pnpm install --frozen-lockfile @@ -25,10 +24,10 @@ COPY . . # --- Asset Generation & Build --- RUN chmod +x ./scripts/*.sh && ./scripts/first_page_image.sh +# The build command creates the .next/standalone directory RUN pnpm build # Stage 3: Runner (Production) -# This is the final, lean image that runs the application. FROM base AS runner WORKDIR /app @@ -39,25 +38,21 @@ ENV NODE_ENV=production RUN addgroup --system --gid 1001 nodejs RUN adduser --system --uid 1001 nextjs -# Copy only the files needed for production from the builder stage -COPY --from=builder /app/package.json /app/pnpm-lock.yaml ./ +# Copy the standalone output from the builder +COPY --from=builder /app/.next/standalone ./ -# Install ONLY production dependencies. -# The pnpm CLI is already available from the 'base' stage. -RUN pnpm install --prod --frozen-lockfile - -# Copy the built Next.js application and public assets +# Copy the public and static assets COPY --from=builder /app/public ./public -COPY --from=builder /app/.next ./.next +COPY --from=builder /app/.next/static ./.next/static # Change ownership to the non-root user RUN chown -R nextjs:nodejs /app - # Switch to the non-root user USER nextjs EXPOSE 3000 ENV PORT=3000 -# The command to start the Next.js server -CMD ["pnpm", "start"] \ No newline at end of file +# --- FINAL CMD CHANGED --- +# Directly run the standalone server. +CMD ["node", "server.js"] \ No newline at end of file