mirror of
https://github.com/rnvm9wjdtj-bot/myaps_api.git
synced 2026-06-02 05:54:40 +00:00
750e8853f1
1. 修复数据库完整性错误:staging_routers.py 添加 _retry_count 字段默认值 0 2. 时区配置规范化:.env 和 settings.py 使用 IANA 格式(Asia/Shanghai),保持向后兼容 3. Docker 部署优化: - Portainer 禁用 Edge 功能,释放 8000 端口 - Uptime Kuma 和 Portainer 设为默认启动服务 4. 新增部署模板:创建 scripts/deploy_docker/mount 目录结构
133 lines
3.7 KiB
YAML
133 lines
3.7 KiB
YAML
# MyAPS API Docker Compose 配置
|
||
#
|
||
# 使用方法:
|
||
# 生产部署(从Docker Hub拉取):
|
||
# DOCKER_IMAGE=qsct/myaps-api:master docker-compose up -d
|
||
#
|
||
# 本地构建部署:
|
||
# docker-compose up -d --build
|
||
#
|
||
# 配置文件挂载:
|
||
# 自动根据 .env 中的 PROJECT_DIR 挂载整个目录
|
||
# - ./project_files/${PROJECT_DIR}:/app/project_files/${PROJECT_DIR}
|
||
#
|
||
# 包含文件:
|
||
# - {PROJECT_JSON}.json (租户配置)
|
||
# - remind.py (告警配置)
|
||
# - client.py 等Git托管文件(覆盖无影响)
|
||
#
|
||
# 网络模式:
|
||
# 全部使用host模式,统一通过localhost访问各服务
|
||
|
||
services:
|
||
redis:
|
||
image: redis:7-alpine
|
||
container_name: myaps_redis
|
||
restart: unless-stopped
|
||
network_mode: host
|
||
volumes:
|
||
- redis_data:/data
|
||
command: redis-server --appendonly yes ${REDIS_PASSWORD:+--requirepass ${REDIS_PASSWORD}}
|
||
healthcheck:
|
||
test: ["CMD", "redis-cli", "ping"]
|
||
interval: 10s
|
||
timeout: 5s
|
||
retries: 5
|
||
|
||
postgres:
|
||
image: postgres:16-alpine
|
||
container_name: myaps_postgres
|
||
restart: unless-stopped
|
||
network_mode: host
|
||
env_file:
|
||
- .env
|
||
environment:
|
||
- TZ=${TIMEZONE:-Asia/Shanghai}
|
||
- POSTGRES_INITDB_ARGS=--encoding=UTF-8 --lc-collate=C --lc-ctype=C
|
||
- POSTGRES_USER=${THIS_DB_USER}
|
||
- POSTGRES_PASSWORD=${THIS_DB_PASSWORD}
|
||
- POSTGRES_DB=${THIS_DB_NAME}
|
||
- POSTGRES_PORT=${THIS_DB_PORT:-5432}
|
||
volumes:
|
||
- postgres_data:/var/lib/postgresql/data
|
||
healthcheck:
|
||
test: ["CMD-SHELL", "pg_isready -U ${THIS_DB_USER} -d ${THIS_DB_NAME}"]
|
||
interval: 10s
|
||
timeout: 5s
|
||
retries: 5
|
||
|
||
app:
|
||
build:
|
||
context: .
|
||
dockerfile: Dockerfile
|
||
image: ${DOCKER_IMAGE:-myaps_api:latest}
|
||
container_name: myaps_api
|
||
restart: unless-stopped
|
||
network_mode: host
|
||
env_file:
|
||
- .env
|
||
environment:
|
||
# 覆盖.env中的配置,适配host网络模式
|
||
- REDIS_HOST=${REDIS_HOST:-localhost}
|
||
- THIS_DB_HOST=${THIS_DB_HOST:-localhost}
|
||
- GUNICORN_BIND=0.0.0.0:${PORT:-8000}
|
||
- APP_ROOT=/app
|
||
volumes:
|
||
# 日志持久化
|
||
- ./logs:/app/logs
|
||
# 存储持久化(SQLite、Binlog位置等)
|
||
- ./storage:/app/storage
|
||
# 项目配置目录挂载(自动使用.env中的PROJECT_DIR)
|
||
# 挂载整个目录,自动包含:
|
||
# - {PROJECT_JSON}.json (租户配置)
|
||
# - remind.py (告警配置)
|
||
# - client.py 等托管文件会被覆盖,但内容相同无影响
|
||
- ./project_files/${PROJECT_DIR}:/app/project_files/${PROJECT_DIR}
|
||
depends_on:
|
||
redis:
|
||
condition: service_healthy
|
||
postgres:
|
||
condition: service_healthy
|
||
healthcheck:
|
||
test: ["CMD", "curl", "-f", "http://localhost:8000/docs"]
|
||
interval: 30s
|
||
timeout: 10s
|
||
start_period: 10s
|
||
retries: 3
|
||
|
||
# ============ 附加服务(默认开启)============
|
||
# 监控和管理工具,随基础服务一起启动
|
||
|
||
uptime-kuma:
|
||
image: louislam/uptime-kuma:1.23.11
|
||
container_name: myaps_uptime_kuma
|
||
restart: unless-stopped
|
||
network_mode: host
|
||
volumes:
|
||
- uptime_kuma_data:/app/data
|
||
healthcheck:
|
||
test: ["CMD", "node", "server/server.js", "--healthcheck"]
|
||
interval: 30s
|
||
timeout: 10s
|
||
retries: 3
|
||
|
||
portainer:
|
||
image: portainer/portainer-ce:2.21.4
|
||
container_name: myaps_portainer
|
||
restart: unless-stopped
|
||
network_mode: host
|
||
volumes:
|
||
- /var/run/docker.sock:/var/run/docker.sock
|
||
- portainer_data:/data
|
||
command: -p 9000 --no-edge
|
||
|
||
volumes:
|
||
redis_data:
|
||
driver: local
|
||
postgres_data:
|
||
driver: local
|
||
uptime_kuma_data:
|
||
driver: local
|
||
portainer_data:
|
||
driver: local
|