新增内容: - 创建基础项目结构。 - 添加 `.gitignore` 和 `.dockerignore` 文件。 - 编写 `pyproject.toml` 和依赖文件。 - 添加算法模块及示例算法。 - 实现核心功能模块(日志、错误处理、指标)。 - 添加开发和运行所需的相关脚本文件及文档。
109 lines
2.6 KiB
YAML
109 lines
2.6 KiB
YAML
version: '3.8'
|
||
|
||
services:
|
||
app:
|
||
build:
|
||
context: ..
|
||
dockerfile: deployment/Dockerfile
|
||
ports:
|
||
- "8111:8000"
|
||
environment:
|
||
- APP_ENV=development
|
||
- LOG_LEVEL=INFO
|
||
- METRICS_ENABLED=true
|
||
# 方案1:Pushgateway 配置
|
||
- PUSHGATEWAY_URL=pushgateway:9091
|
||
- METRICS_JOB_NAME=functional_scaffold
|
||
# 方案2:Redis 配置
|
||
- REDIS_HOST=redis
|
||
- REDIS_PORT=6379
|
||
- REDIS_METRICS_DB=0
|
||
volumes:
|
||
- ../src:/app/src
|
||
restart: unless-stopped
|
||
depends_on:
|
||
- redis
|
||
- pushgateway
|
||
healthcheck:
|
||
test: ["CMD", "python", "-c", "import urllib.request; urllib.request.urlopen('http://localhost:8000/healthz')"]
|
||
interval: 30s
|
||
timeout: 3s
|
||
retries: 3
|
||
start_period: 5s
|
||
|
||
# Redis - 用于集中式指标存储(方案2)
|
||
redis:
|
||
image: redis:7-alpine
|
||
ports:
|
||
- "6379:6379"
|
||
volumes:
|
||
- redis_data:/data
|
||
command: redis-server --appendonly yes
|
||
restart: unless-stopped
|
||
healthcheck:
|
||
test: ["CMD", "redis-cli", "ping"]
|
||
interval: 10s
|
||
timeout: 3s
|
||
retries: 3
|
||
|
||
# Pushgateway - 用于短生命周期任务的指标推送(方案1,推荐)
|
||
pushgateway:
|
||
image: prom/pushgateway:latest
|
||
ports:
|
||
- "9091:9091"
|
||
restart: unless-stopped
|
||
command:
|
||
- '--persistence.file=/data/pushgateway.data'
|
||
- '--persistence.interval=5m'
|
||
volumes:
|
||
- pushgateway_data:/data
|
||
|
||
# Redis Exporter - 将 Redis 指标导出为 Prometheus 格式(方案2需要)
|
||
redis-exporter:
|
||
build:
|
||
context: ..
|
||
dockerfile: deployment/Dockerfile.redis-exporter
|
||
ports:
|
||
- "8001:8001"
|
||
environment:
|
||
- REDIS_HOST=redis
|
||
- REDIS_PORT=6379
|
||
- REDIS_METRICS_DB=0
|
||
depends_on:
|
||
- redis
|
||
restart: unless-stopped
|
||
|
||
prometheus:
|
||
image: prom/prometheus:latest
|
||
ports:
|
||
- "9090:9090"
|
||
volumes:
|
||
- ../monitoring/prometheus.yml:/etc/prometheus/prometheus.yml
|
||
- prometheus_data:/prometheus
|
||
command:
|
||
- '--config.file=/etc/prometheus/prometheus.yml'
|
||
- '--storage.tsdb.path=/prometheus'
|
||
restart: unless-stopped
|
||
depends_on:
|
||
- pushgateway
|
||
- redis-exporter
|
||
|
||
grafana:
|
||
image: grafana/grafana:latest
|
||
ports:
|
||
- "3000:3000"
|
||
environment:
|
||
- GF_SECURITY_ADMIN_PASSWORD=admin
|
||
volumes:
|
||
- grafana_data:/var/lib/grafana
|
||
- ../monitoring/grafana:/etc/grafana/provisioning
|
||
restart: unless-stopped
|
||
depends_on:
|
||
- prometheus
|
||
|
||
volumes:
|
||
prometheus_data:
|
||
grafana_data:
|
||
redis_data:
|
||
pushgateway_data:
|