feat(service): dockerize — Dockerfile + docker-compose + 统一入口

把项目打包成可部署的数据同步服务:

- Dockerfile (multi-stage builder/runtime, slim base, 含 healthcheck)
- docker-compose.yml (postgres:16-alpine + market_sync, 持久化 pgdata + logs)
- .dockerignore (减 build context)
- bin/service_run.sh (单进程跑 uvicorn + scheduler 线程)
- app/entrypoints/worker.py 抽 start_scheduler_thread() (幂等)

部署:
  docker compose up -d
  # 然后访问 http://localhost:8100/docs 看 FastAPI

设计选择:
  - 单容器一服务(uvicorn 主 + scheduler daemon thread),不用 supervisord
  - 原 systemd timer 由进程内 scheduler 取代(配置已存在于 config 表)
  - PG 用 docker volume 持久化;同步日志单独 volume
This commit is contained in:
gao
2026-07-07 16:30:56 +08:00
parent a8ea132924
commit fbc3cc84f0
5 changed files with 299 additions and 1 deletions
+31
View File
@@ -0,0 +1,31 @@
# .dockerignore — 减小 build context
.git
.github
.vscode
.idea
.claude
.venv
venv
__pycache__
*.pyc
*.pyo
*.pyd
.pytest_cache
.mypy_cache
.ruff_cache
.coverage
htmlcov/
*.log
logs/
.DS_Store
*.swp
*.swo
node_modules
frontend/node_modules
tests/
docs/
*.md
!README.md
# 已通过 requirements.txt 装好,不重复打包
**/*.tar.gz
**/*.whl