Fly.io (flyctl + Machines API)

flyctl — see fly version update for current (auto-updates by default) · active · verified Sun Mar 01

Fly.io is a compute platform for deploying containerized apps globally. There is no official Fly.io Python SDK — interaction is via the flyctl CLI, fly.toml config file, and the Machines REST API. The unofficial fly-python-sdk on PyPI (pip install fly-python-sdk) is a third-party project last updated October 2023 and should not be relied upon.

Warnings

Install

Imports

Quickstart

Primary workflow is CLI-based. fly launch detects framework and generates fly.toml. fly deploy on every code change.

# Deploy a Python app:
# 1. In your project directory:
fly launch          # Scans project, creates fly.toml, provisions app
fly deploy          # Builds image, deploys to Machines

# Minimal fly.toml for a Python web app:
# app = 'my-app'
# primary_region = 'iad'
#
# [http_service]
# internal_port = 8080
# force_https = true
# auto_stop_machines = 'suspend'
# auto_start_machines = true
# min_machines_running = 0
#
# [[vm]]
# memory = '256mb'
# cpu_kind = 'shared'
# cpus = 1

# Secrets (env vars):
fly secrets set OPENAI_API_KEY=sk-...

# Scale:
fly scale count 2
fly scale memory 512

view raw JSON →