refactor: 迁移本地 Supabase 到云端,使用 JWKS 进行 JWT 验证
- 新增 JwtVerifier 支持 RS256 + JWKS 验证 - 简化 docker-compose,删除本地 Supabase 服务(kong/auth/storage等) - 删除冗余的 Supabase 配置文件(volumes目录) - 适配测试用例以支持新配置方式 - 更新运行时文档和迁移计划
This commit is contained in:
@@ -28,10 +28,10 @@
|
||||
### Step 1: 启动基础设施
|
||||
|
||||
```bash
|
||||
docker compose --env-file .env -f infra/docker/docker-compose.yml up -d
|
||||
docker compose --env-file .env -f infra/docker/docker-compose.yml up -d redis
|
||||
```
|
||||
|
||||
通过标准:`docker compose ... ps` 中 redis/supabase 相关容器为 `running`。
|
||||
通过标准:`docker compose ... ps` 中 `redis` 容器为 `running`/`healthy`。
|
||||
|
||||
### Step 2: 执行迁移与初始化
|
||||
|
||||
@@ -114,8 +114,11 @@ set +a
|
||||
|
||||
WEB_BASE_URL="http://127.0.0.1:${SOCIAL_WEB__PORT:-5775}"
|
||||
|
||||
# 基础健康
|
||||
curl -fsS http://127.0.0.1:${SOCIAL_SUPABASE__KONG_HTTP_PORT:-8000}/health
|
||||
# 基础健康(redis/web;数据库使用云 Supabase Postgres)
|
||||
docker compose --env-file .env -f infra/docker/docker-compose.yml exec -T redis \
|
||||
sh -lc 'if [ -n "${REDIS_PASSWORD:-}" ]; then redis-cli -a "${REDIS_PASSWORD}" ping; else redis-cli ping; fi'
|
||||
|
||||
curl -fsS "${WEB_BASE_URL}/health"
|
||||
|
||||
# compose 状态
|
||||
docker compose --env-file .env -f infra/docker/docker-compose.yml ps
|
||||
@@ -126,7 +129,7 @@ curl -sS -X POST "${WEB_BASE_URL}/api/v1/auth/sessions" \
|
||||
-d '{"email":"demo@example.com","password":"secret123"}'
|
||||
```
|
||||
|
||||
通过标准:health 返回 2xx,关键容器 `running`,核心接口返回预期业务状态码。
|
||||
通过标准:redis 健康检查成功,web `/health` 返回 2xx,容器 `running`,核心接口返回预期业务状态码。
|
||||
|
||||
### L2 可选(Auth/Profile 业务回归)
|
||||
|
||||
@@ -193,31 +196,25 @@ docker compose --env-file .env -f infra/docker/docker-compose.yml exec -T redis
|
||||
- 定位:核对 `.env` 中 Supabase JWT 配置与签发方设置。
|
||||
- 修复:修正配置后重启 web 进程并执行 L1/L2 验证。
|
||||
|
||||
### 4) Auth 邮件模板未生效 / 注册返回超时但邮件已发送
|
||||
### 4) 基础设施容器异常(db/redis)
|
||||
|
||||
- 症状:
|
||||
- 收到默认英文模板(非 `infra/mail-templates`)。
|
||||
- `signup/start` 偶发 500 或超时,但邮箱仍收到验证码邮件。
|
||||
- 根因:容器配置漂移(旧容器未按最新 compose/.env 重建),导致:
|
||||
- `supabase-auth` 缺少 `GOTRUE_MAILER_TEMPLATES_*` 环境变量。
|
||||
- `supabase-mail-templates` 仍挂载旧路径。
|
||||
- 症状:web 启动失败、迁移失败、任务队列连接报错。
|
||||
- 定位:
|
||||
|
||||
```bash
|
||||
docker inspect supabase-auth --format '{{ range .Config.Env }}{{ println . }}{{ end }}' | grep GOTRUE_MAILER_TEMPLATES
|
||||
docker inspect supabase-mail-templates --format '{{ range .Mounts }}{{ .Source }} -> {{ .Destination }}{{ println }}{{ end }}'
|
||||
docker compose --env-file .env -f infra/docker/docker-compose.yml ps
|
||||
docker compose --env-file .env -f infra/docker/docker-compose.yml logs db --tail=100
|
||||
docker compose --env-file .env -f infra/docker/docker-compose.yml logs redis --tail=100
|
||||
```
|
||||
|
||||
- 修复:强制重建 auth 和 mail-templates(不改其他服务):
|
||||
- 修复:按依赖顺序重建基础设施后重新 bootstrap。
|
||||
|
||||
```bash
|
||||
docker compose --env-file .env -f infra/docker/docker-compose.yml up -d --force-recreate --no-deps mail-templates auth
|
||||
docker compose --env-file .env -f infra/docker/docker-compose.yml up -d --force-recreate redis
|
||||
bash infra/scripts/dev-migrate.sh bootstrap
|
||||
```
|
||||
|
||||
- 复核标准:
|
||||
- `docker inspect supabase-auth` 能看到 `GOTRUE_MAILER_TEMPLATES_CONFIRMATION/RECOVERY`。
|
||||
- `supabase-mail-templates` 挂载源为 `infra/mail-templates`。
|
||||
- `POST /api/v1/auth/verifications` 返回 `202` 且耗时恢复正常。
|
||||
- 复核标准:`redis` 健康检查通过,L1 核心接口 smoke 无 5xx。
|
||||
|
||||
---
|
||||
|
||||
@@ -248,7 +245,7 @@ docker compose --env-file .env -f infra/docker/docker-compose.yml up -d --force-
|
||||
|------|------|
|
||||
| 2026-02-24 | 创建运行时手册,删除 legacy 脚本,统一使用 gunicorn |
|
||||
| 2026-02-24 | 清理配置:合并 AppSettings 到 WebSettings,删除 Worker 旧配置 (enabled_queues/queues),统一使用 SOCIAL_WEB__GUNICORN__* 命名 |
|
||||
| 2026-02-24 | 开发阶段 compose 暂不编排 web/worker,仅保留 redis/supabase 与 init-job |
|
||||
| 2026-02-24 | 开发阶段 compose 暂不编排 web/worker,仅保留 redis/db 与 init-job |
|
||||
| 2026-02-24 | 新增 dev-app-up 脚本:手动基础设施后,一键 bootstrap + tmux 拉起 web/worker |
|
||||
| 2026-02-25 | 补充迁移防遗漏规则:容器迁移命令统一追加 --build;开发调试优先使用本地 CLI 一次性迁移脚本 |
|
||||
| 2026-02-25 | Auth 注册切换为 OTP 三段式:signup/start、signup/verify、signup/resend;邮件模板改为纯验证码展示 |
|
||||
@@ -263,3 +260,4 @@ docker compose --env-file .env -f infra/docker/docker-compose.yml up -d --force-
|
||||
| 2026-03-02 | 修正 bootstrap 命令:init-job 需要使用 `uv run python -m core.runtime.cli bootstrap` |
|
||||
| 2026-03-05 | 新增 Agent Runtime run/resume/events 运维排障流程(Taskiq + Redis + Last-Event-ID) |
|
||||
| 2026-03-06 | Web 启动从 gunicorn 迁移为纯 uvicorn,移除 `SOCIAL_WEB__GUNICORN__*` 配置,统一使用 `SOCIAL_WEB__WORKERS` |
|
||||
| 2026-03-09 | 清理本地 Supabase 依赖描述:基础设施启动与巡检统一为 redis/db/web |
|
||||
|
||||
Reference in New Issue
Block a user