mirror of
https://gitlab.com/mbugroup/lti-web-client.git
synced 2026-05-20 13:32:00 +00:00
edit .gitlab-ci
This commit is contained in:
+14
-18
@@ -1,56 +1,52 @@
|
||||
# ============================================================
|
||||
# 🏗️ Stage 1 — Builder
|
||||
# 🏗️ Stage 1 — Builder
|
||||
# ============================================================
|
||||
FROM node:20-alpine AS builder
|
||||
|
||||
# Install hanya yang diperlukan untuk build
|
||||
# Install dependensi dasar
|
||||
RUN apk add --no-cache git bash build-base curl
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
# Copy dependency list terlebih dahulu agar cache efektif
|
||||
# Copy dependencies terlebih dahulu agar cache efisien
|
||||
COPY package*.json ./
|
||||
|
||||
# Gunakan npm ci (lebih cepat, konsisten)
|
||||
RUN npm ci --omit=dev
|
||||
# Pastikan npm up to date agar mendukung flag terbaru
|
||||
RUN npm install -g npm@11 && npm --version
|
||||
|
||||
# Copy source code terakhir
|
||||
# Install dependency tanpa devDependencies (aman di semua npm versi)
|
||||
RUN npm ci --only=production
|
||||
|
||||
# Copy seluruh source
|
||||
COPY . .
|
||||
|
||||
# Buat config agar Next tahu mode static export
|
||||
# Buat konfigurasi output Next.js
|
||||
RUN echo "const config = { output: 'export', images: { unoptimized: true } }; export default config;" > next.config.mjs
|
||||
|
||||
# Build Next.js tanpa Turbopack, lalu hapus cache npm
|
||||
# Build project (disable Turbopack agar tidak makan RAM)
|
||||
ENV NEXT_DISABLE_TURBOPACK=1
|
||||
RUN npx next build && npm cache clean --force
|
||||
|
||||
# Tambahkan cache folder _next agar bisa dilayani oleh server
|
||||
# Siapkan folder static untuk serve
|
||||
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 (super ringan)
|
||||
# 🧱 Stage 2 — Runtime
|
||||
# ============================================================
|
||||
FROM node:20-alpine AS runtime
|
||||
|
||||
# Install hanya 1 dependency ringan untuk serving static file
|
||||
RUN npm install -g serve && apk add --no-cache tini
|
||||
RUN apk add --no-cache tini && npm install -g serve
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
# Copy hasil build dari stage sebelumnya
|
||||
COPY --from=builder /app/.next/server/app ./server
|
||||
COPY --from=builder /app/.next/server/app/_next ./server/_next
|
||||
COPY --from=builder /app/public ./public
|
||||
|
||||
# Set environment minimal
|
||||
ENV NODE_ENV=production
|
||||
ENV PORT=3000
|
||||
|
||||
EXPOSE 3000
|
||||
|
||||
# Jalankan lewat tini untuk handle signal & memory leak
|
||||
ENTRYPOINT ["/sbin/tini", "--"]
|
||||
|
||||
CMD ["serve", "-s", "server", "-l", "3000"]
|
||||
Reference in New Issue
Block a user