fix dockerfile issue
This commit is contained in:
52
Dockerfile
52
Dockerfile
@@ -1,18 +1,46 @@
|
|||||||
FROM nginx:alpine
|
FROM node:20-alpine AS base
|
||||||
|
|
||||||
# Move to Nginx's public folder
|
# Install dependencies only when needed
|
||||||
WORKDIR /usr/share/nginx/html
|
FROM base AS deps
|
||||||
|
RUN apk add --no-cache libc6-compat
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
# 1. CRUCIAL: Remove Nginx's default "Welcome" page files completely
|
# Install dependencies
|
||||||
RUN rm -rf ./*
|
COPY package.json package-lock.json* ./
|
||||||
|
RUN npm ci
|
||||||
|
|
||||||
# 2. Copy your compiled static assets into the root folder.
|
# Rebuild the source code only when needed
|
||||||
# NOTE: If your folder is named "dist" instead of "build", change "build/" to "dist/"
|
FROM base AS builder
|
||||||
COPY build/ .
|
WORKDIR /app
|
||||||
|
COPY --from=deps /app/node_modules ./node_modules
|
||||||
|
COPY . .
|
||||||
|
|
||||||
# 3. Copy your custom Nginx configuration (which you already have in your log)
|
# Next.js telemetry is disabled
|
||||||
COPY nginx.conf /etc/nginx/nginx.conf
|
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"]
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import type { NextConfig } from "next";
|
import type { NextConfig } from "next";
|
||||||
|
|
||||||
const nextConfig: NextConfig = {
|
const nextConfig: NextConfig = {
|
||||||
/* config options here */
|
output: "standalone",
|
||||||
};
|
};
|
||||||
|
|
||||||
export default nextConfig;
|
export default nextConfig;
|
||||||
|
|||||||
Reference in New Issue
Block a user