AOVIS 部署归档:AWS 生产内容同步到 GCP 冷备测试环境
归档日期:2026-05-04 状态:已同步、已验证、GCP VM 已停机 范围:将 AWS 生产端已经部署的 Git 内容同步到 GCP 冷备/测试环境,避免环境漂移
1. 归档目的
这份记录保存本次跨云同步的执行证据。
本次工作的目标是:
- 以 AWS 生产端当前 Git commit 作为唯一代码基准
- 唤醒 GCP 冷备/测试 VM
- 在 GCP app VM 上从远端 Git 快进到同一 commit
- 完成安装、Prisma generate、生产构建和 PM2 重启
- 验证 GCP app 服务可用并与 AWS 生产 commit 一致
- 验证完成后停机 GCP app/db VM,降低 VM 使用费用
2. 环境身份
- 仓库:
aovis-direct-store - 分支:
main - 远程:
origin/main - AWS 生产主机:
52.87.46.166 - AWS 生产路径:
/opt/aovis/aovis-store-staging - AWS PM2 进程:
aovis-store-aws - GCP 项目:
aovis-direct-store-492514 - GCP zone:
us-west1-c - GCP app VM:
aovis-store-staging-vm - GCP db VM:
aovis-db-staging-vm - GCP app 路径:
/opt/aovis/aovis-store-staging - GCP PM2 进程:
aovis-store-staging
3. 同步身份
- AWS 生产 commit:
b62238082cf3da4c1067dcfe8856c302e45e533e - GCP 同步前 commit:
7dddb1ccc7319d92d668c0a222bf639842518672 - GCP 同步后 commit:
b62238082cf3da4c1067dcfe8856c302e45e533e - 同步方式:GCP VM 内部
git fetch+git pull --ff-only origin main - 本地未提交脏文件:未参与同步
- VM 环境文件:未覆盖
.env.production
4. 同步的 Git 文件范围
GCP 从 7dddb1c 快进到 b622380 时包含以下已提交文件:
PROGRESS.mdapp/account/devices/page.tsxapp/account/loading.tsxapp/account/orders/[id]/loading.tsxapp/account/orders/[id]/page.tsxapp/account/orders/loading.tsxapp/account/orders/page.tsxapp/account/page.tsxapp/account/profile/page.tsxapp/account/services/page.tsxapp/admin/layout.tsxapp/globals.csscomponents/account-layout-shell.tsxcomponents/account-order-list.tsxcomponents/account-profile-center.tsxcomponents/account-ui.tsxcomponents/admin-language-switcher.tsxcomponents/admin-nav.tsxcomponents/admin-shell.tsxcomponents/admin-table-row.tsxcomponents/admin-ui.tsxdocs/current-store-development-status.mddocs/deploy-sop.mdlib/auth-config.ts
说明:
- 这些内容已经先在 AWS 生产端完成部署与验证
- 本次 GCP 工作只是同步既有生产 commit,不从本地脏工作区发布
- GCP 工作区同步后无 tracked 脏改
- GCP 工作区保留未跟踪运行时文件:
.env.production、.env.production.bak-auth-security-20260428025438
5. 执行步骤
确认 GCP 账号:
gcloud auth list --filter=status:ACTIVE --format='value(account)'
结果:
- 活动账号:
[email protected]
确认 GCP VM 初始状态:
aovis-store-staging-vm:TERMINATEDaovis-db-staging-vm:TERMINATED
启动 GCP VM:
gcloud compute instances start aovis-db-staging-vm aovis-store-staging-vm --zone us-west1-c --project aovis-direct-store-492514
启动结果:
- app internal IP:
10.138.0.4 - db internal IP:
10.138.0.3 - app 临时 external IP:
34.177.118.243
部署命令:
gcloud compute ssh aovis-store-staging-vm --zone us-west1-c --project aovis-direct-store-492514 --command 'set -euo pipefail; cd /opt/aovis/aovis-store-staging; echo BEFORE=$(git rev-parse HEAD); git fetch origin; git pull --ff-only origin main; echo AFTER=$(git rev-parse HEAD); npm install; npx prisma generate; npm run build; pm2 restart aovis-store-staging --update-env; pm2 status aovis-store-staging'
部署结果:
git pull --ff-only origin main成功npm install成功npx prisma generate成功npm run build成功pm2 restart aovis-store-staging --update-env成功- PM2
aovis-store-staging状态:online
6. 验证结果
AWS 与 GCP commit 对齐:
- AWS:
b62238082cf3da4c1067dcfe8856c302e45e533e - GCP:
b62238082cf3da4c1067dcfe8856c302e45e533e
GCP app VM 本机服务验证:
http://127.0.0.1:3000/返回200http://127.0.0.1:3000/account返回307,跳转/login?callbackUrl=%2Faccounthttp://127.0.0.1:3000/admin-signin返回200
GCP 外部 IP 验证:
http://34.177.118.243返回301Location: https://aovis.app/
说明:
- GCP 本机 Next.js 服务已验证可用
- 外部 IP 的 Caddy 入口仍重定向到生产域名,这是现有冷备入口配置表现
- 本次同步成功标准以 Git commit 一致性、GCP VM 本机服务响应、构建和 PM2 状态为准
7. 停机结果
验证完成后执行:
gcloud compute instances stop aovis-db-staging-vm aovis-store-staging-vm --zone us-west1-c --project aovis-direct-store-492514
最终状态:
aovis-store-staging-vm:TERMINATEDaovis-store-staging-vmstop time:2026-05-03T23:35:12.231-07:00aovis-db-staging-vm:TERMINATEDaovis-db-staging-vmstop time:2026-05-03T23:36:36.344-07:00
8. 结论
- GCP 冷备/测试环境已同步到 AWS 生产同一 Git commit
- GCP app 构建和 PM2 重启成功
- GCP 本机 HTTP 验证通过
- GCP app/db VM 已停机以降低费用
- 本次没有覆盖 VM 受保护运行时环境文件
- 本次没有从本地未提交脏文件发布任何内容