103 lines
3.0 KiB
YAML
103 lines
3.0 KiB
YAML
# ============================================
|
|
# 玩玩云 Docker Compose 配置
|
|
# ============================================
|
|
# 使用方法:
|
|
# 1. 复制 backend/.env.example 为 backend/.env 并修改配置
|
|
# 2. 运行: docker-compose up -d
|
|
# 3. 访问: http://localhost (或配置的域名)
|
|
# ============================================
|
|
|
|
services:
|
|
desktop-release:
|
|
image: node:20-alpine
|
|
container_name: wanwanyun-desktop-release
|
|
restart: "no"
|
|
working_dir: /workspace/frontend
|
|
command: ["node", "scripts/sync-desktop-release.js"]
|
|
volumes:
|
|
- ./frontend:/workspace/frontend
|
|
networks:
|
|
- wanwanyun-network
|
|
|
|
# ============================================
|
|
# 后端服务
|
|
# ============================================
|
|
backend:
|
|
build:
|
|
context: ./backend
|
|
dockerfile: Dockerfile
|
|
container_name: wanwanyun-backend
|
|
restart: unless-stopped
|
|
environment:
|
|
- NODE_ENV=production
|
|
- PORT=40001
|
|
# 以下配置建议通过 .env 文件或环境变量设置
|
|
# - JWT_SECRET=<至少32字符的强随机密钥>
|
|
# - ADMIN_USERNAME=admin
|
|
# - ADMIN_PASSWORD=<至少8位且至少包含两类字符的强密码>
|
|
env_file:
|
|
- ./backend/.env
|
|
depends_on:
|
|
desktop-release:
|
|
condition: service_completed_successfully
|
|
volumes:
|
|
# 数据持久化
|
|
- ./backend/data:/app/data
|
|
- ./backend/storage:/app/storage
|
|
# 桌面安装包由管理端发布,前后端共享此目录
|
|
- ./frontend/downloads:/frontend/downloads
|
|
networks:
|
|
- wanwanyun-network
|
|
healthcheck:
|
|
test: ["CMD", "wget", "--spider", "-q", "http://localhost:40001/api/health"]
|
|
interval: 30s
|
|
timeout: 10s
|
|
retries: 3
|
|
start_period: 40s
|
|
|
|
# ============================================
|
|
# Nginx 前端服务
|
|
# ============================================
|
|
nginx:
|
|
build:
|
|
context: ./frontend
|
|
dockerfile: Dockerfile
|
|
container_name: wanwanyun-nginx
|
|
restart: unless-stopped
|
|
ports:
|
|
- "80:80"
|
|
- "443:443"
|
|
volumes:
|
|
# 动态发布的桌面安装包覆盖镜像内初始版本
|
|
- ./frontend/downloads:/runtime/downloads:ro
|
|
# Nginx 配置
|
|
- ./nginx/nginx.conf:/etc/nginx/conf.d/default.conf:ro
|
|
# SSL 证书(如有)
|
|
- ./nginx/ssl:/etc/nginx/ssl:ro
|
|
# Let's Encrypt 证书目录(可选)
|
|
# - /etc/letsencrypt:/etc/letsencrypt:ro
|
|
# - ./certbot/www:/var/www/certbot:ro
|
|
depends_on:
|
|
desktop-release:
|
|
condition: service_completed_successfully
|
|
backend:
|
|
condition: service_healthy
|
|
networks:
|
|
- wanwanyun-network
|
|
healthcheck:
|
|
test: ["CMD", "wget", "--spider", "-q", "http://localhost/"]
|
|
interval: 30s
|
|
timeout: 10s
|
|
retries: 3
|
|
|
|
networks:
|
|
wanwanyun-network:
|
|
driver: bridge
|
|
|
|
# ============================================
|
|
# 可选: 数据卷(用于更持久的数据存储)
|
|
# ============================================
|
|
# volumes:
|
|
# wanwanyun-data:
|
|
# wanwanyun-storage:
|