mirror of
https://gitlab.com/mbugroup/lti-web-client.git
synced 2026-05-25 07:45:47 +00:00
Merge branch 'chore/build-cicd' into 'development'
edit Dockerfile See merge request mbugroup/lti-web-client!45
This commit is contained in:
+9
-36
@@ -1,52 +1,25 @@
|
|||||||
# ============================================================
|
FROM node:20-alpine
|
||||||
# 🏗️ Stage 1 — Builder
|
|
||||||
# ============================================================
|
|
||||||
FROM node:20-alpine AS builder
|
|
||||||
|
|
||||||
# Install dependensi dasar
|
|
||||||
RUN apk add --no-cache git bash build-base curl
|
RUN apk add --no-cache git bash build-base curl
|
||||||
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
# Copy dependencies terlebih dahulu agar cache efisien
|
|
||||||
COPY package*.json ./
|
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 . .
|
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
|
RUN echo "const config = { output: 'export', images: { unoptimized: true } }; export default config;" > next.config.mjs
|
||||||
|
|
||||||
# Build project (disable Turbopack agar tidak makan RAM)
|
# Build project (Next.js 15 otomatis static export)
|
||||||
ENV NEXT_DISABLE_TURBOPACK=1
|
RUN NEXT_DISABLE_TURBOPACK=1 npx next build
|
||||||
RUN npx next build && npm cache clean --force
|
|
||||||
|
|
||||||
# Siapkan folder static untuk serve
|
# Pastikan folder static tersedia untuk URL _next/static
|
||||||
RUN mkdir -p .next/server/app/_next && \
|
RUN mkdir -p .next/server/app/_next && \
|
||||||
cp -r .next/static .next/server/app/_next/static && \
|
cp -r .next/static .next/server/app/_next/static && \
|
||||||
cp -r public/assets .next/server/app/ || true
|
RUN cp -r public/* .next/server/app/
|
||||||
|
|
||||||
# ============================================================
|
|
||||||
# 🧱 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
|
|
||||||
|
|
||||||
EXPOSE 3000
|
EXPOSE 3000
|
||||||
ENTRYPOINT ["/sbin/tini", "--"]
|
|
||||||
CMD ["serve", "-s", "server", "-l", "3000"]
|
CMD ["npx", "serve", ".next/server/app", "-l", "3000"]
|
||||||
Reference in New Issue
Block a user