CLI:准备 Cloudflare 资源
为核心交付(9 个 D1、1 个 KV、1 个 R2)创建所需 Cloudflare 资源。Worker 会在执行 wrangler deploy 时自动创建 — 各 wrangler.jsonc 中的 name 定义 Worker 名称,部署时自动应用 binding。增值服务(如 zship-provider1-service)不包含在内。
1. 创建 D1 数据库
Section titled “1. 创建 D1 数据库”在仓库根目录执行以下命令。每条命令会创建数据库并自动更新对应服务的 wrangler.jsonc:
cd backend/node1-auth-service && npx wrangler d1 create zship-auth --binding DB --update-config && cd ../..cd backend/node2-support-service && npx wrangler d1 create zship-support --binding DB --update-config && cd ../..cd backend/node3-pay-service && npx wrangler d1 create zship-pay --binding DB --update-config && cd ../..cd backend/node4-notify-service && npx wrangler d1 create zship-notify --binding DB --update-config && cd ../..cd backend/node5-blog-service && npx wrangler d1 create zship-blog --binding DB --update-config && cd ../..cd backend/node7-site-service && npx wrangler d1 create zship-site --binding DB --update-config && cd ../..cd backend/node8-prompt-service && npx wrangler d1 create zship-prompt --binding DB --update-config && cd ../..cd backend/node9-checkin-service && npx wrangler d1 create zship-checkin --binding DB --update-config && cd ../..cd backend/node10-ai-service && npx wrangler d1 create zship-ai --binding DB --update-config && cd ../..2. 创建 KV namespace
Section titled “2. 创建 KV namespace”cd backend/node3-pay-servicenpx wrangler kv namespace create zship-pay-kv --binding KV --update-configcd ../..3. 创建 R2 bucket
Section titled “3. 创建 R2 bucket”cd backend/node6-cdn-servicenpx wrangler r2 bucket create zship-cdn --binding BUCKET --update-configcd ../..4. 确认没有占位符
Section titled “4. 确认没有占位符”rg -n "00000000-0000-0000-0000-000000000000|placeholder-replace-after-create" backend/*/wrangler.jsonc如果无输出,说明已就绪。若有匹配,先修正配置再继续。
5. 检查清单
Section titled “5. 检查清单”- 9 个 D1 数据库已创建
- KV namespace 已创建
- R2 bucket 已创建
-
wrangler.jsonc中无占位符 ID