mix fly_deploy.hot (FlyDeploy v0.1.13)

Performs a hot code upgrade without restarting the application.

Quick Start

# Zero configuration - everything auto-detected from fly.toml
mix fly_deploy.hot

# Use staging config
mix fly_deploy.hot --config fly-staging.toml

# Pass Docker build arguments
mix fly_deploy.hot --build-arg ELIXIR_VERSION=1.18.2 --build-arg OTP_VERSION=27.1.2

# Preview without executing
mix fly_deploy.hot --dry-run

Configuration

Configuration is merged from multiple sources with priority:

CLI options > Mix config > fly.toml > Auto-detected defaults

fly.toml (or --config custom fly toml file)

The [env] section is automatically read and passed to orchestrator machines:

[env]
  AWS_ENDPOINT_URL_S3 = "https://fly.storage.tigris.dev"
  AWS_REGION = "auto"
  AWS_BUCKET = "my-app-staging"

Mix Config

In config/config.exs:

config :fly_deploy,
  bucket: "my-releases",
  max_concurrency: 10,
  env: %{
    "CUSTOM_VAR" => "value"
  }

CLI Options

  • --config - Path to fly.toml file (default: "fly.toml")
  • --skip-build - Skip building and use existing image (requires --image)
  • --image - Use specific pre-built image
  • --build-arg - Pass build-time variables to Docker (can be used multiple times)
  • --dry-run - Show what would be done without executing
  • --force - Override deployment lock (use with caution)
  • --lock-timeout - Lock expiry timeout in seconds (default: 300)

Required Setup

  • Fly CLI must be authenticated: fly auth login
  • App secrets must include AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY for Tigris/S3
  • App secrets must include FLY_API_TOKEN (used by orchestrator machine)

How It Works

  1. Build Phase: Builds Docker image with fly deploy --build-only
  2. Orchestrator Phase: Spawns temporary machine with new image
  3. Tarball Phase: Orchestrator creates tarball of all .beam files
  4. Upload Phase: Uploads tarball to Tigris/S3
  5. Reload Phase: Each app machine downloads and extracts tarball
  6. Upgrade Phase: Processes are upgraded using :sys.change_code/4

The orchestrator machine automatically has access to app secrets and environment variables from the [env] section of your fly.toml.

Safety

  • Processes are suspended before code loading (prevents race conditions)
  • Only proc_lib processes are upgraded (filters out Tasks)
  • Machines can be upgraded concurrently or sequentially
  • Each process upgrade is isolated with error handling
  • Rollback support (coming soon)