115 lines
3.9 KiB
YAML
115 lines
3.9 KiB
YAML
# =============================================================================
|
||
# Team-API Docker Compose 配置文件
|
||
# =============================================================================
|
||
# 快速部署(仅拉取镜像,只需本文件 + config.yaml):
|
||
# docker compose up -d
|
||
#
|
||
# 本地构建(需要完整项目源码):
|
||
# docker compose --profile build up -d --build
|
||
#
|
||
# 配置步骤:
|
||
# 1. 复制 config.example.yaml 为 config.yaml 并修改数据库密码、Redis 密码等
|
||
# 2. 修改下方 POSTGRES_PASSWORD 和 Redis --requirepass(与 config.yaml 保持一致)
|
||
# 3. 运行: docker compose up -d
|
||
# =============================================================================
|
||
|
||
services:
|
||
# -----------------------------------------------------------------------------
|
||
# PostgreSQL 数据库
|
||
# -----------------------------------------------------------------------------
|
||
postgres:
|
||
image: postgres:18-alpine
|
||
container_name: team-api-postgres
|
||
restart: unless-stopped
|
||
environment:
|
||
TZ: Asia/Shanghai
|
||
POSTGRES_USER: team_api
|
||
POSTGRES_PASSWORD: team_api_secret # 请修改为强密码(PG18 默认 SCRAM-SHA-256 加密)
|
||
POSTGRES_DB: team_api
|
||
# PG18 默认 PGDATA 为 /var/lib/postgresql/18/docker,VOLUME 为 /var/lib/postgresql
|
||
# 不再需要手动设置 PGDATA,镜像已按版本号自动管理子目录
|
||
# PG18 默认启用 data checksums,如从旧版升级且旧集群未启用校验和,
|
||
# 需添加: POSTGRES_INITDB_ARGS: "--no-data-checksums"
|
||
volumes:
|
||
- postgres_data:/var/lib/postgresql
|
||
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: qian5/team-api:${VERSION:-latest}
|
||
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
|