From d3cc38aed52a938a818e42079844351f0b9e3ce1 Mon Sep 17 00:00:00 2001 From: GitLab Deploy Bot Date: Sun, 9 Nov 2025 15:15:26 +0700 Subject: [PATCH] edit Dockerfile --- Dockerfile | 45 +++++++++------------------------------------ 1 file changed, 9 insertions(+), 36 deletions(-) diff --git a/Dockerfile b/Dockerfile index f625ce73..f9a51e76 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,52 +1,25 @@ -# ============================================================ -# 🏗️ Stage 1 — Builder -# ============================================================ -FROM node:20-alpine AS builder +FROM node:20-alpine -# Install dependensi dasar RUN apk add --no-cache git bash build-base curl WORKDIR /app -# Copy dependencies terlebih dahulu agar cache efisien COPY package*.json ./ +RUN npm ci -# Pastikan npm up to date agar mendukung flag terbaru -RUN npm install -g npm@11 && npm --version - -# Install dependency tanpa devDependencies (aman di semua npm versi) -RUN npm ci --only=production - -# Copy seluruh source COPY . . -# Buat konfigurasi output Next.js +# Buat config agar Next tahu output: export RUN echo "const config = { output: 'export', images: { unoptimized: true } }; export default config;" > next.config.mjs -# Build project (disable Turbopack agar tidak makan RAM) -ENV NEXT_DISABLE_TURBOPACK=1 -RUN npx next build && npm cache clean --force +# Build project (Next.js 15 otomatis static export) +RUN NEXT_DISABLE_TURBOPACK=1 npx next build -# Siapkan folder static untuk serve +# Pastikan folder static tersedia untuk URL _next/static RUN mkdir -p .next/server/app/_next && \ cp -r .next/static .next/server/app/_next/static && \ - cp -r public/assets .next/server/app/ || true - -# ============================================================ -# 🧱 Stage 2 — Runtime -# ============================================================ -FROM node:20-alpine AS runtime - -RUN apk add --no-cache tini && npm install -g serve - -WORKDIR /app - -COPY --from=builder /app/.next/server/app ./server -COPY --from=builder /app/public ./public - -ENV NODE_ENV=production -ENV PORT=3000 + RUN cp -r public/* .next/server/app/ EXPOSE 3000 -ENTRYPOINT ["/sbin/tini", "--"] -CMD ["serve", "-s", "server", "-l", "3000"] \ No newline at end of file + +CMD ["npx", "serve", ".next/server/app", "-l", "3000"] \ No newline at end of file