8thang3 / Dockerfile
wynai's picture
Update Dockerfile
d0b92da verified
# ==========================================
# Bước 1: Build Image (Clone code và cài đặt)
# ==========================================
FROM node:20-alpine AS builder
# Cài đặt git để lấy mã nguồn từ GitHub
RUN apk add --no-cache git libc6-compat
WORKDIR /app
# Clone trực tiếp mã nguồn từ repo của bạn
RUN git clone https://github.com/wynriu/8thang3.git .
# Cài đặt các thư viện (dependencies)
RUN npm install
# Vô hiệu hóa Next.js telemetry để tăng tốc quá trình build
ENV NEXT_TELEMETRY_DISABLED=1
# Build dự án Next.js
RUN npm run build
# ==========================================
# Bước 2: Production Image (Môi trường chạy)
# ==========================================
FROM node:20-alpine AS runner
WORKDIR /app
# Thiết lập môi trường Production
ENV NODE_ENV=production
ENV NEXT_TELEMETRY_DISABLED=1
# Cấu hình Port bắt buộc cho Hugging Face Spaces (Port 7860)
ENV PORT=7860
ENV HOSTNAME="0.0.0.0"
EXPOSE 7860
# ĐÃ BỎ DÒNG COPY PUBLIC VÌ DỰ ÁN KHÔNG CÓ THƯ MỤC NÀY
# Copy các thư mục và file cấu hình cần thiết từ giai đoạn builder
COPY --from=builder /app/.next ./.next
COPY --from=builder /app/node_modules ./node_modules
COPY --from=builder /app/package.json ./package.json
# Lệnh khởi chạy server Next.js ở chế độ production
CMD ["npm", "start"]