Files
qzl dab47f0cb3 chore: 优化本地开发环境配置
- 添加 .env.local 支持,app.sh 和 dev-migrate.sh 自动覆盖
- Docker Compose 使用 profiles 区分 dev/prod 环境
- 改进认证 dev session 判断逻辑,使用 test account 配置
- 修复 CoinPackageCard 重复代码问题
- 清理 opencode 配置,移除敏感信息
- 新增 infra/docker/README.md 文档
- 修复 ruff/pyright/flutter lint 错误
- 更新测试用例移除已删除的 country 字段
2026-04-28 18:49:38 +08:00

127 lines
2.5 KiB
Markdown

# Docker Compose Infrastructure
> Local development infrastructure orchestration.
---
## Overview
This directory contains Docker Compose configurations for local development:
- `docker-compose.yml` - Base services (Redis, etc.)
- `supabase/docker-compose.yml` - Local Supabase stack (PostgreSQL, Auth, Storage, Studio, etc.)
---
## Environment-Based Service Activation
Services are conditionally enabled based on `ERYAO_RUNTIME__ENVIRONMENT`:
| Environment | Services |
|-------------|----------|
| `dev` | Redis + Local Supabase |
| `prod` | Redis only (use cloud Supabase) |
### How It Works
Supabase services use `profiles: [dev]`. They only start when the `dev` profile is activated.
---
## Usage
### Development (with local Supabase)
```bash
cd infra/docker
docker compose --profile dev up -d
```
Or with environment variable:
```bash
ERYAO_RUNTIME__ENVIRONMENT=dev docker compose --profile dev up -d
```
### Production (cloud Supabase)
```bash
cd infra/docker
docker compose up -d
```
---
## Services Reference
### Base Services (always started)
| Service | Port | Description |
|---------|------|-------------|
| Redis | 6379 | Caching and queue backend |
### Dev-Only Services (profile: dev)
| Service | Port | Description |
|---------|------|-------------|
| PostgreSQL | 5432 | Local database |
| GoTrue (Auth) | 9999 | Authentication service |
| PostgREST | 3000 | REST API for database |
| Storage | 5000 | File storage service |
| Studio | 3000 | Supabase dashboard UI |
| Kong | 8001, 8443 | API gateway |
---
## Configuration
All services read configuration from `.env` (symlinked to project root `.env`).
Required environment variables:
```bash
# Runtime
ERYAO_RUNTIME__ENVIRONMENT=dev
# Database
ERYAO_DATABASE__PORT=5432
ERYAO_DATABASE__NAME=postgres
ERYAO_DATABASE__PASSWORD=your-password
# Supabase
ERYAO_SUPABASE__JWT_SECRET=your-jwt-secret
ERYAO_SUPABASE__ANON_KEY=your-anon-key
ERYAO_SUPABASE__SERVICE_ROLE_KEY=your-service-role-key
ERYAO_SUPABASE__PUBLIC_URL=http://localhost:8001
# Redis
ERYAO_REDIS__PORT=6379
ERYAO_REDIS__PASSWORD=your-redis-password
```
---
## Troubleshooting
### Supabase services not starting
1. Check profile is activated: `docker compose --profile dev config`
2. Verify environment variables in `.env`
3. Check logs: `docker compose logs <service-name>`
### Port conflicts
If ports are already in use, override in `.env`:
```bash
ERYAO_DATABASE__PORT=5433
ERYAO_REDIS__PORT=6380
```
### Reset local database
```bash
docker compose --profile dev down -v
docker compose --profile dev up -d
```