Merge branch 'chore/build-cicd' into 'development'

edit Dockerfile

See merge request mbugroup/lti-web-client!45
This commit is contained in:
kris
2025-11-09 08:16:08 +00:00
+9 -36
View File
@@ -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"]
CMD ["npx", "serve", ".next/server/app", "-l", "3000"]