### Setup and Run Lucky Development Server Source: https://fly.io/docs/languages-and-frameworks/crystal Execute `script/setup` to install dependencies and create the database, then run `lucky dev` to start the local development server. ```bash script/setup ``` ```bash lucky dev ``` -------------------------------- ### Lucky App Project Setup Source: https://fly.io/docs/languages-and-frameworks/crystal After creating a Lucky project, navigate into the project directory, set up database configurations, install dependencies, and start the development server. ```bash cd hello-lucky check database settings in config/database.cr run script/setup run lucky dev to start the server ``` -------------------------------- ### Post-Deploy App Details Source: https://fly.io/docs/blueprints/deploy-openclaw Example output after a successful deployment, showing the App URL, Setup wizard URL, Gateway URL, and Gateway token. ```text === Deployment Complete === App URL: https://your-app-name.fly.dev Setup wizard: https://your-app-name.fly.dev/setup Gateway URL: wss://your-app-name.fly.dev Gateway token: ``` -------------------------------- ### Example Dockerfile with CUDA Samples Source: https://fly.io/docs/gpus/gpu-quickstart A multi-stage Dockerfile example that installs CUDA, clones NVIDIA's CUDA samples, builds the `deviceQuery` utility, and prepares a runtime image. ```dockerfile FROM ubuntu:22.04 as base RUN apt update -q && apt install -y ca-certificates wget && \ wget -qO /cuda-keyring.deb https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2204/x86_64/cuda-keyring_1.1-1_all.deb && \ dpkg -i /cuda-keyring.deb && apt update -q FROM base as builder RUN apt install -y --no-install-recommends git cuda-nvcc-12-2 RUN git clone --depth=1 https://github.com/nvidia/cuda-samples.git /cuda-samples RUN cd /cuda-samples/Samples/1_Utilities/deviceQuery && \ make && install -m 755 deviceQuery /usr/local/bin FROM base as runtime #RUN apt install -y --no-install-recommends libcudnn8 libcublas-12-2 COPY --from=builder /usr/local/bin/deviceQuery /usr/local/bin/deviceQuery CMD ["sleep", "inf"] ``` -------------------------------- ### Fly.toml Process Configuration for Node.js Source: https://fly.io/docs/js/prisma/sqlite If you have a pre-existing Dockerfile, `fly launch` overrides the CMD in `fly.toml` to run a startup script. This example shows how the `app` process is configured to run a setup script and then start the Node.js application. ```toml [processes] app = "node dbsetup.js npm run start" ``` -------------------------------- ### Generic CI Deployment Example Source: https://fly.io/docs/flyctl/integrating A general example for deploying applications in CI systems. It includes installing flyctl, authenticating using the FLY_API_TOKEN environment variable, and performing a remote deployment. ```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 Initial App Deployment Source: https://fly.io/docs/blueprints/using-base-images-for-faster-deployments This Dockerfile sets up a Debian 12 environment, installs Go, copies the Go server code, compiles it, and sets the command to run the compiled binary. It's used for the initial deployment of the example application. ```dockerfile FROM debian:12 # Install Go RUN apt-get update; apt-get upgrade; apt-get -y install golang # Copy the code for our server to /opt/main.go COPY main.go /opt/main.go # Build /opt/server from the code in /opt/main.go RUN go build -o /opt/server /opt/main.go # Run our code from main.go as /opt/server CMD [ "/opt/server" ] ``` -------------------------------- ### Test Cold Start by Stopping and Starting a Machine Source: https://fly.io/docs/reference/suspend-resume Simulate a cold start scenario by manually stopping and then starting a machine. This helps in testing recovery and startup procedures. ```bash fly machine stop fly machine start ``` -------------------------------- ### Configure 'start' command in package.json Source: https://fly.io/docs/js/frameworks/svelte Add a 'start' script to your package.json file. This script is used by Fly.io to start your application after deployment. ```json "scripts": { "start": "node build", ... } ``` -------------------------------- ### Clone Example Repository Source: https://fly.io/docs/languages-and-frameworks/static Use this command to clone the 'hello-static' GitHub repository to your local machine. This repository contains all the necessary files for the demonstration. ```cmd git clone https://github.com/fly-apps/hello-static ``` -------------------------------- ### Install flyctl Source: https://fly.io/docs/mcp Guides presume flyctl is installed. Install it following the official documentation. ```bash flyctl installed ``` -------------------------------- ### Fly Launch Output Example Source: https://fly.io/docs/reference/fly-launch This output shows the typical process of creating a new Fly App, including app creation, image building, resource provisioning, and initial deployment. It highlights the creation of machines and notes the autostop feature. ```bash Waiting for launch data... Done Created app 'hello-gunicorn-flask' in organization 'personal' Admin URL: https://fly.io/apps/hello-gunicorn-flask Hostname: hello-gunicorn-flask.fly.dev Wrote config file fly.toml Validating /Users/chris/FlyTests/hello-gunicorn-flask/fly.toml Platform: machines ✓ Configuration is valid ==> Building image Remote builder fly-builder-long-glitter-7257 ready ==> Building image with Docker ... --> Pushing image done image: registry.fly.io/hello-gunicorn-flask:deployment-01HGEDDH0R7T762T90B45GZRWP image size: 141 MB Watch your deployment at https://fly.io/apps/hello-gunicorn-flask/monitoring Provisioning ips for hello-gunicorn-flask Dedicated ipv6: 2a09:5789:1::4e:b68c Shared ipv4: 66.333.124.86 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://hello-gunicorn-flask.fly.dev/ ``` ```bash The first deployment has finished! I haven't explicitly configured [process groups](/docs/apps/processes/), so my app gets two Machines assigned to the default `app` process. With `fly status`, I can see the Machines: ``` ```bash fly status ``` ```bash App Name = hello-gunicorn-flask Owner = personal Hostname = hello-gunicorn-flask.fly.dev Image = hello-gunicorn-flask:deployment-01HGEDDH0R7T762T90B45GZRWP Platform = machines Machines PROCESS ID VERSION REGION STATE ROLE CHECKS LAST UPDATED app 918543b477de83 1 ewr stopped 2023-11-29T21:17:19Z app e28697ce6d3986 1 ewr stopped 2023-11-29T20:55:33Z ``` -------------------------------- ### Example Response for Get Machine Metadata Source: https://fly.io/docs/machines/api/machines-resource An example of the JSON response when retrieving metadata for a Fly Machine. ```json { "fly_flyctl_version":"0.2.8", "fly_platform_version":"v2", "fly_process_group":"app", "fly_release_id":"Nj7oGMlVVpZ7JToybJoXLLjMl", "fly_release_version":"63" } ``` -------------------------------- ### Clone the Example Repository Source: https://fly.io/docs/gpus/python-gpu-example Clone the provided Python GPU example repository to your local machine and navigate into the directory. This sets up the project structure for deployment. ```cmd git clone git@github.com:fly-apps/python_gpu_example.git && cd python_gpu_example ``` -------------------------------- ### Example Response for Get Machine Source: https://fly.io/docs/machines/api/machines-resource An example JSON response when successfully retrieving details for a Fly Machine. ```json { "id": "a5c5de9ce64ca12", "name": "aged-wind-2649", "state": "started", "region": "ord", "image_ref": { "registry": "registry-1.docker.io", "repository": "rebelthor/sleep", "tag": "latest", "digest": "sha256:597c3e12f830132be2aa69b4c0deccb0657ea4253e6d59c6f38e41e9f69a0add" }, "instance_id": "1RREBN3T5K95DK9IVP4XHTTPEY2", "private_ip": "fdaa:0:18:a7b:196:e274:9ce1:2", "created_at": "2023-10-31T02:30:10Z", "updated_at": "2023-10-31T02:35:26Z", "config": { /* Fly Machine Config */ }, "events": [ { "type": "start", "status": "started", "source": "flyd", "timestamp": 1698719726615 }, { "type": "launch", "status": "created", "source": "user", "timestamp": 1698719723203 } ] } ``` -------------------------------- ### Example Response for Get Volume Source: https://fly.io/docs/machines/api/volumes-resource This is an example JSON response when successfully retrieving details for a specific volume. ```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": "" } ``` -------------------------------- ### Lucky Project Initialization Prompts Source: https://fly.io/docs/languages-and-frameworks/crystal Example output of the `lucky init` command, showing the prompts for project name, type (full or API), and authentication. ```text ✗ 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 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 ``` -------------------------------- ### Create Storage Initialization Script Source: https://fly.io/docs/laravel/the-basics/laravel-volume-storage Create a startup script named `1_storage_init.sh` in the `.fly/scripts/` directory. The numeric prefix ensures it runs before other scripts. ```bash touch .fly/scripts/1_storage_init.sh ``` -------------------------------- ### Install WireGuard Tools on Ubuntu Source: https://fly.io/docs/networking/private-networking On Ubuntu systems, ensure you have `wireguard-tools` and `openresolv` installed before proceeding with the WireGuard setup. ```bash sudo apt install wireguard-tools openresolv ``` -------------------------------- ### View Certificate Setup Options Source: https://fly.io/docs/app-guides/custom-domains-with-fly This command displays all available setup options for your domain's certificate, including DNS configuration details. It's helpful for understanding the necessary DNS records. ```bash fly certs setup ``` -------------------------------- ### Run Hermes Agent Setup Wizard Source: https://fly.io/docs/blueprints/hermes-agent-on-fly-io Execute the Hermes setup wizard via SSH to configure model selection, tools, and messaging platform connections. This interactive wizard guides the user through essential setup steps. ```bash fly ssh console -a hermes setup ``` -------------------------------- ### Example Flyctl Deploy Output Source: https://fly.io/docs/languages-and-frameworks/static This is an example of the expected output after a successful `flyctl deploy` command. It indicates that the app configuration is valid and the image build process has started. ```bash ==> Verifying app config Validating /Users/jphenow/workspace/hello-static/fly.toml ✓ Configuration is valid --> Verified app config ==> Building image Remote builder fly-builder-little-haze-7293 ready Remote builder fly-builder-little-haze-7293 ready ==> Building image with Docker --> docker host: 24.0.7 linux x86_64 [+] Building 0.4s (7/7) FINISHED ``` -------------------------------- ### Navigate and Launch App Source: https://fly.io/docs/languages-and-frameworks/crystal Navigate to your project directory and run the `fly launch` command to start the app deployment process. ```bash cd hello-lucky fly launch ``` -------------------------------- ### Start Livebook Server Source: https://fly.io/docs/elixir/advanced-guides/interesting-things-with-livebook Start the Livebook server from your project's root directory in the terminal. This command initiates the Livebook environment, allowing you to create and manage notebooks. ```bash livebook server ``` -------------------------------- ### Update Dockerfile for PostgreSQL Client Source: https://fly.io/docs/laravel/database-guides/laravel-pgsql Modify your application's `Dockerfile` to install a compatible PostgreSQL client version. This example installs version 14 client, ensuring compatibility with the server. ```dockerfile # Install pgsql client for version 14 RUN ...other stuff here... \ && apt-get -q install -y lsb-release wget \ && echo "deb http://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list \ && wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | apt-key add - \ && apt-get -q update \ && apt-get -q install -y postgresql-client-14 ``` -------------------------------- ### Output of Remix App Generation Source: https://fly.io/docs/js/frameworks/remix This output shows the process of creating a new Remix app, including package installation and project setup. It confirms dependencies are installed and a Git repository is initialized. ```output Need to install the following packages: create-remix@2.10.0 Ok to proceed? (y) y remix v2.10.0 💿 Let's build a better website... dir Where should we create your new project? ./my-remix-app ◼ Using basic template See https://remix.run/guides/templates for more ✔ Template copied git Initialize a new git repository? Yes deps Install dependencies with npm? Yes ✔ Dependencies installed ✔ Git initialized done That's it! Enter your project directory using cd ./my-remix-app Check out README.md for development and deploy instructions. Join the community at https://rmx.as/discord ... ``` -------------------------------- ### Go Web Server Example Source: https://fly.io/docs/blueprints/using-base-images-for-faster-deployments A simple Go program that listens on port 8080 and responds with 'Hello, world!'. This serves as the application logic for the base image. ```go package main import ( "fmt" "net/http" ) func main() { http.HandleFunc("/", HelloServer) http.ListenAndServe(":8080", nil) } func HelloServer(w http.ResponseWriter, r *http.Request) { fmt.Fprint(w, "Hello, world!\r\n") } ``` -------------------------------- ### Observer script output example Source: https://fly.io/docs/elixir/advanced-guides/connect-observer-to-your-app This is an example of the output you might see when the `observer` script successfully connects to a remote node and starts an IEx session. It shows connection details and the interactive Elixir prompt. ```text Attempting to connect to hello-elixir-01HR8CXEYKQ9RXYQFEWSE5PTE0@fdaa:0:1da8:a7b:a160:73d2:f48b:2 Erlang/OTP 26 [erts-14.2.2] [source] [64-bit] [smp:4:4] [ds:4:4:10] [async-threads:1] [jit] Node Connected?: true Connected Nodes: [:"hello-elixir-01HR8CXEYKQ9RXYQFEWSE5PTE0@fdaa:0:1da8:a7b:a160:73d2:f48b:2"] ... Interactive Elixir (1.16.1) - press Ctrl+C to exit (type h() ENTER for help) ``` -------------------------------- ### Fly.io deployment output example Source: https://fly.io/docs/rust/frameworks/dioxus-liveview This output shows the typical process and information displayed when launching a new application on Fly.io, including app details, build process, and deployment confirmation. ```text Scanning source code Detected a Dioxus Liveview app Warning: This organization has no payment method, turning off high availability Creating app in [redacted]/dioxus-liveview-on-fly We're about to launch your app on Fly.io. Here's what you're getting: Organization: Your Name (fly launch defaults to the personal org) Name: [app-name] (derived from your directory name) Region: Amsterdam, Netherlands (this is the fastest region for you) App Machines: shared-cpu-1x, 1GB RAM (most apps need about 1GB of RAM) Postgres: (not requested) Redis: (not requested) Sentry: false (not requested) ... ==> Building image ... ==> Building image with Docker ... Watch your deployment at https://fly.io/apps/[app-name]/monitoring ... Visit your newly deployed app at https://[app-name].fly.dev/ ``` -------------------------------- ### Restore Dockerfile CMD for Rails Server Source: https://fly.io/docs/rails/cookbooks/databases Restores the default command in the Dockerfile to start the Rails server after database setup. ```dockerfile CMD bin/rails server ``` -------------------------------- ### Dockerfile for a Multi-Process Application Source: https://fly.io/docs/app-guides/multiple-processes A sample Dockerfile that sets up a Go environment, installs necessary tools, and prepares an application directory. The CMD is set to `tail -f /dev/null` to keep the container running. ```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 ``` -------------------------------- ### Flyctl Auth Login Command Source: https://fly.io/docs/flyctl/auth Logs in a user to the Fly.io platform. This is the primary command to start using flyctl after installation if you have an existing account. ```bash fly auth login ``` -------------------------------- ### Building Image with Depot.dev Source: https://fly.io/docs/flyctl/machine-run Use the '--build-depot' flag to build your image with depot.dev. ```bash fly machine run --build-depot ``` -------------------------------- ### Example Multi-container Machine Configuration Source: https://fly.io/docs/machines/guides-examples/multi-container-machines This JSON configuration defines two containers: `my-app` and `log-shipper`. The `log-shipper` depends on `my-app` being healthy before it starts. ```json { "containers": [ { "name": "my-app", "image": "registry.fly.io/my-app:latest", "env": { "PORT": "8080" }, "healthchecks": [ { "http": { "port": 8080, "method": "GET", "path": "/health", "scheme": "http" }, "interval": 10, "timeout": 5, "grace_period": 5, "success_threshold": 2, "failure_threshold": 3 } ] }, { "name": "log-shipper", "image": "registry.fly.io/log-shipper:latest", "env": { "LOG_LEVEL": "info" }, "depends_on": [ { "name": "my-app", "condition": "healthy" } ] } ] } ``` -------------------------------- ### Go Web Server Example Source: https://fly.io/docs/blueprints/using-base-images-for-faster-deployments A simple Go program that listens on port 8080 and responds with 'Hello, world!'. This is used as the application logic for the base image example. ```go package main import ( "fmt" "net/http" ) func main() { http.HandleFunc("/", HelloServer) http.ListenAndServe(":8080", nil) } func HelloServer(w http.ResponseWriter, r *http.Request) { fmt.Fprint(w, "Hello, world!\r\n") } ``` -------------------------------- ### Procfile for Fly.io Source: https://fly.io/docs/blueprints/shared-nothing A Procfile defines the commands that will be executed to start processes within a Fly.io application. This example shows how to define a web process. ```yaml web: bundle exec puma -C config/puma.rb ``` -------------------------------- ### Django app launch example Source: https://fly.io/docs/launch/create Example of running `fly launch` in a directory with a Django app. The scanner detects the framework and provides a summary of the proposed app configuration before proceeding. ```bash fly launch ``` ```text Scanning source code Detected a Django app Creating app in /flyio/hello-django We're about to launch your Django app on Fly.io. Here's what you're getting: Organization: MyName (fly launch defaults to the personal org) Name: hello-django (derived from your directory name) Region: Amsterdam, Netherlands (this is the fastest region for you) App Machines: shared-cpu-1x, 1GB RAM (most apps need about 1GB of RAM) Postgres: (not requested) Redis: (not requested) ? Do you want to tweak these settings before proceeding? Yes ... ``` -------------------------------- ### Example Dockerfile for Compose Deployment Source: https://fly.io/docs/machines/guides-examples/multi-container-machines A simple Dockerfile using the `nginxdemos/hello` image, suitable for a web service in a Docker Compose setup on Fly.io. ```dockerfile FROM nginxdemos/hello:plain-text ``` -------------------------------- ### Initialize Release Environment Source: https://fly.io/docs/app-guides/elixir-static-cookie Run this command to create the necessary release configuration files if they don't exist. ```bash mix release.init ``` -------------------------------- ### Reset OpenClaw configuration Source: https://fly.io/docs/blueprints/deploy-openclaw To start fresh, use the 'Reset' button in the setup wizard or SSH in and remove the configuration file, then restart the application. ```bash fly ssh console -a your-app-name rm /data/openclaw.json exit fly apps restart your-app-name ``` -------------------------------- ### Rails Dockerfile with Action Cable and Active Record Example Source: https://fly.io/docs/rails/cookbooks/databases This enhanced Dockerfile demonstrates a full Rails application setup for Action Cable and Active Record. It includes generating a model and channel, setting up controllers, views, and routing for a visitor counter example. ```dockerfile #syntax = docker/dockerfile:1 FROM ruby:slim as build RUN apt-get update &&\ apt-get install --yes build-essential git pkg-config redis RUN gem install rails RUN rails new demo --css tailwind FROM ruby:slim COPY --from=build /demo /demo COPY --from=build /usr/local/bundle /usr/local/bundle WORKDIR demo RUN bin/rails generate model Visitor counter:integer &&\ bin/rails generate channel counter COPY <<-"EOF" app/controllers/visitors_controller.rb class VisitorsController < ApplicationController def counter @visitor = Visitor.find_or_create_by(id: 1) @visitor.update! counter: @visitor.counter.to_i + 1 @visitor.broadcast_replace_later_to 'counter', partial: 'visitors/counter' end end EOF COPY <<-"EOF" app/views/visitors/counter.html.erb <%= turbo_stream_from 'counter' %>
The monochrome white Fly.io brandmark on a navy background
<%= render "counter", visitor: @visitor %>
EOF COPY <<-"EOF" app/views/visitors/_counter.html.erb <%= turbo_frame_tag(dom_id visitor) do %> <%= visitor.counter.to_i %> <% end %> EOF COPY <<-"EOF" config/routes.rb Rails.application.routes.draw { root "visitors#counter" } EOF ENV RAILS_ENV=production RUN bin/rails assets:precompile RUN bin/rails db:prepare EXPOSE 3000 ENV RAILS_LOG_TO_STDOUT=true ENV RAILS_SERVE_STATIC_FILES=true CMD bin/rails server ``` -------------------------------- ### Create Storage Initialization Startup Script Source: https://fly.io/docs/laravel/the-basics/laravel-volume-storage Create a startup script to initialize the volumized storage folder's contents. Naming the script with a numeric prefix ensures it runs in the correct order. ```bash FOLDER=/var/www/html/storage/app if [ ! -d "$FOLDER" ]; then echo "$FOLDER is not a directory, copying storage_ content to storage" cp -r /var/www/html/storage_/. echo "deleting storage_..." rm -rf /var/www/html/storage_ fi ``` -------------------------------- ### Prepare Demo Database at Build Time Source: https://fly.io/docs/blueprints/shared-nothing This Dockerfile snippet demonstrates preparing a demo database during the image build process. This optimization reduces the startup time for new application instances. ```dockerfile RUN bin/rails db:prepare ``` -------------------------------- ### Puma Server Output Source: https://fly.io/docs/languages-and-frameworks/ruby Example output when the Puma web server starts. It indicates the version, thread settings, environment, PID, and listening addresses. ```text Puma starting in single mode... * Puma version: 6.1.1 (ruby 3.2.1-p31) ("The Way Up") * Min threads: 0 * Max threads: 5 * Environment: development * PID: 26873 * Listening on http://127.0.0.1:9292 * Listening on http://[::1]:9292 Use Ctrl-C to stop ``` -------------------------------- ### Launch Demo Application Source: https://fly.io/docs/js/the-basics/object-storage Launch the `node-dictaphone` demo application, which demonstrates capturing audio and uploading it to a Tigris bucket. This command clones the repository and sets up the application. ```cmd fly launch --from https://github.com/fly-apps/node-dictaphone.git ``` -------------------------------- ### Query All App Machines' 6PN Addresses Source: https://fly.io/docs/networking/private-networking Query for the AAAA records of all started Machines within an app to get their 6PN (6-Planar Network) addresses. ```bash dig +short aaaa my-app-name.internal ``` -------------------------------- ### Example Deployment Output Source: https://fly.io/docs/launch/deploy This output shows a successful deployment using the canary strategy, including image searching, machine creation, and updates. ```text ... ==> Building image Searching for image 'flyio/hellofly:latest' remotely... image found: img_z1nr0lpjz9v5q98w Watch your app at https://fly.io/apps/aged-water-8803/monitoring Creating canary machine for group app Machine 328745da023e85 [app] update finished: success Canary machines successfully created and healthy, destroying before continuing machine 328745da023e85 was found and is currently in created state, attempting to destroy... Updating existing machines in 'example-app-8803' with canary strategy [1/2] Machine 3287457df77785 [app] update finished: success [2/2] Machine 91857266c41638 [app] update finished: success Finished deploying ... ``` -------------------------------- ### Get Machine Lease Response Source: https://fly.io/docs/machines/api/machines-resource Example response when a machine lease is successfully created or retrieved. The `nonce` is crucial for subsequent operations requiring the lease. ```json { "status": "success", "data": { "nonce": "5c35f65c9f95", "expires_at": 1708569778, "owner": "hello@fly.io", "description": "", "version": "01HQ73A7BFFDF1B6WMGHFZZ4E7" } } ``` -------------------------------- ### Configure `start` command in package.json Source: https://fly.io/docs/js/frameworks/svelte Add a `start` script to your `package.json` file. This script is used by deployment platforms to run your application, typically by executing the built Node.js server. ```json "scripts": { "start": "node build", ... } ``` -------------------------------- ### Example Files Configuration Source: https://fly.io/docs/machines/api-machines-resource Configures two files to be written into the Machine. One uses raw base64 encoded content, and the other references a secret name. ```json "files": [ { "guest_path": "/path/to/hello.txt", "raw_value": "aGVsbG8gd29ybGQK" }, { "guest_path": "/path/to/secret.txt", "secret_name": "SUPER_SECRET" } ] ``` -------------------------------- ### Reset Gateway Configuration Source: https://fly.io/docs/blueprints/deploy-openclaw Use this to start fresh by removing the gateway configuration file. This will trigger re-onboarding. 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 ``` -------------------------------- ### Get Specific Volume Response (200 OK) Source: https://fly.io/docs/machines/api/volumes-resource Example response for retrieving a specific volume's details, including its attachment status and storage information. ```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": "" } ``` -------------------------------- ### Canary Deployment Output Example Source: https://fly.io/docs/launch/deploy This output shows the process of a canary deployment, including image building, creation and health verification of a canary machine, and subsequent rolling updates to existing machines. ```bash fly deploy --strategy canary ...==> Building image Searching for image 'flyio/hellofly:latest' remotely... image found: img_z1nr0lpjz9v5q98w Watch your app at https://fly.io/apps/aged-water-8803/monitoring Creating canary machine for group app Machine 328745da023e85 [app] update finished: success Canary machines successfully created and healthy, destroying before continuing machine 328745da023e85 was found and is currently in created state, attempting to destroy... Updating existing machines in 'example-app-8803' with canary strategy [1/2] Machine 3287457df77785 [app] update finished: success [2/2] Machine 91857266c41638 [app] update finished: success Finished deploying ... ``` -------------------------------- ### Get Machine Outbound IP using curl Source: https://fly.io/docs/networking/services You can also call out to an external service that'll tell you your IP. This example uses `curl` to query an external service. ```cmd curl text.ipv6.wtfismyip.com ``` -------------------------------- ### Create a Machine - Example Response Source: https://fly.io/docs/machines/api/machines-resource Example of a successful (200 OK) response when creating a machine. ```json { "id": "f1234567890abcdef", "name": "my-new-machine", "state": "running", "region": "yyz", "image_ref": "registry-1.docker.io/library/ubuntu:latest", "config": { "image": "registry-1.docker.io/library/ubuntu:latest", "cpu": 1, "memory_mb": 1024, "services": [ { "ports": [ { "port": 80, "handlers": ["http"] } ] } ] }, "created_at": "2023-10-27T10:00:00Z", "updated_at": "2023-10-27T10:05:00Z" } ``` -------------------------------- ### View Deployment Status Source: https://fly.io/docs/kubernetes/fks-quickstart Example output of `kubectl get deployments`, showing the status of the nginx-deployment, including ready replicas, up-to-date count, available count, and age. ```text NAME READY UP-TO-DATE AVAILABLE AGE nginx-deployment 3/3 3 3 7s ``` -------------------------------- ### Initialize Sequelize Project Source: https://fly.io/docs/postgres/connecting/app-connection-examples Run the Sequelize CLI to initialize your project, creating necessary configuration and model directories. ```bash npx sequelize init ``` -------------------------------- ### Launch and Deploy App with Fly.io Source: https://fly.io/docs/elixir/getting-started Navigate to your project directory and run `fly launch` to configure and deploy your application. This command prompts for settings and automates the build and deployment process, including database setup. ```bash cd hello_elixir fly launch ``` ```text Organization: MyOrgName (fly launch defaults to the personal org) Name: hello_elixir (derived from your directory name) Region: Secaucus, NJ (US) (this is the fastest region for you) App Machines: shared-cpu-1x, 1GB RAM (most apps need about 1GB of RAM) Postgres: (not requested) Redis: (not requested) ? Do you want to tweak these settings before proceeding? Yes Opening https://fly.io/cli/launch/bea626e2d179a083a3ba622a367e24ec ... ``` ```bash Waiting for launch data... Done Created app 'hello_elixir' in organization 'personal' Admin URL: https://fly.io/apps/hello_elixir Hostname: hello_elixir.fly.dev Set secrets on hello_elixir: SECRET_KEY_BASE Creating postgres cluster in organization personal Creating app... Setting secrets on app hello_elixir-db... Provisioning 1 of 1 machines with image flyio/postgres-flex:15.3@sha256:44b698752cf113110f2fa72443d7fe452b48228aafbb0d93045ef1e3282360a6 Waiting for machine to start... Machine 2865550c7e96d8 is created ==> Monitoring health checks Waiting for 2865550c7e96d8 to become healthy (started, 3/3) Postgres cluster hello_elixir-db created Username: postgres Password: EChe3BrhCjsPQEI Hostname: hello_elixir-db.internal Flycast: fdaa:2:45b:0:1::1d Proxy port: 5432 Postgres port: 5433 Connection string: postgres://postgres:EChe3BrhCjsPQEI@hello_elixir-db.flycast:5432 Save your credentials in a secure place -- you won't be able to see them again! Connect to postgres Any app within the MyOrgName organization can connect to this Postgres using the above connection string Now that you've set up Postgres, here's what you need to understand: https://fly.io/docs/postgres/getting-started/what-you-should-know/ Checking for existing attachments Registering attachment Creating database Creating user Postgres cluster hello_elixir-db is now attached to hello_elixir The following secret was added to hello_elixir: DATABASE_URL=postgres://aa_hello_elixir2:Er6pLzUBuhKcbBl@hello_elixir-db.flycast:5432/aa_hello_elixir2?sslmode=disable Postgres cluster hello_elixir-db is now attached to hello_elixir Generating rel/env.sh.eex for distributed Elixir support Preparing system for Elixir builds Installing application dependencies Running Docker release generator Wrote config file fly.toml Validating /Users/anderson/test-elixir-gs/hello_elixir2/fly.toml ✓ Configuration is valid ==> Building image Remote builder fly-builder-black-pine-7645 ready Remote builder fly-builder-black-pine-7645 ready ==> Building image with Docker --> docker host: 20.10.12 linux x86_64 ... --> Pushing image done image: registry.fly.io/hello_elixir:deployment-01HPMGHTG8XSYH3ZCV82SF5CEZ image size: 126 MB Watch your deployment at https://fly.io/apps/hello_elixir/monitoring Provisioning ips for hello_elixir Dedicated ipv6: 2a09:8280:1::2a:bc0b:0 Shared ipv4: 66.241.124.79 Add a dedicated ipv4 with: fly ips allocate-v4 Running hello_elixir release_command: /app/bin/migrate ------- ✔ release_command 784eee4c294298 completed successfully ------- 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 ------- ``` -------------------------------- ### Bash Script for Project Post-Initialization Source: https://fly.io/docs/gpus/python-gpu-example This script runs as a non-root user to set up a Python virtual environment, install Jupyter, and start the Jupyter server. It checks for the existence of a virtual environment and Jupyter package, installing them if necessary. The Jupyter server is configured to be accessible only via Fly.io's private networking. ```bash #!/bin/bash PROJECT_DIR="project" VENV_DIR="$PROJECT_DIR-venv" echo "Running post-initialization script as $USER." echo "Entering $USER's home dir" cd ~ echo "Creating venv dir for $PROJECT_DIR if it doesn't exist" mkdir -p $VENV_DIR echo "Creating venv in $VENV_DIR if it doesn't exist" if [ ! -f "$VENV_DIR/pyvenv.cfg" ]; then echo "No 'pyvenv.cfg' file found in $VENV_DIR; creating a venv" python3 -m venv $VENV_DIR fi echo "Activating venv in $VENV_DIR" source $VENV_DIR/bin/activate echo "Creating dir $PROJECT_DIR if it doesn't exist" if pip show jupyter &> /dev/null; then echo "Jupyter is installed with pip." else echo "Installing packages with pip" pip install jupyter fi echo "Starting Jupyter notebook server!" jupyter notebook --ip $FLY_PRIVATE_IP --no-browser # If you don't want Jupyter, use the `sleep inf` command instead, and # `fly ssh console` into the Machine to interact with it. # sleep inf ``` -------------------------------- ### Run fly mcp server with MCP inspector Source: https://fly.io/docs/mcp/flyctl-server Starts the MCP server with the inspector enabled for exploration. Requires Node.js to be installed. Navigate to http://127.0.0.1:6274 to use the inspector. ```bash fly mcp server -i ``` -------------------------------- ### Launch Ollama Demo App Source: https://fly.io/docs/blueprints/connect-private-network-wireguard Initializes a Fly.io application from a GitHub repository for demonstrating Ollama. Use `--no-deploy` to prepare for manual deployment. ```bash fly launch --from https://github.com/fly-apps/ollama-demo --no-deploy ``` -------------------------------- ### Run Interactive Shell Machine Source: https://fly.io/docs/blueprints/private-applications-flycast Start an interactive shell session within a new virtual machine. Allocate sufficient memory (e.g., 1024MB) for installing necessary tools. ```bash fly machine run --shell --vm-memory 1024 ubuntu ``` -------------------------------- ### Fastify Application Start Command Source: https://fly.io/docs/js/the-basics/listening-ports Start a Fastify application and specify the listening address using the `--address` flag. ```bash fastify start --address 0.0.0.0 ``` -------------------------------- ### Fly.toml Configuration Example Source: https://fly.io/docs/languages-and-frameworks/dotnet Shows a sample `fly.toml` file generated by `flyctl launch`. This file configures deployment settings for the Fly.io platform. ```toml app = "hellodotnet" primary_region = "ord" [http_service] internal_port = 8080 force_https = true auto_stop_machines = true auto_start_machines = true min_machines_running = 0 processes = ["app"] ... ``` -------------------------------- ### Get App Details Response Source: https://fly.io/docs/machines/api/apps-resource This is an example of a successful response when fetching app details. It includes the app's unique ID, name, current status, and organization information. ```json { "id": "jlyv9r5d56v18xrg", "name": "my-app-name", "status": "pending", "organization": { "name": "My Org", "slug": "personal" } } ``` -------------------------------- ### Outbound Webhook Payload Example - Machine Event Source: https://fly.io/docs/reference/extensions_api This is a sample payload for an outbound webhook notification about a machine event, such as a machine failing to start. It includes machine-specific details and error information. ```json { "machine_id": "5683977ad31768", "status": "failed", "data": { "Error": "image not found", "Transition": "prepareImage" } } ``` -------------------------------- ### Example App List Response Source: https://fly.io/docs/networking/private-networking This is an example output from `dig _apps.internal TXT +short`, indicating the apps accessible through the current VPN connection. ```text my-app,my-app-db ``` -------------------------------- ### Example Checks Configuration Source: https://fly.io/docs/machines/api-machines-resource Defines two checks: one for TCP connectivity and another for HTTP GET requests. Ensure the port matches the internal port and intervals/timeouts are set appropriately. ```json "checks": { "tcp-alive": { "type": "tcp", "port": 8080, "interval": "15s", "timeout": "10s" }, "http-get": { "type": "http", "port": 8080, "protocol": "http" "method": "GET", "path": "/", "interval": "15s", "timeout": "10s" } } ``` -------------------------------- ### Setup Fly.io Ownership TXT Record Source: https://fly.io/docs/networking/understanding-cloudflare Run this command to get the required `_fly-ownership` TXT record details from Cloudflare DNS. This proves domain ownership to Fly.io for certificate validation. ```bash fly certs setup example.com ``` -------------------------------- ### Clone a Fly Machine with Options Source: https://fly.io/docs/flyctl/machine-clone This example demonstrates cloning a machine with specific configurations, such as attaching an existing volume, disabling auto-destroy, setting a new name, and specifying the region. ```bash fly machine clone [machine_id] --app "my-app" --attach-volume "vol_abcdef123456" --clear-auto-destroy --name "my-new-machine" --region "sfo" ``` -------------------------------- ### Example Provisioning Request Source: https://fly.io/docs/reference/extensions_api This is an example of a POST request to provision an extension. It includes details about the extension, organization, user, and optional region-specific information. ```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 } ``` -------------------------------- ### HTTP Request: Trigger Job Start Source: https://fly.io/docs/rails/advanced-guides/machine This is an example of an HTTP request to trigger the '/job/start' endpoint of your deployed Fly.io application. This is typically done via a web browser or a tool like `curl`. ```http curl, url ``` -------------------------------- ### Log Shipper Configuration for Loki Source: https://fly.io/docs/monitoring/logs-api-options Example TOML configuration for the Fly Log Shipper to forward logs to a Loki instance. This setup allows for durable storage and querying of logs in an external system. ```toml [sinks.loki] type = "loki" inputs = ["fly_logs"] endpoint = "https://my-loki-instance.example" encoding.codec = "json" ``` -------------------------------- ### Deploy Initial Application Source: https://fly.io/docs/blueprints/using-base-images-for-faster-deployments Commands to launch and deploy the initial Go application using flyctl. This creates the app and builds its Docker image. ```bash $ fly launch --name go-fly-a-site --vm-size shared-cpu-1x --no-deploy .... Your app is ready! Deploy with `flyctl deploy` ``` ```bash $ fly deploy ==> Verifying app config Validating /Users/fly/Code/go-fly-a-site/fly.toml ✓ Configuration is valid --> Verified app config ==> Building image ==> Building image with Depot --> build: ... Visit your newly deployed app at https://go-fly-a-site.fly.dev/ ``` ```bash $ curl https://go-fly-a-site.fly.dev/ Hello, world! ``` -------------------------------- ### Litestream Configuration File Example Source: https://fly.io/docs/litefs/backup A sample Litestream configuration file (`litestream.yml`) specifying the database path, metadata path, and S3 replica details. Ensure `path` and `bucket` match your setup. ```yml dbs: - path: /litefs/my.db meta-path: /var/lib/litefs/my.db-litestream replicas: - type: s3 bucket: "mybucket" path: "my.db" endpoint: "fly.storage.tigris.dev" force-path-style: true ```