Fly.io 部署
Fly.io 是一个全球边缘计算平台,可以将 Docker 容器部署到离用户最近的数据中心。适合需要低延迟访问的场景。
前置条件
bash
# 安装 Fly CLI
curl -L https://fly.io/install.sh | sh
# 登录
fly auth login快速部署
1. 创建项目目录
bash
mkdir openclaw-fly && cd openclaw-fly2. 创建 fly.toml
toml
app = "my-openclaw"
primary_region = "nrt" # 东京,亚洲延迟最低
[build]
image = "ghcr.io/openclaw/gateway:latest"
[env]
NODE_ENV = "production"
OPENCLAW_LOG_LEVEL = "info"
[http_service]
internal_port = 18789
force_https = true
auto_stop_machines = true
auto_start_machines = true
min_machines_running = 1
[[vm]]
cpu_kind = "shared"
cpus = 1
memory_mb = 10243. 设置 Secrets(密钥)
bash
# 设置 API Key(控制台认证)
fly secrets set OPENCLAW_API_KEY="your-secret-key"
# 设置模型 Provider Key(如需要)
fly secrets set OPENAI_API_KEY="sk-xxx"4. 创建持久化卷
bash
fly volumes create openclaw_data --size 1 --region nrt在 fly.toml 中添加挂载:
toml
[mounts]
source = "openclaw_data"
destination = "/home/openclaw/.openclaw"5. 部署
bash
fly launch # 首次部署
fly deploy # 后续更新常用命令
bash
# 查看日志
fly logs
# SSH 进入容器
fly ssh console
# 查看状态
fly status
# 扩缩容
fly scale count 2 # 扩到 2 个实例
fly scale memory 2048 # 增加内存到 2GB排障
部署失败:健康检查超时
bash
# 增加启动超时时间
fly deploy --wait-timeout 300磁盘空间不足
bash
# 扩展卷大小
fly volumes extend <vol_id> --size 5查看崩溃原因
bash
fly logs --instance <instance_id>