mediahub-fe/Dockerfile

34 lines
804 B
Docker
Raw Normal View History

2025-10-23 03:01:14 +00:00
# Gunakan base image Node.js Alpine yang ringan
2024-12-24 17:07:38 +00:00
FROM node:23.5.0-alpine
2024-12-10 05:48:21 +00:00
2025-10-23 03:01:14 +00:00
# Atur environment
ENV PORT=3000
ENV NODE_ENV=production
ENV NODE_OPTIONS="--max-old-space-size=4096"
2024-12-10 05:48:21 +00:00
2025-10-23 03:01:14 +00:00
# Install dependencies global
RUN npm install -g pnpm pm2
2025-10-23 03:01:14 +00:00
# Set working directory
2024-12-10 05:48:21 +00:00
WORKDIR /usr/src/app
2025-10-23 03:01:14 +00:00
# Salin file penting untuk caching dependencies
COPY package.json pnpm-lock.yaml* ./
2025-07-22 05:09:03 +00:00
2025-10-23 03:01:14 +00:00
# Salin vendor jika diperlukan (ckeditor misalnya)
2025-07-22 05:09:03 +00:00
COPY vendor/ckeditor5 ./vendor/ckeditor5
2025-01-04 17:34:23 +00:00
# Install dependencies
2025-10-23 03:01:14 +00:00
RUN pnpm install --frozen-lockfile
2025-01-04 17:34:23 +00:00
2025-10-23 03:01:14 +00:00
# Salin semua source code
2025-01-04 17:32:21 +00:00
COPY . .
2024-12-10 05:48:21 +00:00
2025-10-23 03:01:14 +00:00
# Build Next.js
RUN pnpm run build
2025-01-04 17:32:21 +00:00
2025-10-23 03:01:14 +00:00
# Expose port
2024-12-10 05:48:21 +00:00
EXPOSE 3000
2025-10-23 03:01:14 +00:00
# Jalankan Next.js dalam mode cluster (gunakan semua core)
2025-10-23 08:21:41 +00:00
CMD ["pm2-runtime", "start", "node_modules/next/dist/bin/next", "-i", "max", "--name", "next-app", "--", "start", "-p", "3000"]