fix dockerfile issue

This commit is contained in:
2026-06-26 16:07:38 +05:30
parent b323cbb6be
commit c1eac6e2bc
2 changed files with 41 additions and 13 deletions

View File

@@ -1,18 +1,46 @@
FROM nginx:alpine
FROM node:20-alpine AS base
# Move to Nginx's public folder
WORKDIR /usr/share/nginx/html
# Install dependencies only when needed
FROM base AS deps
RUN apk add --no-cache libc6-compat
WORKDIR /app
# 1. CRUCIAL: Remove Nginx's default "Welcome" page files completely
RUN rm -rf ./*
# Install dependencies
COPY package.json package-lock.json* ./
RUN npm ci
# 2. Copy your compiled static assets into the root folder.
# NOTE: If your folder is named "dist" instead of "build", change "build/" to "dist/"
COPY build/ .
# Rebuild the source code only when needed
FROM base AS builder
WORKDIR /app
COPY --from=deps /app/node_modules ./node_modules
COPY . .
# 3. Copy your custom Nginx configuration (which you already have in your log)
COPY nginx.conf /etc/nginx/nginx.conf
# Next.js telemetry is disabled
ENV NEXT_TELEMETRY_DISABLED=1
EXPOSE 80
RUN npm run build
CMD ["nginx", "-g", "daemon off;"]
# Production image, copy all the files and run next
FROM base AS runner
WORKDIR /app
ENV NODE_ENV=production
ENV NEXT_TELEMETRY_DISABLED=1
RUN addgroup --system --gid 1001 nodejs
RUN adduser --system --uid 1001 nextjs
COPY --from=builder /app/public ./public
# Automatically leverage output traces to reduce image size
# https://nextjs.org/docs/advanced-features/output-file-tracing
COPY --from=builder --chown=nextjs:nodejs /app/.next/standalone ./
COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static
USER nextjs
EXPOSE 3000
ENV PORT=3000
ENV HOSTNAME="0.0.0.0"
CMD ["node", "server.js"]

View File

@@ -1,7 +1,7 @@
import type { NextConfig } from "next";
const nextConfig: NextConfig = {
/* config options here */
output: "standalone",
};
export default nextConfig;