1
0

docker-compose.yml 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. # FitHealthAgent —— 默认(持久化)配置
  2. #
  3. # 开发时想要热重载:
  4. # docker compose -f docker-compose.yml -f docker-compose.dev.yml up
  5. #
  6. # 首次使用:
  7. # 1. cp .env.example .env 并填好各 API key;
  8. # 2. docker compose up -d --build
  9. services:
  10. fithealth:
  11. build:
  12. context: .
  13. dockerfile: Dockerfile
  14. args:
  15. # 发布版默认使用 Python 3.12,可在部署时覆盖基础镜像。
  16. BASE_IMAGE: python:3.12-bookworm
  17. image: fit_health_agent:v1
  18. container_name: fit_health_agent
  19. restart: unless-stopped
  20. ports:
  21. # 个人自用:只绑本机回环,不对局域网暴露
  22. - "127.0.0.1:9999:9999"
  23. env_file:
  24. - .env
  25. environment:
  26. PYTHONUNBUFFERED: "1"
  27. PYTHONDONTWRITEBYTECODE: "1"
  28. PYTHONPATH: /app
  29. TZ: Asia/Shanghai
  30. # 与下面的数据卷挂载点保持一致。
  31. FITHEALTH_DATA_DIR: /app/data
  32. volumes:
  33. # 持久化 JSON、health.db、原始导入文件和心率流。
  34. - ./data:/app/data
  35. working_dir: /app
  36. healthcheck:
  37. test:
  38. - CMD
  39. - python
  40. - -c
  41. - "import urllib.request,sys; sys.exit(0 if urllib.request.urlopen('http://127.0.0.1:9999/health/storage-status', timeout=4).status == 200 else 1)"
  42. interval: 30s
  43. timeout: 5s
  44. retries: 3
  45. start_period: 20s
  46. # SQLite 异常可通过 /health/storage-status 检查存储状态。
  47. stop_grace_period: 20s