flyctl
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseFly.io Deployment (flyctl)
Fly.io Deployment (flyctl)
Deploy applications to Fly.io's global edge infrastructure.
将应用部署到Fly.io的全球边缘基础设施。
Quick Reference
快速参考
| Task | Command |
|---|---|
| New app | |
| Deploy | |
| Status | |
| Logs | |
| SSH | |
| Open | |
| 任务 | 命令 |
|---|---|
| 新建应用 | |
| 部署应用 | |
| 查看状态 | |
| 查看日志 | |
| SSH连接 | |
| 打开应用 | |
Core Workflows
核心工作流
1. New App Deployment
1. 新应用部署
bash
cd /path/to/project
fly launch # Interactive setup
fly launch --now -y # Accept defaults, deploy immediately
fly launch --no-deploy # Configure only, deploy laterCreates: (config), (if needed)
fly.tomlDockerfilebash
cd /path/to/project
fly launch # 交互式配置
fly launch --now -y # 接受默认配置,立即部署
fly launch --no-deploy # 仅完成配置,稍后部署生成文件:(配置文件)、(如有需要)
fly.tomlDockerfile2. Subsequent Deploys
2. 后续部署
bash
fly deploy # Standard deploy
fly deploy --strategy rolling # Rolling update (default)
fly deploy --local-only # Build locally instead of remotebash
fly deploy # 标准部署
fly deploy --strategy rolling # 滚动更新(默认方式)
fly deploy --local-only # 本地构建而非远程构建3. Secrets Management
3. 密钥管理
bash
fly secrets set KEY=value # Set secret
fly secrets set K1=v1 K2=v2 # Multiple
fly secrets list # List (values hidden)
fly secrets unset KEY # Remove
cat .env | fly secrets import # Import from filebash
fly secrets set KEY=value # 设置密钥
fly secrets set K1=v1 K2=v2 # 设置多个密钥
fly secrets list # 列出密钥(值隐藏)
fly secrets unset KEY # 删除密钥
cat .env | fly secrets import # 从文件导入密钥4. Scaling
4. 缩放配置
bash
fly scale show # Current config
fly scale vm shared-cpu-1x # Change VM size
fly scale memory 512 # Set memory (MB)
fly scale count 3 # Set instance count
fly scale count web=2 worker=1 # Per process groupVM sizes: , , ,
shared-cpu-1xshared-cpu-2xperformance-1xperformance-2xbash
fly scale show # 查看当前配置
fly scale vm shared-cpu-1x # 更改VM规格
fly scale memory 512 # 设置内存(MB)
fly scale count 3 # 设置实例数量
fly scale count web=2 worker=1 # 按进程组设置VM规格选项:、、、
shared-cpu-1xshared-cpu-2xperformance-1xperformance-2x5. Volumes (Persistent Storage)
5. 存储卷(持久化存储)
bash
fly volumes create mydata --size 10 --region ord # Create 10GB
fly volumes list # List volumes
fly volumes extend <id> --size 20 # ResizeMount in fly.toml:
toml
[mounts]
source = "mydata"
destination = "/data"bash
fly volumes create mydata --size 10 --region ord # 创建10GB存储卷
fly volumes list # 列出存储卷
fly volumes extend <id> --size 20 # 调整存储卷大小在fly.toml中挂载:
toml
[mounts]
source = "mydata"
destination = "/data"6. Databases
6. 数据库
Managed Postgres (recommended):
bash
fly mpg create # Create managed postgres
fly mpg list # List clustersUnmanaged Postgres:
bash
fly postgres create # Create cluster
fly postgres attach <pg-app> # Attach to app (sets DATABASE_URL)
fly postgres connect <pg-app> # Connect via psqlRedis (Upstash):
bash
fly redis create # Create instance托管Postgres(推荐):
bash
fly mpg create # 创建托管Postgres
fly mpg list # 列出集群非托管Postgres:
bash
fly postgres create # 创建集群
fly postgres attach <pg-app> # 关联到应用(自动设置DATABASE_URL)
fly postgres connect <pg-app> # 通过psql连接Redis(Upstash):
bash
fly redis create # 创建实例7. Monitoring
7. 监控
bash
fly status # App status
fly logs # Tail logs
fly logs -i <machine-id> # Specific machine
fly checks list # Health checks
fly dashboard # Open web UIbash
fly status # 查看应用状态
fly logs # 实时查看日志
fly logs -i <machine-id> # 查看特定实例日志
fly checks list # 查看健康检查
fly dashboard # 打开Web控制台8. SSH & Console
8. SSH与控制台
bash
fly ssh console # Interactive shell
fly ssh console -C "cmd" # Run command
fly sftp shell # SFTP accessbash
fly ssh console # 交互式Shell
fly ssh console -C "cmd" # 执行指定命令
fly sftp shell # SFTP访问fly.toml Essentials
fly.toml 核心配置
toml
app = "my-app"
primary_region = "ord"
[env]
APP_ENV = "production"
[http_service]
internal_port = 8080
force_https = true
auto_stop_machines = "stop"
auto_start_machines = true
min_machines_running = 1
[[vm]]
memory = "512mb"
cpu_kind = "shared"
cpus = 1toml
app = "my-app"
primary_region = "ord"
[env]
APP_ENV = "production"
[http_service]
internal_port = 8080
force_https = true
auto_stop_machines = "stop"
auto_start_machines = true
min_machines_running = 1
[[vm]]
memory = "512mb"
cpu_kind = "shared"
cpus = 1Framework-Specific
框架专属指南
For Laravel apps: Read
For Dockerfile apps: Read
reference/laravel.mdreference/dockerfile.mdLaravel应用:参考
Dockerfile应用:参考
reference/laravel.mdreference/dockerfile.mdTroubleshooting
故障排查
bash
fly doctor # Diagnose issues
fly releases # List releases
fly releases show <v> # Release details
fly machine list # List machines
fly machine restart <id> # Restart specific machinebash
fly doctor # 诊断问题
fly releases # 列出版本
fly releases show <v> # 查看版本详情
fly machine list # 列出实例
fly machine restart <id> # 重启特定实例Common Flags
通用参数
| Flag | Description |
|---|---|
| Specify app name |
| Config file path |
| Target region |
| Skip confirmations |
| Verbose output |
| 参数 | 说明 |
|---|---|
| 指定应用名称 |
| 配置文件路径 |
| 指定目标区域 |
| 跳过确认步骤 |
| 显示详细输出 |