Commit 2f634bff authored by Phạm Quang Bảo's avatar Phạm Quang Bảo

Merge branch 'refactor/generate_api_and_fix_fallback_img' of...

Merge branch 'refactor/generate_api_and_fix_fallback_img' of https://gitlab.meu-solutions.com/vanhoangit/vcci-news into refactor/generate_api_and_fix_fallback_img
parents 5e306082 e8cd033e
#!/bin/bash #!/bin/bash
set -e
cd .ci cd .ci
sudo docker build -t $image_name:$tag -f $docker_path/build.Dockerfile ../ sudo docker build -t $image_name:$tag -f $docker_path/build.Dockerfile ../
sudo docker logout registry.gitlab.com sudo docker logout registry.gitlab.com
......
FROM node:22-alpine FROM node:22-alpine AS base
WORKDIR /app 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,10 +6,16 @@ ARG NEXT_PUBLIC_FRONTEND_HOST=https://vcci-hcm.org.vn ...@@ -6,10 +6,16 @@ ARG NEXT_PUBLIC_FRONTEND_HOST=https://vcci-hcm.org.vn
ENV NEXT_PUBLIC_BACKEND_HOST=$NEXT_PUBLIC_BACKEND_HOST ENV NEXT_PUBLIC_BACKEND_HOST=$NEXT_PUBLIC_BACKEND_HOST
ENV NEXT_PUBLIC_FRONTEND_HOST=$NEXT_PUBLIC_FRONTEND_HOST ENV NEXT_PUBLIC_FRONTEND_HOST=$NEXT_PUBLIC_FRONTEND_HOST
# Base image cũ có thể chưa có pnpm — bật corepack ở đâng để chắc chắn.
# (Sau khi base image được rebuild với base.Dockerfile mới, dòng này sẽ là no-op.)
RUN corepack enable && corepack prepare pnpm@latest --activate
# Copy toàn bộ source (đã được .dockerignore lọc trừ node_modules / .next / openapi)
COPY . . COPY . .
RUN npm run build RUN npm run build
# ----------------- Production stage -----------------
FROM node:22-alpine AS production FROM node:22-alpine AS production
WORKDIR /app WORKDIR /app
...@@ -19,15 +25,18 @@ ARG NEXT_PUBLIC_FRONTEND_HOST=https://vcci-hcm.org.vn ...@@ -19,15 +25,18 @@ ARG NEXT_PUBLIC_FRONTEND_HOST=https://vcci-hcm.org.vn
ENV NEXT_PUBLIC_BACKEND_HOST=$NEXT_PUBLIC_BACKEND_HOST ENV NEXT_PUBLIC_BACKEND_HOST=$NEXT_PUBLIC_BACKEND_HOST
ENV NEXT_PUBLIC_FRONTEND_HOST=$NEXT_PUBLIC_FRONTEND_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 --from=builder /app/node_modules ./node_modules
RUN npm prune --production # Chỉ copy manifest + lockfile (KHÔNG copy node_modules).
# Cài fresh production-only deps để tránh `pnpm prune --prod` bị
# ERR_PNPM_IGNORED_BUILDS trên pnpm v11+.
COPY --from=builder /app/package.json ./
COPY --from=builder /app/pnpm-lock.yaml* ./
RUN pnpm install --prod --frozen-lockfile --ignore-scripts
COPY --from=builder /app/.next ./.next COPY --from=builder /app/.next ./.next
COPY --from=builder /app/public ./public COPY --from=builder /app/public ./public
EXPOSE 3000 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 — cần thiết cho Docker build để generate API client nhất quán với local
# (orval.config.ts sẽ ưu dụng local file trước, fallback sang fetch từ BE)
...@@ -133,4 +133,4 @@ You can check out [the Next.js GitHub repository](https://github.com/vercel/next ...@@ -133,4 +133,4 @@ You can check out [the Next.js GitHub repository](https://github.com/vercel/next
The easiest way to deploy your Next.js app is to use the [Vercel Platform](https://vercel.com/new?utm_medium=default-template&filter=next.js&utm_source=create-next-app&utm_campaign=create-next-app-readme) from the creators of Next.js. The easiest way to deploy your Next.js app is to use the [Vercel Platform](https://vercel.com/new?utm_medium=default-template&filter=next.js&utm_source=create-next-app&utm_campaign=create-next-app-readme) from the creators of Next.js.
Check out our [Next.js deployment documentation](https://nextjs.org/docs/app/building-your-application/deploying) for more details. Check out our [Next.js deployment documentation](https://nextjs.org/docs/app/building-your-application/deploying) for more details.
\ No newline at end of file
...@@ -677,7 +677,7 @@ export default function AdminBaseConfigPage() { ...@@ -677,7 +677,7 @@ export default function AdminBaseConfigPage() {
} catch (error) { } catch (error) {
console.error(error); console.error(error);
if (mounted) { if (mounted) {
toast.error("Không thể tải danh sách banner"); toast.error("Không thể tải danh sách banner");
} }
} }
}; };
......
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