- erp-core: error types, shared types, event bus, ErpModule trait - erp-server: config loading, database/Redis connections, migrations - erp-server/migration: tenants table with SeaORM - apps/web: Vite + React 18 + TypeScript + Ant Design 5 + TailwindCSS - Web frontend: main layout with sidebar, header, routing - Docker: PostgreSQL 16 + Redis 7 development environment - All workspace crates compile successfully (cargo check passes)
58 lines
1.6 KiB
Markdown
58 lines
1.6 KiB
Markdown
# infrastructure (Docker 与开发环境)
|
||
|
||
## 设计思想
|
||
|
||
开发环境使用 Docker Compose 提供基础设施服务,应用服务在宿主机运行。这种设计允许:
|
||
- 后端 Rust 服务快速重启(无需容器化构建)
|
||
- 前端 Vite 热更新直接在宿主机
|
||
- 数据库和缓存服务标准化,团队成员环境一致
|
||
|
||
## 代码逻辑
|
||
|
||
### 服务配置
|
||
|
||
| 服务 | 镜像 | 端口 | 用途 |
|
||
|------|------|------|------|
|
||
| erp-postgres | postgres:16-alpine | 5432 | 主数据库 |
|
||
| erp-redis | redis:7-alpine | 6379 | 缓存 + 会话 |
|
||
|
||
### 连接信息
|
||
```
|
||
PostgreSQL: postgres://erp:erp_dev_2024@localhost:5432/erp
|
||
Redis: redis://localhost:6379
|
||
```
|
||
|
||
### 健康检查
|
||
- PostgreSQL: `pg_isready` 每 5 秒,5 次重试
|
||
- Redis: `redis-cli ping` 每 5 秒,5 次重试
|
||
|
||
### 数据持久化
|
||
- `postgres_data` — 命名卷,PostgreSQL 数据
|
||
- `redis_data` — 命名卷,Redis 数据
|
||
|
||
### 环境变量
|
||
通过 `docker/.env.example` 文档化,使用默认值即可启动开发环境。
|
||
|
||
## 关联模块
|
||
|
||
- **[[erp-server]]** — 连接 PostgreSQL 和 Redis
|
||
- **[[database]]** — 迁移在 PostgreSQL 中执行
|
||
- **[[frontend]]** — Vite 代理 API 到后端
|
||
|
||
## 关键文件
|
||
|
||
| 文件 | 职责 |
|
||
|------|------|
|
||
| `docker/docker-compose.yml` | 服务定义 |
|
||
| `docker/.env.example` | 环境变量模板 |
|
||
| `crates/erp-server/config/default.toml` | 默认连接配置 |
|
||
|
||
## 常用命令
|
||
|
||
```bash
|
||
cd docker && docker compose up -d # 启动服务
|
||
docker compose -f docker/docker-compose.yml ps # 查看状态
|
||
docker compose -f docker/docker-compose.yml down # 停止
|
||
docker exec -it erp-postgres psql -U erp # 连接数据库
|
||
```
|