KB-4874
S174-PREP-NUXT: Backup 2 Repo + De Xuat Sua + Check Ha Tang
7 min read Revision 1
s174nuxtbackupreport
S174-PREP-NUXT: Backup 2 Repo + Đề Xuất Sửa + Check Hạ Tầng
Date: 2026-04-08 Mission: S174-PREP-NUXT Status: COMPLETE
VIỆC 1 — BACKUP 2 REPO LÊN GITHUB
Kết quả
| Repo | Path local VPS | Branch | Commit hash | Remote URL | Backup branch | Verify |
|---|---|---|---|---|---|---|
| web-test | /opt/incomex/docker/nuxt-repo |
main | dd0e52b |
https://github.com/Huyen1974/web-test.git |
main (VPS is ancestor of remote — remote đã chứa toàn bộ VPS content) | ✓ VPS⊂Remote |
| agent-data-test | /opt/incomex/docker/agent-data-repo |
main | 3fcad85 |
https://github.com/Huyen1974/agent-data-test.git |
vps-snapshot-s174 (diverged — push VPS main sang branch backup) |
✓ Exact match |
Chi tiết
web-test: VPS HEAD dd0e52b là ancestor của remote HEAD 260ed7b. Remote đã chứa tất cả commits trên VPS. Không cần push — backup đã an toàn.
agent-data-test: Diverged — VPS có 4 commits không trên remote, remote có ~100 commits không trên VPS.
- VPS-only commits:
3fcad85S170,f6dd405S167 PG→Qdrant,8adfd37S167 add files,4acebbcFREEZE S167 - Push thành công VPS main → remote branch
vps-snapshot-s174(exact match verified) - ⚠️ Branch
maintrên VPS lệch remotemain— cần reconcile riêng (ngoài scope S174-PREP)
VIỆC 2 — ĐỀ XUẤT SỬA CODE NUXT ĐỂ BỎ PHỤ THUỘC GOOGLE
Tổng quan kiến trúc hiện tại
docker-compose.ymlentrynuxt:dùng image từpkg.dev(Artifact Registry GCP retired)- Deploy thực tế: volume mount
/opt/incomex/deploys/nuxt-output:/app/.output— nuxt chạy từ pre-built output, KHÔNG pull image mỗi lần start - Dockerfile build (
web/Dockerfile) dùng basenode:20-alpinetừ Docker Hub — KHÔNG phụ thuộc GCP - Firebase Auth được dùng cho client-side authentication (login/portal)
Bảng đề xuất sửa
| # | File | Dòng | Hiện tại | Đề xuất sửa | Mức độ |
|---|---|---|---|---|---|
| 1 | docker-compose.yml |
125 | image: ${NUXT_SSR_IMAGE:-asia-southeast1-docker.pkg.dev/.../nuxt-ssr:latest} |
Đổi sang image: nuxt-ssr-local:latest hoặc build from web/Dockerfile với build: context: ./nuxt-repo/web |
BLOCKER — cold start/recreate sẽ fail nếu registry hết hạn |
| 2 | web/Dockerfile |
3 | Comment "Also pushed to Artifact Registry as backup for Cloud Run" | Xóa comment Cloud Run/Artifact Registry | Low — chỉ docs |
| 3 | web/nuxt.config.ts |
117-128 | firebase: { apiKey: ..., authDomain: ... } runtimeConfig |
GIỮ NGUYÊN nếu vẫn dùng Firebase Auth. Nếu muốn bỏ hoàn toàn: thay bằng Directus Auth | DECISION — cần quyết định auth strategy |
| 4 | web/plugins/firebase.client.ts |
1-44 | Firebase client init plugin | GIỮ NGUYÊN nếu vẫn dùng Firebase Auth. Graceful degradation đã có (check apiKey trước init) |
DECISION — phụ thuộc #3 |
| 5 | web/middleware/auth.ts |
1 | import { onAuthStateChanged } from 'firebase/auth' |
GIỮ NGUYÊN nếu vẫn dùng Firebase Auth | DECISION — phụ thuộc #3 |
| 6 | web/package.json |
61-62 | "firebase": "^12.6.0", "google-auth-library": "^10.5.0" |
google-auth-library có thể xóa (googleAuth.ts đã deprecated). firebase giữ nếu vẫn dùng Auth |
Medium — google-auth-library là dead dep |
| 7 | web/server/utils/googleAuth.ts |
toàn file | Đã deprecated + stub — all commented out | Xóa file, thay bằng stub 1 dòng hoặc xóa hẳn + cập nhật imports | Low — đã là dead code |
| 8 | web/server/api/directus/[...path].ts |
93,170-171 | firebaseSessionCookie, __session cookie proxy |
GIỮ NGUYÊN nếu vẫn dùng Firebase Auth | DECISION — phụ thuộc #3 |
| 9 | docker-compose.local.yml |
17 | image: gcr.io/cloud-sql-connectors/cloud-sql-proxy:2.14.2 |
Xóa cloud-sql-proxy service (VPS dùng local PG) | Low — chỉ local dev |
| 10 | docker-compose.local.yml |
35 | image: asia-southeast1-docker.pkg.dev/.../directus:latest |
Đổi sang local directus image | Low — chỉ local dev |
| 11 | dot/configs/directus.env.template |
25-26 | STORAGE_LOCATIONS=gcs, STORAGE_GCS_DRIVER=gcs |
Đổi sang STORAGE_LOCATIONS=local, xóa GCS config |
Medium — template cho directus |
Lưu ý quan trọng
- #1 là BLOCKER duy nhất cho runtime Nuxt. Các mục khác hoặc là dead code, hoặc phụ thuộc quyết định giữ/bỏ Firebase Auth.
GOOGLE_APPLICATION_CREDENTIALS(compose line 103) thuộc serviceagent-data, KHÔNG phảinuxt— ngoài scope.- Firebase Auth là client-side only (
.client.tsplugin) — không phụ thuộc GCP infrastructure, chỉ phụ thuộc Firebase project (miễn phí tier).
VIỆC 3 — CHECK HẠ TẦNG VPS ĐỦ BUILD NUXT KHÔNG
Bảng đánh giá
| Tài nguyên | Yêu cầu ước lượng | Hiện có | Đủ/Thiếu |
|---|---|---|---|
| RAM total | ~2GB cho Nuxt build | 11Gi total, 8.8Gi available | ✓ DƯ |
| RAM free | ≥1.5GB free | 5.9Gi free | ✓ DƯ |
| Swap | Có thì tốt | 2Gi (unused) | ✓ OK |
| Disk free | ~2GB cho build + image | 60GB available (38% used) | ✓ DƯ |
| Docker Engine | ≥20.x | 29.2.1 | ✓ OK |
| Docker Buildx | Có | v0.31.1 | ✓ OK |
Base image node:20-alpine |
Cần pull ~180MB | Chưa cached, Docker Hub reachable (manifest inspect OK) |
✓ Có thể pull |
| Build context | Nhỏ | 23MB (không có node_modules) | ✓ OK |
.dockerignore |
Nên có để exclude .git, node_modules |
KHÔNG CÓ — build context sẽ include .git (~vài MB) |
⚠️ NÊN TẠO |
| Pre-built output | — | /opt/incomex/deploys/nuxt-output/ tồn tại, có nitro.json, public/, server/ |
✓ Đã có output sẵn |
| pnpm | Cần cho build | Trong Dockerfile corepack enable — tự cài trong build |
✓ OK |
Kết luận
VPS ĐỦ ĐIỀU KIỆN build Nuxt từ source.
- RAM, disk, Docker đều dư
- Base image
node:20-alpinepull được từ Docker Hub - Thiếu
.dockerignore(minor — nên tạo để optimize build context) - Nuxt đang chạy từ pre-built
.outputvia volume mount — có thể build local rồi copy output mà KHÔNG cần đổi compose image
Ghi chú thêm
- Dockerfile hiện tại (
web/Dockerfile) comment nói "Cloud Run" nhưng build logic hoàn toàn standard — dùng được cho VPS - Port trong Dockerfile là 8080 (Cloud Run default), compose override thành 3000 — OK vì compose env
PORT: '3000'sẽ override - Existing local images:
docker-nuxt:latest(248MB),nuxt-ssr-local:latest(249MB) — đã từng build local thành công
AP-CLOSE CHECKLIST
- Việc 1: web-test VPS content verified in remote ✓
- Việc 1: agent-data-test pushed to
vps-snapshot-s174, exact match verified ✓ - Việc 2: Báo cáo 11 mục Google dependency + đề xuất sửa ✓
- Việc 3: Báo cáo hạ tầng — VPS đủ build ✓
- Upload report lên KB