feat: update Dockerfile
This commit is contained in:
parent
0757ec6519
commit
0d1f8041a9
36
Dockerfile
36
Dockerfile
|
|
@ -1,34 +1,34 @@
|
|||
# Menggunakan image Node.js yang lebih ringan
|
||||
# Gunakan base image Node.js Alpine yang ringan
|
||||
FROM node:23.5.0-alpine
|
||||
|
||||
# Mengatur port
|
||||
ENV PORT 3000
|
||||
# Atur environment
|
||||
ENV PORT=3000
|
||||
ENV NODE_ENV=production
|
||||
ENV NODE_OPTIONS="--max-old-space-size=4096"
|
||||
|
||||
# Install pnpm secara global
|
||||
RUN npm install -g pnpm
|
||||
# Install dependencies global
|
||||
RUN npm install -g pnpm pm2
|
||||
|
||||
# Membuat direktori aplikasi dan mengatur sebagai working directory
|
||||
# Set working directory
|
||||
WORKDIR /usr/src/app
|
||||
|
||||
# Salin file penting untuk caching dependencies
|
||||
COPY package.json pnpm-lock.yaml* ./
|
||||
|
||||
# Menyalin file penting terlebih dahulu untuk caching
|
||||
COPY package.json ./
|
||||
|
||||
# Menyalin direktori ckeditor5 jika diperlukan
|
||||
# Salin vendor jika diperlukan (ckeditor misalnya)
|
||||
COPY vendor/ckeditor5 ./vendor/ckeditor5
|
||||
|
||||
# Install dependencies
|
||||
RUN pnpm install
|
||||
# RUN pnpm install --frozen-lockfile
|
||||
RUN pnpm install --frozen-lockfile
|
||||
|
||||
# Menyalin source code aplikasi
|
||||
# Salin semua source code
|
||||
COPY . .
|
||||
|
||||
# Build aplikasi
|
||||
RUN NODE_OPTIONS="--max-old-space-size=4096" pnpm run build
|
||||
# Build Next.js
|
||||
RUN pnpm run build
|
||||
|
||||
# Expose port untuk server
|
||||
# Expose port
|
||||
EXPOSE 3000
|
||||
|
||||
# Perintah untuk menjalankan aplikasi
|
||||
CMD ["pnpm", "run", "start"]
|
||||
# Jalankan Next.js dalam mode cluster (gunakan semua core)
|
||||
CMD ["pm2-runtime", "pnpm", "--", "run", "start", "-i", "max"]
|
||||
Loading…
Reference in New Issue