Files
myaps_api/docker-compose.yml
admin f7e79269f5 ci(build): add aliyun mirror switch and fix redis command
1. 为Dockerfile添加USE_ALIYUN_MIRROR构建参数,支持切换使用阿里云镜像源
2. 移除docker-compose.yml中redis的动态密码参数配置
3. 在CI工作流中默认关闭阿里云镜像源
2026-06-01 12:39:35 +08:00

135 lines
3.8 KiB
YAML
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# 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
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:${PORT:-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
environment:
- UPTIME_KUMA_LISTEN=0.0.0.0:${UPTIME_KUMA_PORT:-3001}
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: --bind=:${PORTAINER_PORT:-9000} --tunnel-port ${PORTAINER_TUNNEL_PORT:-9001}
volumes:
redis_data:
driver: local
postgres_data:
driver: local
uptime_kuma_data:
driver: local
portainer_data:
driver: local