Files
cryptoHermes/docker-compose.yml
2026-05-24 21:18:19 +08:00

80 lines
2.6 KiB
YAML
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
services:
postgres:
image: timescale/timescaledb:latest-pg16
container_name: crypto-hermes-postgres
environment:
POSTGRES_USER: ${POSTGRES_USER:-postgres}
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:?POSTGRES_PASSWORD must be set, see .env.example}
POSTGRES_DB: ${POSTGRES_DB:-hermes_market}
ports:
- "${POSTGRES_PORT:-5432}:5432"
volumes:
- hermes_pg_data:/var/lib/postgresql/data
healthcheck:
# 用 pg_isready 探测,避免 init 期 race
test: ["CMD-SHELL", "pg_isready -U ${POSTGRES_USER:-postgres} -d ${POSTGRES_DB:-hermes_market}"]
interval: 5s
timeout: 3s
retries: 10
start_period: 10s
restart: unless-stopped
logging:
driver: json-file
options:
max-size: "50m"
max-file: "5"
# init container跑完 migration 立即退出。
# 由 app 依赖它 service_completed_successfully保证表存在再启动 app。
migrate:
image: migrate/migrate:v4.18.1
container_name: crypto-hermes-migrate
depends_on:
postgres:
condition: service_healthy
volumes:
- ./migrations:/migrations:ro
command:
- -path=/migrations
- -database=postgres://${POSTGRES_USER:-postgres}:${POSTGRES_PASSWORD:?POSTGRES_PASSWORD must be set, see .env.example}@postgres:5432/${POSTGRES_DB:-hermes_market}?sslmode=disable
- up
restart: "no"
app:
build:
context: .
dockerfile: Dockerfile
container_name: crypto-hermes-market-gateway
depends_on:
postgres:
condition: service_healthy
migrate:
condition: service_completed_successfully
ports:
- "${APP_HOST_PORT:-8080}:8080"
environment:
CONFIG_PATH: /app/config/config.yml
APP_ENV: ${APP_ENV:-production}
APP_PORT: "8080"
POSTGRES_DSN: postgres://${POSTGRES_USER:-postgres}:${POSTGRES_PASSWORD:?POSTGRES_PASSWORD must be set, see .env.example}@postgres:5432/${POSTGRES_DB:-hermes_market}?sslmode=disable
BINANCE_BASE_URL: ${BINANCE_BASE_URL:-https://fapi.binance.com}
# 透传代理:国内直连 fapi.binance.com 不稳,详见 AGENTS.md §7.5
HTTP_PROXY: ${HTTP_PROXY:-}
HTTPS_PROXY: ${HTTPS_PROXY:-}
NO_PROXY: ${NO_PROXY:-}
volumes:
- ./config:/app/config:ro
- ./logs:/app/logs
# SIGTERM → 等 app 内置 10s graceful shutdownfiber.ShutdownWithContext
# + cron 任务结束的缓冲 = 30s。超时后 docker 发 SIGKILL。
stop_grace_period: 30s
restart: unless-stopped
logging:
driver: json-file
options:
max-size: "50m"
max-file: "5"
volumes:
hermes_pg_data: