单机生产部署
适合无面板管理的服务器,使用 Docker 自建基础设施,支持 SSL 证书自动申请。
架构
┌─────────────────────────────────────────────────────────────┐
│ Nginx (443/80) │
│ ├── your-domain.com → frontend:80 (前端) │
│ ├── admin.your-domain.com → admin:80 (管理后台) │
│ └── api.your-domain.com → backend:8000 (后端 API) │
└─────────────────────────────────────────────────────────────┘
│
┌─────────────────────────────────────────────────────────────┐
│ Docker Network: radstudio │
│ ├── frontend (nginx:80) │
│ ├── admin (nginx:80) │
│ ├── backend (uvicorn:8000) │
│ ├── celery-worker │
│ ├── agent (心跳 + 配置拉取) │
│ ├── postgres (PostgreSQL 16) │
│ └── redis (Redis 7) │
└─────────────────────────────────────────────────────────────┘
部署流程
1. 初始化服务器
# 安装 Docker、配置防火墙
sudo bash deploy/scripts/init-server.sh
2. 初始化配置
radstudioctl prod init --native
3. 编辑配置
vim .env
需要配置的关键项:
# 数据库
POSTGRES_PASSWORD=your_secure_password
REDIS_PASSWORD=your_redis_password
# 安全
SECRET_KEY=your_secret_key
INTERNAL_SERVICE_TOKEN=your_token
# 域名
DOMAIN=your-domain.com
FRONTEND_URL=https://your-domain.com
ADMIN_URL=https://admin.your-domain.com
BACKEND_URL=https://api.your-domain.com
# 存储
OBJECT_STORAGE_BACKEND=s3
S3_ENDPOINT=https://s3.amazonaws.com
S3_ACCESS_KEY=your_access_key
S3_SECRET_KEY=your_secret_key
S3_BUCKET=radstudio
4. 启动基础设施
radstudioctl infra up
5. 申请 SSL 证书
radstudioctl infra ssl
6. 部署应用
# Phase 1: migrate + backend + admin
radstudioctl prod bootstrap
# Phase 2: agent + frontend + celery-worker
radstudioctl prod deploy
7. 创建管理员
域名 配置
添加 DNS A 记录:
your-domain.com → 服务器公网 IP
admin.your-domain.com → 服务器公网 IP
api.your-domain.com → 服务器公网 IP
SSL 证书
- 自动申请 Let's Encrypt 证书
- 每天凌晨 3 点自动续期
- 支持手动续期:
radstudioctl infra ssl
运维命令
# 基础设施
radstudioctl infra up # 启动
radstudioctl infra down # 停止
radstudioctl infra status # 查看状态
radstudioctl infra ssl # SSL 证书管理
# 应用
radstudioctl prod bootstrap # 部署 Phase 1
radstudioctl prod deploy # 部署 Phase 2
radstudioctl prod status # 查看状态
radstudioctl prod logs # 查看日志
radstudioctl prod restart # 重启
radstudioctl prod down # 停止