47 lines
1.1 KiB
YAML
47 lines
1.1 KiB
YAML
services:
|
|
postgres:
|
|
image: postgres:18.3-alpine3.23
|
|
container_name: trade-postgres
|
|
environment:
|
|
POSTGRES_USER: trade
|
|
POSTGRES_PASSWORD: trade
|
|
POSTGRES_DB: futures
|
|
volumes:
|
|
- pgdata:/var/lib/postgresql
|
|
healthcheck:
|
|
test: ["CMD-SHELL", "pg_isready -U trade -d futures"]
|
|
interval: 5s
|
|
timeout: 5s
|
|
retries: 5
|
|
|
|
tushare:
|
|
build: ./tushare
|
|
container_name: trade-tushare
|
|
# token 已写死在代码中,无需 env_file
|
|
environment:
|
|
- DATABASE_URL=postgresql://trade:trade@postgres:5432/futures
|
|
depends_on:
|
|
postgres:
|
|
condition: service_healthy
|
|
ports:
|
|
- "4001:8000"
|
|
command: ["uvicorn", "src.api:app", "--host", "0.0.0.0", "--port", "8000"]
|
|
|
|
web:
|
|
build:
|
|
context: ./web
|
|
dockerfile: backend/Dockerfile
|
|
container_name: trade-web
|
|
# .env 已移除,环境变量直接写在此处
|
|
environment:
|
|
- LISTEN_ADDR=:8080
|
|
- DATABASE_URL=postgres://trade:trade@postgres:5432/futures?sslmode=disable
|
|
depends_on:
|
|
- postgres
|
|
ports:
|
|
- "4000:8080"
|
|
restart: unless-stopped
|
|
|
|
volumes:
|
|
pgdata:
|