Files
pos-tumbuhin/Dockerfile

38 lines
1.1 KiB
Docker

# ---------- 1. Install dependencies (di-cache selama package.json tidak berubah) ----------
FROM node:22-alpine AS deps
WORKDIR /app
COPY package.json package-lock.json ./
RUN --mount=type=cache,target=/root/.npm \
npm ci --ignore-scripts && npm install --no-save --ignore-scripts sharp
# ---------- 2. Build (hanya bagian ini yang jalan saat artikel berubah) ----------
FROM node:22-alpine AS builder
WORKDIR /app
COPY --from=deps /app/node_modules ./node_modules
COPY . .
ENV NEXT_TELEMETRY_DISABLED=1
ARG SITE_URL
ENV SITE_URL=${SITE_URL}
RUN npx fumadocs-mdx
# nice -n 19 = prioritas CPU paling rendah, supaya POS tetap lancar saat build
RUN --mount=type=cache,target=/app/.next/cache \
nice -n 19 npm run build
# ---------- 3. Runtime (image kecil) ----------
FROM node:22-alpine AS runner
WORKDIR /app
ENV NODE_ENV=production
ENV NEXT_TELEMETRY_DISABLED=1
ENV PORT=3000
ENV HOSTNAME=0.0.0.0
COPY --from=builder /app/.next/standalone ./
COPY --from=builder /app/.next/static ./.next/static
COPY --from=builder /app/public ./public
EXPOSE 3000
CMD ["node", "server.js"]