全栈 docker compose 编排上移到根目录,简化部署流程

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
fish
2026-04-26 15:40:50 +08:00
parent 6eb0b3ac3f
commit 4e004f5a85
11 changed files with 418 additions and 263 deletions

View File

@@ -29,7 +29,6 @@ backend/
│ ├── user-login-email/ # 邮箱登录服务 (port 8003)
│ ├── user-register-email/ # 邮箱注册服务 (port 8004)
│ ├── migrations/ # 数据库初始化 SQL
│ ├── docker-compose.yml # 用户服务本地编排
│ └── Dockerfile # 通用/遗留构建文件
├── gateway/ # API 网关
│ ├── Dockerfile
@@ -46,6 +45,8 @@ backend/
└── README.md
```
> 编排已统一上移到项目根目录的 `docker-compose.yml` / `docker-compose.dev.yml`,本目录不再存放 compose 文件。
## 微服务架构说明
### 服务拆分原则
@@ -192,7 +193,7 @@ OK
### 5. Docker 构建
- 各微服务 Dockerfile 的构建上下文为**项目根目录**`docker-compose.yml` 中使用 `context: ../..`)。
- 各微服务 Dockerfile 的构建上下文为 **`backend/` 目录**根目录 `docker-compose.yml` 中使用 `context: ./backend`)。
- 构建采用多阶段builder + runtime基于 `rust:1.94.1-alpine3.23` 编译,最终运行在 `alpine:3.23`。
- 共享代码更新时,需确保 `shared/` 目录在 Dockerfile 中被正确复制。
@@ -206,10 +207,21 @@ OK
## 常用命令
### 启动用户服务(本地开发
### 启动整套后端(含网关 + 数据库 + 缓存
后端不再单独编排,由项目根目录的 docker compose 一并启动。详见 [根目录 CLAUDE.md](../CLAUDE.md#部署)。
```bash
cd services/user-service
docker-compose up --build
# 在项目根目录
docker compose -f docker-compose.dev.yml up -d --build # 测试
docker compose up -d --build # 正式
```
如需仅启动后端栈(不含前端)做联调:
```bash
docker compose -f docker-compose.dev.yml up -d --build user-db user-redis \
user-login-account user-register-account user-login-email user-register-email gateway
```
### 网关管理