116 lines
3.9 KiB
YAML
116 lines
3.9 KiB
YAML
# =============================================================================
|
|
# Team-API Docker Compose 配置文件
|
|
# =============================================================================
|
|
# 使用说明:
|
|
# 1. 修改下方 "数据库配置" 中的 POSTGRES_PASSWORD
|
|
# 2. 修改下方 "Redis 配置" 中的 --requirepass 密码
|
|
# 3. 将 manifest/docker/config.yaml 修改为实际配置
|
|
# (确保数据库密码和 Redis 密码与上方设置一致)
|
|
# 4. (可选)复制 .env.example 为 .env 并按需调整镜像加速配置
|
|
# 5. 运行: docker compose up -d
|
|
#
|
|
# 镜像加速说明(大陆用户):
|
|
# 构建时默认使用 goproxy.cn 和 npmmirror 作为 Go/Bun 的下载源。
|
|
# 拉取基础镜像缓慢时,可配置 Docker daemon 镜像加速器:
|
|
# 编辑 /etc/docker/daemon.json,添加:
|
|
# {"registry-mirrors": ["https://mirror.ccs.tencentyun.com", "https://docker.1ms.run"]}
|
|
# 然后重启 Docker: systemctl restart docker
|
|
# =============================================================================
|
|
|
|
services:
|
|
# -----------------------------------------------------------------------------
|
|
# PostgreSQL 数据库
|
|
# -----------------------------------------------------------------------------
|
|
postgres:
|
|
image: postgres:17-alpine
|
|
container_name: team-api-postgres
|
|
restart: unless-stopped
|
|
environment:
|
|
TZ: Asia/Shanghai
|
|
POSTGRES_USER: team_api
|
|
POSTGRES_PASSWORD: team_api_secret # 请修改为强密码
|
|
POSTGRES_DB: team_api
|
|
PGDATA: /var/lib/postgresql/data/pgdata
|
|
volumes:
|
|
- postgres_data:/var/lib/postgresql/data
|
|
healthcheck:
|
|
test: ["CMD-SHELL", "pg_isready -U team_api -d team_api"]
|
|
interval: 10s
|
|
timeout: 5s
|
|
retries: 5
|
|
networks:
|
|
- team-api-network
|
|
|
|
# -----------------------------------------------------------------------------
|
|
# Redis 缓存
|
|
# -----------------------------------------------------------------------------
|
|
redis:
|
|
image: redis:7-alpine
|
|
container_name: team-api-redis
|
|
restart: unless-stopped
|
|
environment:
|
|
TZ: Asia/Shanghai
|
|
command: redis-server --appendonly yes --requirepass redis_secret # 请修改为强密码
|
|
volumes:
|
|
- redis_data:/data
|
|
healthcheck:
|
|
test: ["CMD", "redis-cli", "-a", "redis_secret", "ping"]
|
|
interval: 10s
|
|
timeout: 5s
|
|
retries: 5
|
|
networks:
|
|
- team-api-network
|
|
|
|
# -----------------------------------------------------------------------------
|
|
# Team-API 应用
|
|
# -----------------------------------------------------------------------------
|
|
app:
|
|
image: team-api:${VERSION:-v0.1.0}
|
|
build:
|
|
context: ../..
|
|
dockerfile: manifest/docker/Dockerfile
|
|
args:
|
|
VERSION: ${VERSION:-latest}
|
|
GOPROXY: ${GOPROXY:-https://goproxy.cn,direct}
|
|
BUN_CONFIG_REGISTRY: ${BUN_CONFIG_REGISTRY:-https://registry.npmmirror.com}
|
|
container_name: team-api-app
|
|
restart: unless-stopped
|
|
ports:
|
|
- "18888:18888"
|
|
environment:
|
|
TZ: Asia/Shanghai
|
|
volumes:
|
|
- ./config.yaml:/app/config/config.yaml:ro
|
|
- app_logs:/app/logs
|
|
healthcheck:
|
|
test: ["CMD", "curl", "-f", "http://localhost:18888/api/health"]
|
|
interval: 30s
|
|
timeout: 10s
|
|
start_period: 30s
|
|
retries: 3
|
|
depends_on:
|
|
postgres:
|
|
condition: service_healthy
|
|
redis:
|
|
condition: service_healthy
|
|
networks:
|
|
- team-api-network
|
|
|
|
# -----------------------------------------------------------------------------
|
|
# 数据卷定义
|
|
# -----------------------------------------------------------------------------
|
|
volumes:
|
|
postgres_data:
|
|
driver: local
|
|
redis_data:
|
|
driver: local
|
|
app_logs:
|
|
driver: local
|
|
|
|
# -----------------------------------------------------------------------------
|
|
# 网络定义
|
|
# -----------------------------------------------------------------------------
|
|
networks:
|
|
team-api-network:
|
|
driver: bridge
|