45 lines
1.2 KiB
YAML
45 lines
1.2 KiB
YAML
# 可选覆盖文件:把 PostgreSQL / Redis 也交给 Compose 管理。
|
|
# 用法:./scripts/docker-deploy.sh --full
|
|
|
|
services:
|
|
postgres:
|
|
image: postgres:16-alpine
|
|
environment:
|
|
POSTGRES_DB: "${POSTGRES_DB:-nex_buddy}"
|
|
POSTGRES_USER: "${POSTGRES_USER:-nex_buddy}"
|
|
POSTGRES_PASSWORD: "${POSTGRES_PASSWORD:-change-me}"
|
|
volumes:
|
|
- pgdata:/var/lib/postgresql/data
|
|
healthcheck:
|
|
test: ["CMD-SHELL", "pg_isready -U \"$${POSTGRES_USER}\" -d \"$${POSTGRES_DB}\""]
|
|
interval: 5s
|
|
timeout: 5s
|
|
retries: 20
|
|
restart: unless-stopped
|
|
|
|
redis:
|
|
image: redis:7-alpine
|
|
command: ["redis-server", "--appendonly", "yes"]
|
|
volumes:
|
|
- redisdata:/data
|
|
healthcheck:
|
|
test: ["CMD", "redis-cli", "ping"]
|
|
interval: 5s
|
|
timeout: 3s
|
|
retries: 20
|
|
restart: unless-stopped
|
|
|
|
api:
|
|
depends_on:
|
|
postgres:
|
|
condition: service_healthy
|
|
redis:
|
|
condition: service_healthy
|
|
environment:
|
|
DATABASE_URL: "postgresql+asyncpg://${POSTGRES_USER:-nex_buddy}:${POSTGRES_PASSWORD:-change-me}@postgres:5432/${POSTGRES_DB:-nex_buddy}"
|
|
REDIS_URL: "redis://redis:6379/9"
|
|
|
|
volumes:
|
|
pgdata:
|
|
redisdata:
|