Files
billai/docker-compose.yaml
CHE LIANG ZHAO 05ab270677 feat: 添加 Gitea webhook 自动部署功能
- 新增独立的 webhook 服务 (Go, 端口 9000)
- HMAC-SHA256 签名验证
- 零停机热更新部署
- 自动清理旧镜像
- 完整配置文档 WEBHOOK_SETUP.md
- 精简 README 版本历史为表格形式
2026-01-13 14:37:01 +08:00

156 lines
4.1 KiB
YAML
Raw 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.
services:
# SvelteKit 前端服务
web:
build:
context: ./web
dockerfile: Dockerfile
container_name: billai-web
restart: unless-stopped
ports:
- "3000:3000"
environment:
NODE_ENV: production
HOST: "0.0.0.0"
PORT: "3000"
# SSR 服务端请求后端的地址Docker 内部网络)
API_URL: "http://server:8080"
depends_on:
server:
condition: service_healthy
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:3000"]
interval: 10s
timeout: 5s
retries: 5
start_period: 15s
# Go 后端服务
server:
build:
context: ./server
dockerfile: Dockerfile
container_name: billai-server
restart: unless-stopped
ports:
- "8080:8080"
environment:
ANALYZER_URL: "http://analyzer:8001"
ANALYZER_MODE: "http"
MONGO_URI: "mongodb://admin:password@mongodb:27017"
MONGO_DATABASE: "billai"
# 认证配置
JWT_SECRET: "billai-secret-key-2026"
TOKEN_EXPIRY: "1" # Token 过期时间(小时)
# 管理员账号(如需覆盖配置文件中的用户,取消注释以下配置)
ADMIN_USERNAME: "admin"
ADMIN_PASSWORD: "admin123"
ADMIN_NAME: "管理员"
volumes:
- ./server/uploads:/app/server/uploads
- ./server/outputs:/app/server/outputs
depends_on:
analyzer:
condition: service_healthy
mongodb:
condition: service_healthy
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:8080/health"]
interval: 10s
timeout: 5s
retries: 5
start_period: 10s
# Python 分析服务 (FastAPI)
analyzer:
build:
context: ./analyzer
dockerfile: Dockerfile
container_name: billai-analyzer
restart: unless-stopped
ports:
- "8001:8001"
environment:
ANALYZER_HOST: "0.0.0.0"
ANALYZER_PORT: "8001"
volumes:
# 共享数据目录,用于访问上传的文件
- ./server/uploads:/app/server/uploads
- ./server/outputs:/app/server/outputs
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:8001/health"]
interval: 10s
timeout: 5s
retries: 5
start_period: 10s
mongodb:
image: mongo:8.0
container_name: billai-mongodb
restart: unless-stopped
ports:
- "27017:27017"
environment:
MONGO_INITDB_DATABASE: billai
# 如需认证,取消下面两行注释
MONGO_INITDB_ROOT_USERNAME: admin
MONGO_INITDB_ROOT_PASSWORD: password
volumes:
- ./mongodata/db:/data/db
- ./mongodata/configdb:/data/configdb
healthcheck:
test: ["CMD", "mongosh", "--eval", "db.adminCommand('ping')"]
interval: 10s
timeout: 5s
retries: 5
start_period: 10s
networks:
default:
aliases:
- mongo
# 可选MongoDB 可视化管理工具
mongo-express:
image: mongo-express:latest
container_name: billai-mongo-express
restart: unless-stopped
ports:
- "8083:8081"
environment:
ME_CONFIG_MONGODB_SERVER: mongodb
ME_CONFIG_MONGODB_PORT: 27017
ME_CONFIG_BASICAUTH: "false"
# 如启用 MongoDB 认证,取消下面两行注释
ME_CONFIG_MONGODB_ADMINUSERNAME: admin
ME_CONFIG_MONGODB_ADMINPASSWORD: password
depends_on:
mongodb:
condition: service_healthy
# Gitea Webhook 服务 - 自动部署
webhook:
build:
context: ./webhook
dockerfile: Dockerfile
container_name: billai-webhook
restart: unless-stopped
ports:
- "9000:9000"
environment:
WEBHOOK_PORT: "9000"
# 重要:更改此 Secret 为强随机值
# 生成方法: openssl rand -hex 32
WEBHOOK_SECRET: "change-this-to-your-secret-key"
REPO_PATH: "/app"
volumes:
# 挂载 Docker Socket 以支持容器操作
- /var/run/docker.sock:/var/run/docker.sock
# 挂载仓库目录
- /path/to/billai:/app
working_dir: /app
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:9000/health"]
interval: 10s
timeout: 5s
retries: 3
start_period: 5s