flyctl

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Fly.io Deployment (flyctl)

Fly.io Deployment (flyctl)

Deploy applications to Fly.io's global edge infrastructure.
将应用部署到Fly.io的全球边缘基础设施。

Quick Reference

快速参考

TaskCommand
New app
fly launch
Deploy
fly deploy
Status
fly status
Logs
fly logs
SSH
fly ssh console
Open
fly apps open
任务命令
新建应用
fly launch
部署应用
fly deploy
查看状态
fly status
查看日志
fly logs
SSH连接
fly ssh console
打开应用
fly apps open

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 later
Creates:
fly.toml
(config),
Dockerfile
(if needed)
bash
cd /path/to/project
fly launch              # 交互式配置
fly launch --now -y     # 接受默认配置,立即部署
fly launch --no-deploy  # 仅完成配置,稍后部署
生成文件:
fly.toml
(配置文件)、
Dockerfile
(如有需要)

2. Subsequent Deploys

2. 后续部署

bash
fly deploy                    # Standard deploy
fly deploy --strategy rolling # Rolling update (default)
fly deploy --local-only       # Build locally instead of remote
bash
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 file
bash
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 group
VM sizes:
shared-cpu-1x
,
shared-cpu-2x
,
performance-1x
,
performance-2x
bash
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-1x
shared-cpu-2x
performance-1x
performance-2x

5. 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                  # Resize
Mount 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 clusters
Unmanaged 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 psql
Redis (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 UI
bash
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 access
bash
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 = 1
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 = 1

Framework-Specific

框架专属指南

For Laravel apps: Read
reference/laravel.md
For Dockerfile apps: Read
reference/dockerfile.md
Laravel应用:参考
reference/laravel.md
Dockerfile应用:参考
reference/dockerfile.md

Troubleshooting

故障排查

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 machine
bash
fly doctor              # 诊断问题
fly releases            # 列出版本
fly releases show <v>   # 查看版本详情
fly machine list        # 列出实例
fly machine restart <id> # 重启特定实例

Common Flags

通用参数

FlagDescription
-a <app>
Specify app name
-c <path>
Config file path
-r <region>
Target region
--yes
Skip confirmations
--verbose
Verbose output
参数说明
-a <app>
指定应用名称
-c <path>
配置文件路径
-r <region>
指定目标区域
--yes
跳过确认步骤
--verbose
显示详细输出