### Install example project Source: https://github.com/superfly/docs/blob/main/app-guides/puppeteer-js-renderer.mdx Clone the example repository and install dependencies with npm. ```bash git clone https://github.com/fly-examples/puppeteer-js-renderer.git cd puppeteer-js-renderer npm install ``` -------------------------------- ### Launch Desktop Commander MCP server with setup step Source: https://github.com/superfly/docs/blob/main/model-context-protocol/examples.mdx Requires a setup step to run the DesktopCommander setup command. ```sh fly mcp launch "npx @wonderwhy-er/desktop-commander@latest" \ --claude --server desktop-commander \ --setup "RUN npx -y @wonderwhy-er/desktop-commander@latest setup" ``` -------------------------------- ### Install Prisma CLI and Client Source: https://github.com/superfly/docs/blob/main/unmanaged-postgres/connecting/app-connection-examples.mdx Install the Prisma CLI and Prisma Client dependencies for a Node.js project. ```bash npm i --save-dev prisma npm i @prisma/client ``` -------------------------------- ### Install Sequelize dependencies and CLI Source: https://github.com/superfly/docs/blob/main/unmanaged-postgres/connecting/app-connection-examples.mdx Install the Sequelize dependencies and CLI into your project. ```bash npm install --save sequelize npm install --save-dev sequelize-cli ``` -------------------------------- ### Launch Livebook server locally Source: https://github.com/superfly/docs/blob/main/elixir/advanced-guides/connect-livebook-to-your-app.mdx Start the Livebook server locally after installing it as an Escript. ```bash livebook server ``` -------------------------------- ### List Machine ids with fly machines list -q Source: https://github.com/superfly/docs/blob/main/blueprints/cell-based.mdx Command to get a list of Machine ids, useful for accessing the application when deployed to fly.io. ```bash fly machines list -q ``` -------------------------------- ### Create a Rails app and launch on Fly.io Source: https://github.com/superfly/docs/blob/main/blueprints/cell-based.mdx Commands to scaffold a new Rails application with Tailwind CSS, generate a Post scaffold, and launch it on Fly.io with a unique name. Substitute a different app name if desired. ```bash rails new blog --css tailwind cd blog bin/rails generate scaffold Post title:string body:text fly launch --name blog-$USER-$RANDOM ``` -------------------------------- ### Clone the example repository Source: https://github.com/superfly/docs/blob/main/machines/guides-examples/machines-app-using-flyctl.mdx Clones the hello-gunicorn-flask repository from GitHub to get the code and Dockerfile for the example app. ```bash git clone https://github.com/fly-apps/hello-gunicorn-flask ``` -------------------------------- ### Run the configure script Source: https://github.com/superfly/docs/blob/main/app-guides/vscode-remote.mdx Run the configure script to start the interactive setup. The script prompts for app name, organization, disk size, Docker installation, and extra packages. ```bash ./configure.sh ``` ```out Enter desired app name or press return to have a name generated: Enter desired organization name or press return to use your personal org: Enter disk size in GB or press return for default 10GB: Use Docker on remote machine (y/n):y Any extra packages:clang htop make ``` -------------------------------- ### Install psycopg and django-environ with pip Source: https://github.com/superfly/docs/blob/main/unmanaged-postgres/connecting/app-connection-examples.mdx Installs the psycopg driver and django-environ package, which translates the DATABASE_URL environment variable into Django database configuration. ```bash python -m pip install psycopg django-environ ``` -------------------------------- ### Add start script to package.json Source: https://github.com/superfly/docs/blob/main/js/frameworks/svelte.mdx Insert `"start": "node build"` at the beginning of the `scripts` section in `package.json` to define the start command. ```json "scripts": { "start": "node build", ... } ``` -------------------------------- ### Install Fly CLI with install script Source: https://github.com/superfly/docs/blob/main/app-guides/run-a-private-dns-over-https-service.mdx Download and run the install script for other systems. ```bash curl -L https://fly.io/install.sh | sh ``` -------------------------------- ### Install Fly CLI and log in Source: https://github.com/superfly/docs/blob/main/getting-started/migrate-from-heroku.mdx Install the Fly CLI, sign up or log in to Fly, and ensure you're logged into Heroku before starting the migration. ```bash # Install Fly CLI curl -fsSL https://fly.io/install.sh | sh # Sign up / log in to Fly fly auth signup # or: fly auth login # Make sure you're logged into Heroku heroku login ``` -------------------------------- ### Clone a Machine with fly machine clone Source: https://github.com/superfly/docs/blob/main/blueprints/cell-based.mdx Command to create a second Machine after deploying the middleware change. Each Machine runs its own instance of the blog application with its own volume and sqlite3 database. ```bash fly machine clone ``` -------------------------------- ### Add pgx module dependency Source: https://github.com/superfly/docs/blob/main/unmanaged-postgres/connecting/app-connection-examples.mdx Install the pgx v4 module as a dependency for connecting to PostgreSQL from Go. ```bash go get github.com/jackc/pgx/v4 ``` -------------------------------- ### Options for fly agent start Source: https://github.com/superfly/docs/blob/main/flyctl/cmd/fly_agent_start.mdx Displays help for the start command. ```bash -h, --help help for start ``` -------------------------------- ### Clone the Arcjet example Next.js repository Source: https://github.com/superfly/docs/blob/main/security/arcjet.mdx Clone the example app from GitHub to get started with Arcjet on Fly.io. ```bash git clone git@github.com:arcjet/arcjet-example-nextjs-fly.git ``` -------------------------------- ### Install networking tools in Ubuntu Source: https://github.com/superfly/docs/blob/main/blueprints/private-applications-flycast.mdx Installs curl, iputils-ping, and dnsutils in the minimal Ubuntu image. ```bash # apt update && apt install -y curl iputils-ping dnsutils ``` -------------------------------- ### Install dependencies for debian/ubuntu-based images Source: https://github.com/superfly/docs/blob/main/litefs/getting-started-docker.mdx Add this line to your Dockerfile for debian/ubuntu-based images to install required packages: ca-certificates, fuse3, and sqlite3. ```dockerfile # for debian/ubuntu-based images RUN apt-get update -y && apt-get install -y ca-certificates fuse3 sqlite3 ``` -------------------------------- ### Install dependencies for alpine-based images Source: https://github.com/superfly/docs/blob/main/litefs/getting-started-docker.mdx Add this line to your Dockerfile for alpine-based images to install required packages: ca-certificates, fuse3, and sqlite. ```dockerfile # for alpine-based images RUN apk add ca-certificates fuse3 sqlite ``` -------------------------------- ### Set up the database Source: https://github.com/superfly/docs/blob/main/elixir/getting-started/legacy.mdx Run this command to create and set up the database for the Phoenix application. The output confirms the database for HelloElixir.Repo has been created. ```bash mix ecto.setup ``` ```output The database for HelloElixir.Repo has been created ``` -------------------------------- ### Clone the vscode-remote repository Source: https://github.com/superfly/docs/blob/main/app-guides/vscode-remote.mdx Clone the example repository to get the code for the remote development setup. ```bash git clone https://github.com/fly-examples/vscode-remote.git ``` -------------------------------- ### Initialize Prisma Source: https://github.com/superfly/docs/blob/main/unmanaged-postgres/connecting/app-connection-examples.mdx Initialize Prisma in your project. Creates a prisma folder, .env file, and schema.prisma file. ```bash npx prisma init ``` -------------------------------- ### Create startup script 1_storage_init.sh Source: https://github.com/superfly/docs/blob/main/laravel/the-basics/laravel-volume-storage.mdx Creates the startup script file .fly/scripts/1_storage_init.sh. Startup scripts run in numeric-alphabetical order, so the 1_ prefix ensures this runs before caches.sh. ```bash touch .fly/scripts/1_storage_init.sh ``` -------------------------------- ### Generic CI example: install, authenticate, and deploy Source: https://github.com/superfly/docs/blob/main/flyctl/integrating.mdx Complete setup for any CI system: install flyctl, set FLY_API_TOKEN from a CI secret, and deploy with --remote-only. Store your token as a secret in your CI provider. ```bash # Install curl -L https://fly.io/install.sh | sh export PATH="$HOME/.fly/bin:$PATH" # Authenticate via environment export FLY_API_TOKEN="$YOUR_CI_SECRET" # Deploy fly deploy --remote-only -a my-app ``` -------------------------------- ### Dockerfile for a simple Go app Source: https://github.com/superfly/docs/blob/main/app-guides/multiple-processes.mdx Base Dockerfile for the example Go app. It installs bash and curl, builds the Go code, and runs `tail -f /dev/null` as the default command. ```dockerfile FROM golang RUN apt-get update && \ apt-get install -y \ bash \ curl RUN mkdir /app WORKDIR /app ADD go.* *.go /app/ RUN go build CMD tail -f /dev/null ``` -------------------------------- ### Launch GitHub MCP server with GitHub CLI token Source: https://github.com/superfly/docs/blob/main/model-context-protocol/examples.mdx Requires GitHub CLI installed. Uses gh auth token for the personal access token secret. ```sh flyctl mcp launch --image ghcr.io/github/github-mcp-server \ --secret GITHUB_PERSONAL_ACCESS_TOKEN=$(gh auth token) \ --claude --server github --name git ``` -------------------------------- ### Initialize Sequelize into your project Source: https://github.com/superfly/docs/blob/main/unmanaged-postgres/connecting/app-connection-examples.mdx Initialize Sequelize into your project. This creates config, models, migrations, and seeders folders. ```bash npx sequelize init ``` -------------------------------- ### Test Rails app locally with Docker Compose Source: https://github.com/superfly/docs/blob/main/rails/getting-started/dockerfiles.mdx Run these commands to test your application locally before deploying. Requires Docker installed. Generates a compose setup, sets the master key, then builds and starts the containers. ```sh bin/rails generate dockerfile --compose ``` ```sh export RAILS_MASTER_KEY=$(cat config/master.key) ``` ```sh docker compose build ``` ```sh docker compose up ``` -------------------------------- ### Example response for Get Machine metadata Source: https://github.com/superfly/docs/blob/main/machines/api/machines-resource.mdx Example JSON response with status 200 OK, showing the metadata key-value pairs returned by the GET request. ```json { "fly_flyctl_version":"0.2.8", "fly_platform_version":"v2", "fly_process_group":"app", "fly_release_id":"Nj7oGMlVVpZ7JToybJoXLLjMl", "fly_release_version":"63" } ``` -------------------------------- ### fly launch command for go-fly-a-site Source: https://github.com/superfly/docs/blob/main/blueprints/using-base-images-for-faster-deployments.mdx Creates the app go-fly-a-site with a shared-cpu-1x VM and skips deployment. Output shows the app is ready for deployment. ```bash $ fly launch --name go-fly-a-site --vm-size shared-cpu-1x --no-deploy .... Your app is ready! Deploy with `flyctl deploy` ``` -------------------------------- ### Start Observer Source: https://github.com/superfly/docs/blob/main/elixir/advanced-guides/connect-observer-to-your-app.mdx Launches the Observer GUI. If it opens successfully, WxWidgets support is working. It won't be connected to anything else, but verifies that the libraries and dependencies are working. ```elixir :observer.start ``` -------------------------------- ### GET /v1/apps/{app_name} - Example response (200 OK) Source: https://github.com/superfly/docs/blob/main/machines/api/apps-resource.mdx Example JSON response for a successful GET request, showing app details such as id, name, status, and organization information. ```json { "id": "jlyv9r5d56v18xrg", "name": "my-app-name", "status": "pending", "organization": { "name": "My Org", "slug": "personal" } } ``` -------------------------------- ### Example output of lucky init Source: https://github.com/superfly/docs/blob/main/languages-and-frameworks/crystal.mdx Shows the interactive prompts and final instructions after running lucky init. The output lists next steps: cd into the project, check database settings, run script/setup, and run lucky dev. ```bash ✗ lucky init Welcome to Lucky v0.29.0 🎉 Project name?: hello-lucky Lucky can generate different types of projects Full (recommended for most apps) ● Great for server rendered HTML or Single Page Applications ● Webpack included ● Setup to compile CSS and JavaScript ● Support for rendering HTML API ● Specialized for use with just APIs ● No webpack ● No static file serving or public folder ● No HTML rendering folders API only or full support for HTML and Webpack? (api/full): full Lucky can be generated with email and password authentication ● Sign in and sign up ● Mixins for requiring sign in ● Password reset ● Token authentication for API endpoints ● Generated files can easily be removed/customized later Generate authentication? (y/n): y ----------------------- Done generating your Lucky project ▸ cd into hello-lucky ▸ check database settings in config/database.cr ▸ run script/setup ▸ run lucky dev to start the server ``` -------------------------------- ### Install WireGuard tools on Ubuntu Source: https://github.com/superfly/docs/blob/main/networking/private-networking.mdx Install `wireguard-tools` and `openresolv` on Ubuntu 18.04 to 22.04. Required if `wg-quick` is not installed. ```bash sudo apt install wireguard-tools openresolv ``` -------------------------------- ### Trivial entrypoint.sh for testing Source: https://github.com/superfly/docs/blob/main/machines/flyctl/fly-machine-run.mdx A simple entrypoint script that prints a message and then executes the passed arguments. The line 'Hello from my Fly Machine' should appear in the app's logs. ```bash #! /bin/bash echo "Hello from my Fly Machine" exec "$@" ``` -------------------------------- ### Check app status with fly status Source: https://github.com/superfly/docs/blob/main/getting-started/launch-demo.mdx Use the `fly status` command to get basic details about your deployed app, including name, owner, hostname, image, and Machine states. The example output shows two Machines in the ord (Chicago) region, one started and one stopped. ```bash fly status ``` ```output App Name = hellofly Owner = personal Hostname = hellofly.fly.dev Image = flyio/hellofly:latest Machines PROCESS ID VERSION REGION STATE ROLE CHECKS LAST UPDATED app 148e453b7d7289 1 ord started 2023-05-17T17:39:37Z app 5683d311c3228e 1 ord stopped 2023-05-17T17:38:44Z ``` -------------------------------- ### Query database with Prisma Client Source: https://github.com/superfly/docs/blob/main/unmanaged-postgres/connecting/app-connection-examples.mdx TypeScript example using Prisma Client to find posts and create a new post. ```typescript import { PrismaClient } from '@prisma/client' const prisma = new PrismaClient() async function main() { const posts = await prisma.post.findMany() const newPost = await prisma.post.create({ data: { title: 'PostgreSQL on Fly', content: 'https://fly.io/docs/reference/postgres' } }) } main() .catch((e) => { throw e }) .finally(async () => { await prisma.$disconnect() }) ``` -------------------------------- ### Start machine response (200) Source: https://github.com/superfly/docs/blob/main/snippets/reference/machines/start.mdx Example response with status 200 when the machine start request succeeds. The JSON body contains the previous state of the machine, which is "stopped". ```json { "previous_state": "stopped" } ``` -------------------------------- ### fly launch deployment output Source: https://github.com/superfly/docs/blob/main/getting-started/launch-demo.mdx Example output after confirming settings and deploying the app. It shows the created app, configuration validation, image build, IP provisioning, machine creation, and the URL to visit the deployed app. ```output Created app 'my-app-name' in organization 'personal' Admin URL: https://fly.io/apps/my-app-name Hostname: my-app-name.fly.dev Wrote config file fly.toml Validating /Users/username/my-app-dir/fly.toml Platform: machines ✓ Configuration is valid ==> Building image Searching for image 'flyio/hellofly:latest' remotely... image found: img_z1nr0lpjz9v5q98w Watch your deployment at https://fly.io/apps/my-app-name/monitoring Provisioning ips for my-app-name Dedicated ipv6: 2a09:8280:1::42:a8f4 Shared ipv4: 66.241.124.213 Add a dedicated ipv4 with: fly ips allocate-v4 This deployment will: * create 2 "app" machines No machines in group app, launching a new machine Creating a second machine to increase service availability Finished launching new machines ------- NOTE: The machines for [app] have services with 'auto_stop_machines = true' that will be stopped when idling ------- Visit your newly deployed app at https://my-app-name.fly.dev/ ``` -------------------------------- ### Start an existing machine Source: https://github.com/superfly/docs/blob/main/machines/guides-examples/functions-with-machines.mdx Starts an existing stopped Machine using its machine ID. Images stay cached after first launch, so starting is fast. The API call only succeeds if the machine is stopped; calling start on a running machine is safe but returns an error. Start operations clear filesystem changes. ```bash curl -i -X POST \ -H "Authorization: Bearer $FLY_API_TOKEN" \ "https://api.machines.dev/v1/apps/my-app-name/machines/10e286064b1867/start" ``` -------------------------------- ### Start Machine for the base image Source: https://github.com/superfly/docs/blob/main/blueprints/using-base-images-for-faster-deployments.mdx Start a specific Machine using its ID from the list command. ```bash fly machine start --config base.fly.toml ``` -------------------------------- ### Run Hermes setup wizard on Fly.io Source: https://github.com/superfly/docs/blob/main/blueprints/hermes-agent-on-fly-io.mdx Opens a shell on the machine and runs `hermes setup` to configure model selection, tools, and messaging platforms. After finishing, exit the SSH session. ```bash fly ssh console -a hermes setup ``` -------------------------------- ### Install cookie-parser for sticky sessions Source: https://github.com/superfly/docs/blob/main/js/frameworks/meteor.mdx Install the `cookie-parser` npm package, required for the sticky session middleware example that follows. ```bash npm install cookie-parser ``` -------------------------------- ### Create a new Poetry project Source: https://github.com/superfly/docs/blob/main/python/the-basics/initial-setup.mdx Use the `poetry new` command to create a new project with the specified app name. ```bash poetry new ``` -------------------------------- ### kubectl get ns output Source: https://github.com/superfly/docs/blob/main/kubernetes/clusters.mdx Example output from running kubectl get ns after connecting to the cluster over WireGuard. Shows the namespaces in the cluster. ```text > kubectl get ns NAME STATUS AGE kube-public Active 22d kube-node-lease Active 22d default Active 22d kube-system Active 22d ``` -------------------------------- ### Compile and run gRPC-Web client Source: https://github.com/superfly/docs/blob/main/app-guides/grpc-and-grpc-web-services.mdx Run these commands in the web-proxy folder to install dependencies, compile the client with webpack, and open the browser. The method responses are printed to the console. ```shell npm install npx webpack client.js open index.html ``` -------------------------------- ### Get Machine Details Response Source: https://github.com/superfly/docs/blob/main/snippets/reference/machines/get.mdx Example JSON response from the Get Machine Details API call. Shows the machine's state, region, private IP, configuration, image reference, and event history. ```json { "id": "d5683210c7968e", "name": "quirky-machine", "state": "stopped", "region": "cdg", "instance_id": "01G3GNA72484XS5D9SCRW8X79Q", "private_ip": "fdaa:0:3ec2:a7b:5adc:c12d:84b0:2", "config": { "env": null, "init": { "exec": null, "entrypoint": null, "cmd": null, "tty": false }, "image": "flyio/fastify-functions", "metadata": null, "restart": { "policy": "" }, "services": [ { "internal_port": 8080, "ports": [ { "handlers": [ "tls", "http" ], "port": 443 }, { "handlers": [ "http" ], "port": 80 } ], "protocol": "tcp" } ], "guest": { "cpu_kind": "shared", "cpus": 1, "memory_mb": 256 } }, "image_ref": { "registry": "registry-1.docker.io", "repository": "flyio/fastify-functions", "tag": "latest", "digest": "sha256:e15c11a07e1abbc50e252ac392a908140b199190ab08963b3b5dffc2e813d1e8", "labels": { } }, "created_at": "2022-05-20T11:58:13Z", "events": [ { "type": "exit", "status": "stopped", "request": { "exit_event": { "exit_code": 127, "exited_at": 1653047897299, "guest_exit_code": 0, "guest_signal": -1, "oom_killed": false, "requested_stop": false, "restarting": false, "signal": -1 }, "restart_count": 0 }, "source": "flyd", "timestamp": 1653047898717 }, { "type": "update", "status": "replacing", "source": "user", "timestamp": 1653047897200 }, { "type": "start", "status": "started", "source": "flyd", "timestamp": 1653047895247 }, { "type": "launch", "status": "created", "source": "user", "timestamp": 1653047893083 } ] } ``` -------------------------------- ### Run a Machine with --autostop and --autostart=false Source: https://github.com/superfly/docs/blob/main/machines/flyctl/fly-machine-run.mdx Use this command to create a new Machine that the Fly Proxy may stop when idle but will never restart. The --autostop flag enables autostop, while --autostart=false explicitly disables autostart. If multiple services are defined, the setting applies to all services. ```bash fly machine run nginx --port 80:80/tcp:http \ --port 443:80/tcp:http:tls \ --autostop \ --autostart=false ``` -------------------------------- ### Clone the hello-static repository Source: https://github.com/superfly/docs/blob/main/languages-and-frameworks/static.mdx Clone the example repository containing all files needed for the static site deployment. ```bash git clone https://github.com/fly-apps/hello-static ``` -------------------------------- ### Get app response (200) Source: https://github.com/superfly/docs/blob/main/snippets/reference/machines/get-app.mdx Example JSON response returned when the request succeeds. Contains the app name and organization information. ```json { "name": "my-app-name", "organization": { "name": "My Org", "slug": "personal" } } ``` -------------------------------- ### Initialize Fly app with fly.source.toml Source: https://github.com/superfly/docs/blob/main/app-guides/smokescreen.mdx Imports the supplied fly.source.toml to initialize the app. Replace smokescreen-example with your preferred app name or omit it to have Fly generate a name. You may be prompted for an organization; ensure it matches the organization of the apps whose external calls you want to manage. ```bash fly init smokescreen-example --import fly.source.toml ``` -------------------------------- ### Fly.io process configuration for startup script Source: https://github.com/superfly/docs/blob/main/js/prisma/sqlite.mdx Overrides the Dockerfile CMD in `fly.toml` to run a startup script. The `app` process runs `node dbsetup.js npm run start`. ```toml [processes] app = "node dbsetup.js npm run start" ``` -------------------------------- ### Start Machine response (Status: 200 OK) Source: https://github.com/superfly/docs/blob/main/machines/api/machines-resource.mdx Example response from the start Machine endpoint. Shows the previous state of the Machine, whether it was migrated, and the new host (empty when not migrated). ```json { "previous_state": "stopped", "migrated": false, "new_host": "" } ``` -------------------------------- ### Install WireGuard on Ubuntu Source: https://github.com/superfly/docs/blob/main/blueprints/bridge-deployments-wireguard.mdx Install WireGuard on an Ubuntu server using apt. Required before creating a WireGuard peer. ```docker sudo apt -y install wireguard ``` -------------------------------- ### Get SSH access to the base image Source: https://github.com/superfly/docs/blob/main/blueprints/using-base-images-for-faster-deployments.mdx Open an SSH console to the base image. Ensure the Machine is started before running. ```bash fly ssh console --config base.fly.toml ``` -------------------------------- ### Initialize a new Poetry project Source: https://github.com/superfly/docs/blob/main/python/frameworks/fastapi.mdx Create a new Python project with Poetry and navigate into it. ```bash poetry new fastapi-app cd fastapi-app ``` -------------------------------- ### flyctl apps create output: app creation summary Source: https://github.com/superfly/docs/blob/main/app-guides/run-a-global-image-service.mdx Example output after the organization is selected, showing the new app details and that the fly.toml file was written. ```output New app created Name = flyimaginary Owner = demo Version = 0 Status = Hostname = Wrote config file fly.toml ``` -------------------------------- ### Get deployments with kubectl Source: https://github.com/superfly/docs/blob/main/kubernetes/fks-quickstart.mdx List the deployments in the cluster. The output shows the nginx-deployment with 3 replicas ready. ```bash kubectl get deployments ``` ```output NAME READY UP-TO-DATE AVAILABLE AGE nginx-deployment 3/3 3 3 7s ``` -------------------------------- ### Example output of fly regions list Source: https://github.com/superfly/docs/blob/main/app-guides/planetscale.mdx Example output showing the region pool and backup region. ```text Region Pool: lhr Backup Region: ``` -------------------------------- ### Configure database connection in config/config.js Source: https://github.com/superfly/docs/blob/main/unmanaged-postgres/connecting/app-connection-examples.mdx Shows the CLI how to connect to the database. Includes development, test, and production environments with different dialects and credentials. ```javascript const fs = require('fs'); module.exports = { development: { username: 'database_dev', password: 'database_dev', database: 'database_dev', host: '127.0.0.1', port: 3306, dialect: 'mysql', dialectOptions: { bigNumberStrings: true } }, test: { username: process.env.CI_DB_USERNAME, password: process.env.CI_DB_PASSWORD, database: process.env.CI_DB_NAME, host: '127.0.0.1', port: 3306, dialect: 'postgres', dialectOptions: { bigNumberStrings: true } }, production: { database: process.env.DATABASE_URL, host: process.env.PROD_DB_HOSTNAME, dialect: 'postgres' } }; ``` -------------------------------- ### Output of kubectl get svc for ClusterIP Service Source: https://github.com/superfly/docs/blob/main/kubernetes/services.mdx Example output showing the fksdemo-service with a ClusterIP and no external IP. ```text NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE kubernetes ClusterIP fdaa:3:dde8:0:1::3a 443/TCP 32h fksdemo-service ClusterIP fdaa:3:dde8:0:1::3b 80/TCP 11s ``` -------------------------------- ### Create and enter the project folder Source: https://github.com/superfly/docs/blob/main/django/getting-started/index.mdx Creates a directory named hello-django and changes into it. Run this before setting up the virtual environment. ```bash mkdir hello-django && cd hello-django ``` -------------------------------- ### LiteFS proxy configuration in litefs.yml Source: https://github.com/superfly/docs/blob/main/litefs/getting-started-fly.mdx Configures the built-in proxy to handle write redirection and replica consistency. Requires GET requests to never perform writes and clients to have cookies enabled. The target should point to the application's port. ```yaml proxy: # Bind address for the proxy to listen on. addr: ":8080" # Hostport of your application - replace 8081 with whatever port # your application is listening on! target: "localhost:8081" # Filename of the SQLite database you want to use for TXID tracking. db: "my.db" ``` -------------------------------- ### Run Deno app Source: https://github.com/superfly/docs/blob/main/js/frameworks/deno.mdx Starts the Deno application with network access. Expected output: 'listening on http://0.0.0.0:8080/'. ```bash deno run --allow-net main.ts ``` ```output listening on http://0.0.0.0:8080/ ``` -------------------------------- ### Output of kubectl get svc for LoadBalancer Service Source: https://github.com/superfly/docs/blob/main/kubernetes/services.mdx Example output showing the fksdemo-service-public with a LoadBalancer type and external IP/domain. ```text NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE kubernetes ClusterIP fdaa:3:dde8:0:1::3a 443/TCP 32h fksdemo-service ClusterIP fdaa:3:dde8:0:1::3b 80/TCP 26m fksdemo-service-public LoadBalancer fdaa:3:dde8:0:1::3c fksdemo-service-public.svc.fks-default-vz5dlqz7v4ylrnpq.fly.dev,2a09:8280:1::31:ab8:0,137.66.25.254 80/TCP 8s ``` -------------------------------- ### Provisioning request example Source: https://github.com/superfly/docs/blob/main/reference/extensions_api.mdx Example of a provisioning request to the partner API. The request is a POST to the /extensions endpoint and includes required and optional parameters. The request must be signed with an X-Signature header containing the HMAC of the request body. ```javascript POST https://logjam.io/flyio/extensions { name: "test", id: "test", organization_id: "04La2mblTaz", organization_name: "High Flyers", user_email: "v9WvKokd@customer.fly.io", user_id: "NeBO2G0l0yJ6", user_role: "admin", primary_region: "mad", ip_address: "fdaa:0:47fb:0:1::1d", read_regions: ["syd", "scl"], url: "https://logjam.io/flyio/extensions", nonce: "e3f7b4c8f5ea016d0d2e92048ca0d856", timestamp: 1685641159 } ``` -------------------------------- ### Wipe config files and restart Source: https://github.com/superfly/docs/blob/main/blueprints/hermes-agent-on-fly-io.mdx Removes config.yaml and .env, restarts the machine, and runs hermes setup to start fresh while preserving skills, sessions, and memories. ```bash fly ssh console -a -C \ "sh -c 'rm -f /opt/data/config.yaml /opt/data/.env'" fly machine restart -a fly ssh console -a hermes setup ``` -------------------------------- ### Run the .NET application with dotnet run Source: https://github.com/superfly/docs/blob/main/languages-and-frameworks/dotnet.mdx Execute this command in the application folder to start the 'hellodotnet' app. The output shows the local listening address and hosting environment. ```bash dotnet run ``` ```output Building... Now listening on: http://localhost:5162 Application started. Press Ctrl+C to shut down. Hosting environment: Development ``` -------------------------------- ### Output of fly status -a testrun Source: https://github.com/superfly/docs/blob/main/machines/guides-examples/machines-app-using-flyctl.mdx Example output from the fly status command, showing the app details and the started machine. ```text App Name = testrun Owner = personal Hostname = testrun.fly.dev Platform = machines ID STATE REGION HEALTH CHECKS IMAGE CREATED UPDATED 21781160b41d89 started yyz testrun:deployment-01GMF1WS8C28CDDYAFBVHA8F0Q 2022-12-17T03:26:30Z 2022-12-17T03:26:32Z ``` -------------------------------- ### Initialize Fly app with fly init Source: https://github.com/superfly/docs/blob/main/app-guides/6pndemochat.mdx Creates a new Fly app with the chosen chat app name, using the example-fly.toml configuration file. ```bash fly init YOURAPPNAME --import example-fly.toml ``` -------------------------------- ### Apply nginx deployment with kubectl Source: https://github.com/superfly/docs/blob/main/kubernetes/fks-quickstart.mdx Apply the nginx deployment from the official Kubernetes examples URL. The output confirms the deployment was created. ```bash kubectl apply -f https://k8s.io/examples/controllers/nginx-deployment.yaml ``` ```output deployment.apps/nginx-deployment created ``` -------------------------------- ### Run a Machine with custom metadata Source: https://github.com/superfly/docs/blob/main/machines/flyctl/fly-machine-run.mdx Starts a Machine that the `fly deploy` command will manage as part of the `app` process group, replacing its image and config with what is set up in the working directory. Use the `--metadata` flag for each metadata key-value pair. ```bash fly machine run . --metadata fly_platform_version=v2 \ --metadata fly_process_group=app \ --metadata my_metadata=mineallmine ``` -------------------------------- ### Attach a Consul cluster to the Fly.io app Source: https://github.com/superfly/docs/blob/main/litefs/getting-started-fly.mdx Sets the FLY_CONSUL_URL secret for the app, providing the Consul cluster URL for lease configuration. ```sh fly consul attach ``` -------------------------------- ### Bring up WireGuard tunnel with wg-quick Source: https://github.com/superfly/docs/blob/main/networking/private-networking.mdx Run `wg-quick up` with the peer name (without .conf extension) to activate the tunnel. The output shows the commands executed to set up the interface and routes. ```bash wg-quick up mypeer ``` ```output [#] ip link add mypeer type wireguard [#] wg setconf mypeer /dev/fd/63 [#] ip -6 address add fdaa:0:4:a7b:ab6:0:a:102/120 dev mypeer [#] ip link set mtu 1420 up dev mypeer [#] resolvconf -a tun.mypeer -m 0 -x [#] ip -6 route add fdaa:0:4::/48 dev mypeer ``` -------------------------------- ### Create a Fly.io volume for LiteFS Source: https://github.com/superfly/docs/blob/main/litefs/getting-started-fly.mdx Creates a persistent volume named 'litefs' with a size of 10 GB, required for the data directory. ```sh fly volumes create litefs --size 10 ``` -------------------------------- ### Create .sequelizerc file Source: https://github.com/superfly/docs/blob/main/unmanaged-postgres/connecting/app-connection-examples.mdx Create a new file named `.sequelizerc` to allow the CLI to read your `config.js` file. ```javascript const path = require('path'); module.exports = { 'config': path.resolve('config', 'config.js') } ``` -------------------------------- ### fly services list output Source: https://github.com/superfly/docs/blob/main/apps/info.mdx Example output from `fly services list` showing the configured services with protocol, ports, and force HTTPS settings. ```out Services PROTOCOL PORTS FORCE HTTPS TCP 80 => 8080 [HTTP] True 443 => 8080 [TLS,HTTP] False ``` -------------------------------- ### Run Django migrations Source: https://github.com/superfly/docs/blob/main/django/getting-started/index.mdx Initializes the local database and sets up tables for Django's default apps. ```bash python manage.py migrate ``` -------------------------------- ### Get outbound IP via external service (curl) Source: https://github.com/superfly/docs/blob/main/networking/services.mdx Calls an external service to return the Machine's outbound IPv6 address. Requires curl to be installed on the Machine. ```bash curl text.ipv6.wtfismyip.com ``` ```out 2605:4c40:92:520a:0:8c93:3d8a:1 ``` -------------------------------- ### Get volume response (200 OK) Source: https://github.com/superfly/docs/blob/main/machines/api/volumes-resource.mdx Example JSON response for a successful GET request to retrieve a volume. Shows volume details such as ID, name, state, size, region, zone, encryption, attachment, creation timestamp, block information, filesystem type, snapshot retention, and backup settings. ```json { "id": "vvol_6r7ye90k98ynwk1r", "name": "disk", "state": "created", "size_gb": 3, "region": "yul", "zone": "09cd", "encrypted": true, "attached_machine_id": "6e8297dc244287", "attached_alloc_id": null, "created_at": "2023-09-01T19:47:14.774Z", "blocks": 768250, "block_size": 4096, "blocks_free": 768244, "blocks_avail": 730163, "fstype": "ext4", "snapshot_retention": 5, "auto_backup_enabled": true, "host_dedication_key": "" } ``` -------------------------------- ### Clone a Machine with a volume (example) Source: https://github.com/superfly/docs/blob/main/volumes/volume-manage.mdx Example of cloning a Machine and attaching a volume with a specific mount path. The destination mount path cannot be '/'. ```bash fly machine clone 148eddeef09789 --region yyz --attach-volume vol_8l524yj0ko347zmp:/data ``` -------------------------------- ### Serve statics from a Tigris bucket Source: https://github.com/superfly/docs/blob/main/reference/configuration.mdx Add a [[statics]] section with tigris_bucket to serve static files from a Tigris object storage bucket. Requests under url_prefix are served from files in the bucket under guest_path. The machine must be running; if autostart is enabled, it will be started for statics requests. ```toml [[statics]] guest_path = "/app/public" url_prefix = "/public" tigris_bucket = "my-bucket" ``` -------------------------------- ### LiteFS file system configuration Source: https://github.com/superfly/docs/blob/main/litefs/getting-started-docker.mdx Sets the mount directory for the application database and the internal data directory. The data directory must be on a persistent volume. ```yaml # This directory is where your application will access the database. fuse: dir: "/litefs" # This directory is where LiteFS will store internal data. # You must place this directory on a persistent volume. data: dir: "/var/lib/litefs" ``` -------------------------------- ### nginx Deployment YAML Source: https://github.com/superfly/docs/blob/main/kubernetes/fks-quickstart.mdx A simple Kubernetes Deployment example from the official Kubernetes documentation. It creates a ReplicaSet with 3 nginx pods using the nginx:1.14.2 image. ```yaml apiVersion: apps/v1 kind: Deployment metadata: name: nginx-deployment labels: app: nginx spec: replicas: 3 selector: matchLabels: app: nginx template: metadata: labels: app: nginx spec: containers: - name: nginx image: nginx:1.14.2 ports: - containerPort: 80 ``` -------------------------------- ### GET /extensions/{extension_id}/sso Source: https://github.com/superfly/docs/blob/main/reference/extensions_api.mdx Initiates the Single Sign-On flow for a customer. If the user is already logged in, redirects to the extension detail screen; otherwise, starts an OAuth authorization request to Fly.io. ```APIDOC ## GET /extensions/{extension_id}/sso ### Description Initiates the Single Sign-On flow for a customer. If the user is already logged in, redirects to the extension detail screen; otherwise, starts an OAuth authorization request to Fly.io. ### Method GET ### Endpoint {base_url}/extensions/{extension_id}/sso ### Parameters #### Path Parameters - **extension_id** (string) - Required - The unique identifier of the extension. ### Response #### Success Response (302) - **Location** (string) - Redirect URL to the extension detail screen or to the Fly.io OAuth authorization endpoint. ``` -------------------------------- ### Reset configuration and restart Source: https://github.com/superfly/docs/blob/main/blueprints/deploy-openclaw.mdx SSH into the Machine, remove the OpenClaw config file, exit, and restart the app to start fresh. Alternatively, use the 'Reset' button in the setup wizard. ```bash fly ssh console -a your-app-name rm /data/openclaw.json exit fly apps restart your-app-name ``` -------------------------------- ### Launch Filesystem MCP server with volume (Go) Source: https://github.com/superfly/docs/blob/main/model-context-protocol/examples.mdx Alternative using the Go mcp-filesystem-server. Same volume configuration as the Node version. ```sh fly mcp launch "go run github.com/mark3labs/mcp-filesystem-server@latest /data/" \ --claude --server volume --volume data:/data:initial_size=1GB ``` -------------------------------- ### Clone and launch the <%= repo %> template Source: https://github.com/superfly/docs/blob/main/snippets/python/speedrun.mdx Use the Fly.io template to quickly deploy a basic server. Run these commands in order: clone the repository, change into the app directory, and launch with a generated name. ```bash git clone git@github.com:fly-apps/<%= repo %>.git <%= runtime.downcase %>-app cd <%= runtime.downcase %>-app fly launch --generate-name ``` -------------------------------- ### Launch Slack MCP server with secrets Source: https://github.com/superfly/docs/blob/main/model-context-protocol/examples.mdx Requires a Bot User OAuth Token and Team ID from Slack setup. Secrets are passed via --secret flags. ```sh fly mcp launch \ "npx -y @modelcontextprotocol/server-slack" \ --claude --server slack \ --secret SLACK_BOT_TOKEN=xoxb-your-bot-token \ --secret SLACK_TEAM_ID=T01234567 ``` -------------------------------- ### GET /v1/apps/{app_name}/machines/{machine_id}/wait Source: https://github.com/superfly/docs/blob/main/machines/api/machines-resource.mdx Waits for a Machine to reach a specified state. Use this endpoint to block until the Machine transitions to the desired state, such as started, stopped, suspended, or destroyed. ```APIDOC ## [GET] /v1/apps/{app_name}/machines/{machine_id}/wait ### Description Waits for a Machine to reach a specified state. Use this endpoint to block until the Machine transitions to the desired state, such as started, stopped, suspended, or destroyed. ### Method GET ### Endpoint /v1/apps/{app_name}/machines/{machine_id}/wait ### Parameters #### Path Parameters - **app_name** (string) - Required - The name of the Fly App the Machine belongs to. - **machine_id** (string) - Required - The ID of the Machine to wait for. #### Query Parameters - **instance_id** (string) - Optional - Filter for a specific Machine `instance_id` (version). Required when waiting for Machine to be in `stopped` state. - **timeout** (integer) - Optional - The time, in seconds, to wait for the Machine to enter the specified state. Default is 60. - **state** (string enum) - Optional - The Machine state to wait for. Values are: `started`, `stopped`, `suspended`, or `destroyed`. Default is `started`. ### Request Example ```sh curl -i -X GET \ -H "Authorization: Bearer ${FLY_API_TOKEN}" -H "Content-Type: application/json" \ "${FLY_API_HOSTNAME}/v1/apps/my-app-name/machines/73d8d46dbee589/wait?state=stopped&instance_id=01HMVXC16ED6SHK9452AF029Y7" ``` ### Response #### Success Response (200) - **ok** (boolean) - Indicates the request was successful. #### Response Example ```json { "ok": true } ``` ``` -------------------------------- ### Example app Machine distribution after scaling Source: https://github.com/superfly/docs/blob/main/launch/scale-count.mdx Shows the resulting Machine distribution after applying --max-per-region 5. Output displays 3 in ewr, 3 in yul, 5 in yyz. ```text NAME COUNT KIND CPUS MEMORY REGIONS app 11 shared 1 256 MB ewr(3),yul(3),yyz(5) ``` -------------------------------- ### Connect to Redis database with fly redis connect Source: https://github.com/superfly/docs/blob/main/upstash/redis.mdx Connects to a Redis database via a local proxy and opens an interactive redis-cli session. The example shows setting and getting a key. ```bash fly redis connect ? Select a database to connect to empty-water-3291 (sjc) 200M Proxying local port 16379 to remote [fdaa:0:6d6b:0:1::3]:6379 127.0.0.1:16379> set foo bar OK 127.0.0.1:16379> get foo "bar" 127.0.0.1:16379> ``` -------------------------------- ### Nginx Rate Limiting Configuration Source: https://github.com/superfly/docs/blob/main/machines/guides-examples/multi-container-machines.mdx The nginx configuration that is base64-encoded in the rate limiter sidecar example. It defines a rate limit zone and applies it to all requests, proxying them to localhost:80. This file is written to /etc/nginx/conf.d/default.conf when the container starts. ```nginx limit_req_zone $binary_remote_addr zone=my_zone:10m rate=1r/s; server { listen 8080; location / { limit_req zone=my_zone; proxy_pass http://localhost:80; } } ``` -------------------------------- ### Create snapshot-enabled bucket and take snapshot and fork Source: https://github.com/superfly/docs/blob/main/tigris/index.mdx Creates a new bucket with the --enable-snapshots flag, takes a snapshot, and creates a fork. Snapshots cannot be enabled on existing buckets, so create a new bucket first. ```bash tigris buckets create my-bucket --enable-snapshots tigris snapshots take my-bucket tigris forks create my-bucket my-fork ``` -------------------------------- ### Interact with LiteFS mount using sqlite3 CLI Source: https://github.com/superfly/docs/blob/main/litefs/getting-started-docker.mdx Use the `sqlite3` CLI to interact with databases on the LiteFS mount directory. LiteFS only allows files in the root of the mount and does not support subdirectories. ```text sqlite3 /litefs/my.db ``` -------------------------------- ### Introspect database with Prisma Source: https://github.com/superfly/docs/blob/main/unmanaged-postgres/connecting/app-connection-examples.mdx Generate models in schema.prisma by introspecting an existing database. ```bash npx prisma db pull ``` -------------------------------- ### LiteFS static lease configuration for primary node Source: https://github.com/superfly/docs/blob/main/litefs/getting-started-docker.mdx Configures a static lease for the primary node. Set `lease.candidate: true` on the primary and `false` on replicas. Replace `primary` with the actual hostname. ```yaml lease: # Required. Must be either "consul" or "static". type: "static" # Required. The URL for the primary node's LiteFS API. # Note: replace `primary` with the appropriate hostname for your primary node! advertise-url: "http://primary:20202" # Specifies whether the node can become the primary. If using # "static" leasing, this should be set to true on the primary # and false on the replicas. # Note: update this to `false` on the replica nodes! candidate: true ``` -------------------------------- ### Initialize the Fly app with fly init --import fly.source.toml Source: https://github.com/superfly/docs/blob/main/app-guides/postgres.mdx Run this command to create your fly.toml file by importing the template from the repository. You will be prompted for an app name and organization; you can hit return to generate an app name when asked. ```bash fly init --import fly.source.toml ```