changes
This commit is contained in:
22
Dockerfile
22
Dockerfile
@@ -1,31 +1,33 @@
|
||||
# --- STAGE 1: Build (Môi trường build) ---
|
||||
FROM node:20-alpine AS builder
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
# Copy các file cấu hình dependency
|
||||
# Tăng memory limit ngay từ đầu
|
||||
ENV NODE_OPTIONS="--max-old-space-size=8192"
|
||||
|
||||
# Copy package files trước
|
||||
COPY package*.json ./
|
||||
|
||||
# Cài đặt mọi thư viện (bao gồm cả devDependencies để build)
|
||||
# Cài dependencies
|
||||
RUN npm ci --legacy-peer-deps
|
||||
|
||||
# Copy toàn bộ source code và build dự án
|
||||
# Copy source code
|
||||
COPY . .
|
||||
|
||||
# Build với memory limit rõ ràng
|
||||
RUN npm run build
|
||||
|
||||
# --- STAGE 2---
|
||||
# --- STAGE 2: Production ---
|
||||
FROM node:20-alpine AS runner
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
# Thiết lập môi trường Production
|
||||
ENV NODE_ENV=production
|
||||
ENV NODE_OPTIONS="--max-old-space-size=2048"
|
||||
|
||||
# 1. Cài đặt PM2 toàn cục và dọn dẹp cache của npm ngay lập tức
|
||||
# Cài PM2
|
||||
RUN npm install pm2 -g && npm cache clean --force
|
||||
|
||||
# 2. Chỉ copy những file cần thiết nhất từ stage builder
|
||||
# Nuxt 3/Nitro đã đóng gói mọi node_modules cần thiết vào .output
|
||||
# Copy những file cần thiết từ builder
|
||||
COPY --from=builder /app/.output ./.output
|
||||
COPY --from=builder /app/ecosystem.config.cjs ./
|
||||
COPY --from=builder /app/package*.json ./
|
||||
|
||||
Reference in New Issue
Block a user