fix: fixing dockerfile
This commit is contained in:
parent
26b2f51787
commit
e5da6f4ecc
|
|
@ -36,3 +36,4 @@ yarn-error.log*
|
|||
# typescript
|
||||
*.tsbuildinfo
|
||||
next-env.d.ts
|
||||
.env.local
|
||||
|
|
|
|||
20
Dockerfile
20
Dockerfile
|
|
@ -4,6 +4,16 @@ FROM node:23.5.0-alpine
|
|||
# Mengatur port
|
||||
ENV PORT 3000
|
||||
|
||||
# Build arguments untuk environment variables (build-time)
|
||||
# Bisa di-override saat docker build dengan --build-arg
|
||||
ARG NEXT_PUBLIC_API_URL
|
||||
ARG NEXT_PUBLIC_SITE_URL
|
||||
|
||||
# Set sebagai environment variables untuk build
|
||||
# Next.js membaca NEXT_PUBLIC_* variables saat BUILD TIME
|
||||
ENV NEXT_PUBLIC_API_URL=${NEXT_PUBLIC_API_URL}
|
||||
ENV NEXT_PUBLIC_SITE_URL=${NEXT_PUBLIC_SITE_URL}
|
||||
|
||||
# Install pnpm secara global
|
||||
RUN npm install -g pnpm
|
||||
|
||||
|
|
@ -16,17 +26,19 @@ COPY package.json ./
|
|||
# Menyalin direktori ckeditor5 jika diperlukan
|
||||
COPY vendor/ckeditor5 ./vendor/ckeditor5
|
||||
|
||||
# Menyalin env
|
||||
COPY .env .env
|
||||
|
||||
# Install dependencies
|
||||
RUN pnpm install
|
||||
# RUN pnpm install --frozen-lockfile
|
||||
|
||||
# Menyalin source code aplikasi
|
||||
# Menyalin source code aplikasi (termasuk .env jika ada)
|
||||
# PENTING: Next.js akan membaca file .env otomatis jika ada
|
||||
# Tapi jika ARG di-set, ARG akan override nilai dari .env
|
||||
COPY . .
|
||||
|
||||
# Build aplikasi
|
||||
# Next.js membaca NEXT_PUBLIC_* dari:
|
||||
# 1. Environment variables (ENV) - prioritas tertinggi
|
||||
# 2. File .env - jika ENV tidak di-set
|
||||
RUN NODE_OPTIONS="--max-old-space-size=4096" pnpm next build
|
||||
|
||||
# Expose port untuk server
|
||||
|
|
|
|||
Loading…
Reference in New Issue