Commit 7e367373 authored by Lê Bảo Hồng Đức's avatar Lê Bảo Hồng Đức

[tag]0.1-vcci

parent b3589a95
Pipeline #52398 failed with stages
in 43 seconds
FROM node:22-alpine
FROM node:22-alpine AS base
WORKDIR /app
COPY package*.json ./
RUN npm install
# Cài pnpm qua corepack — cách chính thức của Node.js
RUN corepack enable && corepack prepare pnpm@latest --activate
# Copy manifest + lockfile trước để tận dụng Docker layer cache
COPY package.json pnpm-lock.yaml* ./
# Cài dependencies production + dev (cần dev vì next build, eslint, orval tại build stage)
RUN pnpm install --frozen-lockfile
......@@ -6,11 +6,14 @@ ARG NEXT_PUBLIC_FRONTEND_HOST=https://news.vccihcm.vn
ENV NEXT_PUBLIC_BACKEND_HOST=$NEXT_PUBLIC_BACKEND_HOST
ENV NEXT_PUBLIC_FRONTEND_HOST=$NEXT_PUBLIC_FRONTEND_HOST
# Copy toàn bộ source (đã được .dockerignore lọc trừ node_modules / .next / openapi)
COPY . .
# Generate API client + build
RUN node scripts/generate-api.mjs
RUN npm run build
RUN pnpm run build
# ----------------- Production stage -----------------
FROM node:22-alpine AS production
WORKDIR /app
......@@ -20,15 +23,19 @@ ARG NEXT_PUBLIC_FRONTEND_HOST=https://news.vccihcm.vn
ENV NEXT_PUBLIC_BACKEND_HOST=$NEXT_PUBLIC_BACKEND_HOST
ENV NEXT_PUBLIC_FRONTEND_HOST=$NEXT_PUBLIC_FRONTEND_HOST
COPY --from=builder /app/package*.json ./
RUN corepack enable && corepack prepare pnpm@latest --activate
# Copy lockfile + manifest + node_modules từ builder
COPY --from=builder /app/package.json ./
COPY --from=builder /app/pnpm-lock.yaml* ./
COPY --from=builder /app/node_modules ./node_modules
RUN npm prune --production
# Prune dev deps để giảm image size
RUN pnpm prune --prod
COPY --from=builder /app/.next ./.next
COPY --from=builder /app/public ./public
EXPOSE 3000
CMD ["npm", "run", "start"]
CMD ["pnpm", "run", "start"]
# =====================================================================
# VCCI-News .dockerignore
# Tránh copy các file không cần thiết vào Docker image.
# Bắt buộc có để build Docker nhất quán giữa các môi trường.
# =====================================================================
# Node / Next.js
node_modules
.pnp
.pnp.js
.yarn/install-state.gz
# Build output
.next/
out/
build/
dist/
# Misc
.DS_Store
*.pem
npm-debug.log*
yarn-debug.log*
yarn-error.log*
.vercel
.turbo
.idea
.vscode
# Env / secrets
.env*.local
.env.production.local
# Test
coverage
.nyc_output
# Swagger spec chỉ dùng cho local dev — base image nên dùng BE thật
openapi/
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment