### Dockerfile with Overmind and Procfile Source: https://github.com/superfly/docs/blob/main/app-guides/multiple-processes.html.md Install Overmind, a Procfile manager, and set it to start processes defined in a Procfile. This example uses a golang base image and installs Overmind via go get. ```dockerfile FROM golang RUN apt-get update && \ apt-get install -y \ bash \ tmux \ curl # ... RUN GO111MODULE=on go get -u github.com/DarthSim/overmind/v2 ADD Procfile /app/ CMD ["overmind", "start"] ``` -------------------------------- ### Generic CI Example: Deploy App Source: https://github.com/superfly/docs/blob/main/flyctl/integrating.html.md A complete example for deploying an application in a generic CI environment. It includes installing flyctl, authenticating with an API token, and running the deploy command. ```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 ``` -------------------------------- ### Create and Configure a New Rails Application Source: https://github.com/superfly/docs/blob/main/rails/getting-started/index.html.md This snippet shows how to create a new Rails application, navigate into its directory, and modify the `config/routes.rb` file to display a welcome page in production. It requires Rails to be installed. ```shell rails --version rails new welcome cd welcome ``` ```diff Rails.application.routes.draw do # Define your application routes per the DSL in # https://guides.rubyonrails.org/routing.html # Reveal health status on /up that returns 200 if the app boots # with no exceptions, otherwise 500. # Can be used by load balancers and uptime monitors to verify # that the app is live. get "up" => "rails/health#show", as: :rails_health_check # Defines the root path route ("/") - # root "articles#index" + root "rails/welcome#index" end ``` -------------------------------- ### Start command options Source: https://github.com/superfly/docs/blob/main/flyctl/cmd/fly_agent_start.md Displays help information for the start command. ```bash -h, --help help for start ``` -------------------------------- ### Create Project Directory and Navigate (Command Line) Source: https://github.com/superfly/docs/blob/main/django/getting-started/index.html.md Creates a new directory for the project named 'hello-django' and then changes the current directory to the newly created folder. This is a standard first step for new projects. ```cmd mkdir hello-django && cd hello-django ``` -------------------------------- ### Clone Example Repository Source: https://github.com/superfly/docs/blob/main/gpus/python-gpu-example.html.md This command clones the provided example repository for a Python GPU setup. After cloning, it navigates into the newly created directory. ```bash git clone git@github.com:fly-apps/python_gpu_example.git && cd python_gpu_example ``` -------------------------------- ### Start Django Development Server (Command Line) Source: https://github.com/superfly/docs/blob/main/django/getting-started/index.html.md Starts Django's built-in local web server, allowing you to test your application locally. The server typically runs on http://127.0.0.1:8000/. ```cmd python manage.py runserver ``` -------------------------------- ### Run a function on a new machine (JavaScript Example) Source: https://github.com/superfly/docs/blob/main/blueprints/infra-automation-without-terraform.html.md This example, found in a JavaScript repository, illustrates a pattern for executing a single function on a newly provisioned Machine. It involves booting a Machine in a specific region, running a job, and then tearing down the Machine. This approach offers serverless-like functionality with the benefits of a full VM and no cold starts. ```javascript // Example structure, actual implementation would involve API calls async function runFunctionOnNewMachine(region, image, command) { const machineConfig = { region: region, config: { image: image, cmd: command.split(' '), // ... other guest and metadata configurations } }; // 1. Create Machine const createResponse = await fetch('https://api.machines.dev/v1/apps/YOUR_APP_NAME/machines', { method: 'POST', headers: { 'Authorization': `Bearer YOUR_FLY_TOKEN`, 'Content-Type': 'application/json' }, body: JSON.stringify(machineConfig) }); const newMachine = await createResponse.json(); const machineId = newMachine.id; // 2. Start Machine (if not started automatically) await fetch(`https://api.machines.dev/v1/apps/YOUR_APP_NAME/machines/${machineId}/start`, { method: 'POST', headers: { 'Authorization': `Bearer YOUR_FLY_TOKEN` } }); // 3. Wait for job completion (implementation specific) console.log(`Machine ${machineId} is running job...`); // ... logic to monitor job status or wait for a signal ... // 4. Destroy Machine await fetch(`https://api.machines.dev/v1/apps/YOUR_APP_NAME/machines/${machineId}`, { method: 'DELETE', headers: { 'Authorization': `Bearer YOUR_FLY_TOKEN` } }); console.log(`Machine ${machineId} destroyed.`); } // Example usage: // runFunctionOnNewMachine('sjc', 'ubuntu', 'echo "Hello from ephemeral VM"'); ``` -------------------------------- ### Launch Livebook Server Locally Source: https://github.com/superfly/docs/blob/main/elixir/advanced-guides/connect-livebook-to-your-app.html.md Starts the Livebook server from the command line. This command assumes Livebook has been installed as an escript. ```cmd livebook server ``` -------------------------------- ### Fly Certs Setup Command Source: https://github.com/superfly/docs/blob/main/flyctl/cmd/fly_certs_setup.md Use this command to initiate the setup process for certificate DNS records. Provide the hostname as an argument. ```bash fly certs setup [flags] ``` -------------------------------- ### Deploying Web Tier Application Source: https://github.com/superfly/docs/blob/main/blueprints/n-tier-architecture.html.md These commands initiate the deployment of your application's web tier on Fly.io. 'fly launch' sets up your project configuration, and 'fly deploy' pushes your code to the Fly Machines. ```bash fly launch fly deploy ``` -------------------------------- ### Launch Application on Fly Source: https://github.com/superfly/docs/blob/main/mcp/transports/stdio.html.md This command initiates the deployment of the MCP server to the Fly.io platform. It configures the application for high availability (set to false in this example). ```shell fly launch --ha=false ``` -------------------------------- ### Test Cold Start Behavior Source: https://github.com/superfly/docs/blob/main/reference/suspend-resume.html.md This sequence of commands can be used to test how your machine behaves when it needs to cold start. It involves stopping and then starting the machine. ```bash fly machine stop ``` ```bash fly machine start ``` -------------------------------- ### Start MCP Proxy Client Source: https://github.com/superfly/docs/blob/main/flyctl/cmd/fly_mcp_proxy.md Starts an MCP proxy client. This command is experimental and used for starting a proxy client to connect to an MCP server. ```APIDOC ## POST /fly/mcp/proxy ### Description Starts an MCP proxy client to connect to an MCP server. This is an experimental feature. ### Method POST ### Endpoint /fly/mcp/proxy ### Parameters #### Query Parameters - **app** (string) - Optional - Application name - **bind-addr** (string) - Optional - Local address to bind to (default "127.0.0.1") - **bearer-token** (string) - Optional - Bearer token to authenticate with - **user** (string) - Optional - User to authenticate with - **password** (string) - Optional - Password to authenticate with - **instance** (string) - Optional - Use fly-force-instance-id to connect to a specific instance - **url** (string) - Optional - URL of the MCP wrapper server - **timeout** (integer) - Optional - Timeout in seconds for the MCP connection #### Flags - **inspector** (boolean) - Optional - Launch MCP inspector: a developer tool for testing and debugging MCP servers - **ping** (boolean) - Optional - Enable ping for the MCP connection - **sse** (boolean) - Optional - Use Server-Sent Events (SSE) for the MCP connection - **stream** (boolean) - Optional - Use streaming for the MCP connection ### Request Example ```json { "app": "my-app", "bind-addr": "0.0.0.0", "user": "testuser", "password": "testpass", "inspector": true, "ping": true } ``` ### Response #### Success Response (200) - **message** (string) - Confirmation message indicating the proxy client has started. #### Response Example ```json { "message": "MCP proxy client started successfully." } ``` ``` -------------------------------- ### Fly.toml Process Configuration for Node.js Apps Source: https://github.com/superfly/docs/blob/main/js/prisma/sqlite.html.md This TOML snippet shows how `fly launch` might override the default application command in `fly.toml` for Node.js applications. It configures the 'app' process to run a startup script `dbsetup.js` followed by `npm run start`, ensuring database setup precedes application startup. ```toml [processes] app = "node dbsetup.js npm run start" ``` -------------------------------- ### Clone Example App Repository Source: https://github.com/superfly/docs/blob/main/security/arcjet.html.md Clones the Arcjet example application repository from GitHub to get started with testing security features. ```cmd git clone git@github.com:arcjet/arcjet-example-nextjs-fly.git ``` -------------------------------- ### Scale VM Count with Options Source: https://github.com/superfly/docs/blob/main/flyctl/cmd/fly_scale_count.md This example demonstrates scaling the VM count with additional options. Specify the application name, target VM count, and optionally set environment variables or specify regions to act upon. This provides granular control over the scaling operation. ```bash fly scale count 5 --app my-app -r "us-east,eu-west" -e "LOG_LEVEL=debug" ``` -------------------------------- ### View deployment output Source: https://github.com/superfly/docs/blob/main/blueprints/deploy-openclaw.html.md Example of the information displayed upon successful deployment. ```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: ``` -------------------------------- ### Install Django using pip (Command Line) Source: https://github.com/superfly/docs/blob/main/django/getting-started/index.html.md Installs the latest version of Django using pip, the Python package installer. This command should be run with your virtual environment activated. ```cmd python -m pip install Django ``` -------------------------------- ### Go Web Server Example Source: https://github.com/superfly/docs/blob/main/blueprints/using-base-images-for-faster-deployments.html.md A simple Go program that listens on port 8080 and responds with 'Hello, world!'. This serves 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") } ``` -------------------------------- ### Install Gunicorn Production Server Source: https://github.com/superfly/docs/blob/main/django/getting-started/index.html.md Installs Gunicorn, a production-ready WSGI HTTP server, using pip. Gunicorn is recommended for serving Django applications in production environments instead of Django's built-in development server. ```cmd python -m pip install gunicorn ``` -------------------------------- ### Generate Django Requirements File Source: https://github.com/superfly/docs/blob/main/django/getting-started/index.html.md Creates a requirements.txt file that lists all the Python packages currently installed in the virtual environment. This file is essential for replicating the project's dependencies in the production environment. ```cmd pip freeze > requirements.txt ``` -------------------------------- ### Create command help options Source: https://github.com/superfly/docs/blob/main/flyctl/cmd/fly_tokens_create.md Displays help information for the create command. ```bash -h, --help help for create ``` -------------------------------- ### Launch Rails Application on Fly.io Source: https://github.com/superfly/docs/blob/main/rails/getting-started/index.html.md This command initiates the deployment process for a Rails application on Fly.io. It guides the user through configuration options and deploys the application. No specific inputs are required beyond responding to prompts. ```cmd fly launch ``` ```output Scanning source code Detected a Rails app Creating app in ~/tmp/welcome We're about to launch your Rails app on Fly.io. Here's what you're getting: Organization: Jane Developer (fly launch defaults to the personal org) Name: welcome-proud-sun-3423 (generated) Region: Ashburn, Virginia (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) Tigris: (not requested) ? Do you want to tweak these settings before proceeding? (y/N) ``` ```cmd fly apps open ``` -------------------------------- ### Dockerfile for a Golang App Source: https://github.com/superfly/docs/blob/main/app-guides/multiple-processes.html.md Sets up a Go environment, installs necessary tools, and builds a Go application. The CMD instruction 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 ``` -------------------------------- ### Create a New Machine from Configuration Source: https://github.com/superfly/docs/blob/main/machines/guides-examples/managing-machines-with-the-api.html.md Posts a JSON configuration file to the API to provision a new Machine. ```bash curl -H "Authorization: Bearer $FLY_TOKEN" \ -H "Content-Type: application/json" \ -X POST https://api.machines.dev/v1/apps/YOUR_APP/machines \ -d @config.json ``` -------------------------------- ### Base Dockerfile Example Source: https://github.com/superfly/docs/blob/main/blueprints/using-base-images-for-faster-deployments.html.md A Dockerfile designed to be a base image. It starts from a Debian 12 image and installs Go, but instead of running an application, it uses 'sleep inf' to keep the container running for potential future use or inspection. ```dockerfile FROM debian:12 ``` -------------------------------- ### Help for Enable Command Source: https://github.com/superfly/docs/blob/main/flyctl/cmd/fly_settings_autoupdate_enable.md View help information for the 'enable' command to understand its options and usage. ```bash fly settings autoupdate enable --help ``` -------------------------------- ### Bash Script: Setup Python Virtual Environment and Run Jupyter Source: https://github.com/superfly/docs/blob/main/gpus/python-gpu-example.html.md The `post-initialization.sh` script runs as the non-root user. It creates and activates a Python virtual environment, installs Jupyter if not already present, and starts a Jupyter notebook server accessible via the Machine's private IPv6 address. This script is designed to be run after the `entrypoint.sh` script. ```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" mkdir -p $PROJECT_DIR && cd $PROJECT_DIR # If you want to get project Python deps using requirements.txt, uncomment this and # adjust the Dockerfile to copy the file into the image # cp /requirements.txt . # The following only installs pip packages if Jupyter isn't yet installed; # essentially on first boot. if pip show jupyter &> /dev/null; then echo "Jupyter is installed with pip." else echo "Installing packages with pip" # Uncomment to use requirements.txt. You can also install more packages # after deployment. This Python venv lives on the persistent Fly Volume. # pip install -r requirements.txt # Install from scratch without a requirements.txt; some examples: pip install jupyter # pip install numpy torch # numpy isn't getting installed as a dep of torch so do it explicitly # pip install diffusers transformers accelerate # HuggingFace libs for specific projects 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 ``` -------------------------------- ### Database Creation Options Source: https://github.com/superfly/docs/blob/main/flyctl/cmd/fly_mpg_databases_create.md Lists available flags for the database creation command. ```bash -h, --help help for create -n, --name string The name of the database ``` -------------------------------- ### Install flyctl in Rails Dockerfile Source: https://github.com/superfly/docs/blob/main/rails/advanced-guides/machine.html.md Instructions to install the flyctl executable within the Rails application's Dockerfile. This enables the application to interact with Fly.io services from within the running machine. ```dockerfile RUN curl -L https://fly.io/install.sh | sh ENV FLYCTL_INSTALL="/root/.fly" ENV PATH="$FLYCTL_INSTALL/bin:$PATH" ``` -------------------------------- ### Enable Synthetics Agent Source: https://github.com/superfly/docs/blob/main/flyctl/cmd/fly_settings_synthetics_enable.md Use this command to enable the synthetics agent for your Fly.io applications. No specific setup is required beyond having the Fly CLI installed. ```bash fly settings synthetics enable [flags] ``` -------------------------------- ### Command Options Source: https://github.com/superfly/docs/blob/main/flyctl/cmd/fly_postgres_import.md Configuration flags for the import process, including database creation and schema handling. ```bash -a, --app string Application name --clean Drop database objects prior to creating them. -c, --config string Path to application configuration file --create Begin by creating the database itself and reconnecting to it. If --clean is also specified, the script drops and recreates the target database before reconnecting to it. (default true) --data-only Dump only the data, not the schema (data definitions). -h, --help help for import --image string Path to public image containing custom migration process --no-owner Do not set ownership of objects to match the original database. Makes dump restorable by any user. (default true) --region string Region to provision migration machine --vm-size string the size of the VM ``` -------------------------------- ### Scale VM Count with VM Configuration Source: https://github.com/superfly/docs/blob/main/flyctl/cmd/fly_scale_count.md Configure the VM specifications while scaling. This example sets the VM count to 3, specifies the application, and defines the VM CPU kind, number of CPUs, and memory. This is useful for ensuring that scaled VMs meet specific performance requirements. ```bash fly scale count 3 --app my-app --vm-cpu-kind "performance" --vm-cpus 2 --vm-memory "2048" ``` -------------------------------- ### Show Postgres Backup Configuration Source: https://github.com/superfly/docs/blob/main/flyctl/cmd/fly_postgres_backup_config.md Displays the current backup configuration for a Fly Postgres instance. No setup is required beyond having the flyctl CLI installed. ```bash fly postgres backup config show ``` -------------------------------- ### Configuration File Option Source: https://github.com/superfly/docs/blob/main/flyctl/cmd/fly_machine_uncordon.md Provide the path to your application's configuration file using this option. ```bash -c, --config string Path to application configuration file ``` -------------------------------- ### List MySQL Databases Source: https://github.com/superfly/docs/blob/main/flyctl/cmd/fly_mysql_list.md Use this command to list all MySQL databases within your Fly.io organization. No setup is required beyond having the flyctl CLI installed. ```bash fly mysql list [flags] ``` -------------------------------- ### Provisioning Request Example (JavaScript) Source: https://github.com/superfly/docs/blob/main/reference/extensions_api.html.md This snippet demonstrates a sample provisioning request to the Fly.io extensions API. It includes mandatory and optional parameters required to set up an extension, such as name, organization details, user information, and region preferences. The request is sent via a POST request to a specified endpoint. ```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 } ``` -------------------------------- ### List Certificates for an Application Source: https://github.com/superfly/docs/blob/main/flyctl/cmd/fly_certs_list.md Use this command to view all certificates associated with your Fly application. No setup is required beyond having the Fly CLI installed and authenticated. ```bash fly certs list [flags] ``` -------------------------------- ### Install Network Tools Source: https://github.com/superfly/docs/blob/main/blueprints/private-applications-flycast.html.md Inside the shell Machine, install essential network utilities like `curl`, `ping`, and `dig` using `apt`. ```bash # apt update && apt install -y curl iputils-ping dnsutils ``` -------------------------------- ### Fly.io Application Log Output Example Source: https://github.com/superfly/docs/blob/main/rails/advanced-guides/machine.html.md This is an example of the log output you might see in your Fly.io application's log stream when accessing the `/job/start` and `/job/complete` endpoints. It shows request processing, job enqueuing, and completion details. ```log 2022-09-20T04:07:59Z app[9080514c12d787] iad [info]I, [2022-09-20T04:07:59.525790 #514] INFO -- : [b2f7eb1f-e552-445d-84ac-72d4a63fa4d4] Started GET "/job/start" for 168.220.92.2 at 2022-09-20 04:07:59 +0000 2022-09-20T04:07:59Z app[9080514c12d787] iad [info]I, [2022-09-20T04:07:59.529213 #514] INFO -- : [b2f7eb1f-e552-445d-84ac-72d4a63fa4d4] Processing by JobController#start as HTML 2022-09-20T04:07:59Z app[9080514c12d787] iad [info]I, [2022-09-20T04:07:59.541820 #514] INFO -- : [b2f7eb1f-e552-445d-84ac-72d4a63fa4d4] [ActiveJob] Enqueued MachineJob (Job ID: 7984003d-bb82-4815-acff-81d1ba91539f) to Async(default) with arguments: "http://weathered-sunset-3812.fly.dev/job/complete" 2022-09-20T04:07:59Z app[9080514c12d787] iad [info]I, [2022-09-20T04:07:59.544837 #514] INFO -- : [b2f7eb1f-e552-445d-84ac-72d4a63fa4d4] Rendered text template (Duration: 0.0ms | Allocations: 8) 2022-09-20T04:07:59Z app[9080514c12d787] iad [info]I, [2022-09-20T04:07:59.545257 #514] INFO -- : [b2f7eb1f-e552-445d-84ac-72d4a63fa4d4] Completed 200 OK in 16ms (Views: 2.9ms | Allocations: 1056) 2022-09-20T04:07:59Z app[9080514c12d787] iad [info]I, [2022-09-20T04:07:59.546683 #514] INFO -- : [ActiveJob] [MachineJob] [7984003d-bb82-4815-acff-81d1ba91539f] Performing MachineJob (Job ID: 7984003d-bb82-4815-acff-81d1ba91539f) from Async(default) enqueued at 2022-09-20T04:07:59Z with arguments: "http://weathered-sunset-3812.fly.dev/job/complete" 2022-09-20T04:07:59Z app[9080514c12d787] iad [info]E, [2022-09-20T04:07:59.546905 #514] ERROR -- : [ActiveJob] [MachineJob] [7984003d-bb82-4815-acff-81d1ba91539f] danger 2022-09-20T04:07:59Z runner[5683009c17548e] iad [info]Reserved resources for machine '5683009c17548e' 2022-09-20T04:07:59Z runner[5683009c17548e] iad [info]Pulling container image 2022-09-20T04:08:00Z app[9080514c12d787] iad [info]I, [2022-09-20T04:08:00.071564 #514] INFO -- : [ActiveJob] [MachineJob] [7984003d-bb82-4815-acff-81d1ba91539f] Started machine: 5683009c17548e 2022-09-20T04:08:00Z runner[5683009c17548e] iad [info]Unpacking image 2022-09-20T04:08:02Z runner[5683009c17548e] iad [info]Configuring firecracker 2022-09-20T04:08:03Z app[5683009c17548e] iad [info] % Total % Received % Xferd Average Speed Time Time Time Current 0 0 0 0 0 0 load Upload Total Spent Left Speed 2022-09-20T04:08:04Z app[9080514c12d787] iad [info]I, [2022-09-20T04:08:04.813284 #514] INFO -- : [c6131d3b-bcba-4ab7-88cb-3e07800ec6b2] Started GET "/job/complete" for 2a09:8280:1::7635 at 2022-09-20 04:08:04 +0000 2022-09-20T04:08:04Z app[9080514c12d787] iad [info]I, [2022-09-20T04:08:04.814303 #514] INFO -- : [c6131d3b-bcba-4ab7-88cb-3e07800ec6b2] Processing by JobController#complete as */* 2022-09-20T04:08:04Z app[9080514c12d787] iad [info]I, [2022-09-20T04:08:04.826253 #514] INFO -- : [c6131d3b-bcba-4ab7-88cb-3e07800ec6b2] Rendered text template (Duration: 0.0ms | Allocations: 2) 2022-09-20T04:08:04Z app[9080514c12d787] iad [info]I, [2022-09-20T04:08:04.827434 #514] INFO -- : [c6131d3b-bcba-4ab7-88cb-3e07800ec6b2] Completed 200 OK in 13ms (Views: 2.1ms | Allocations: 167) 100 3 0 3 0 0 1 0 --:--:-- 0:00:02 --:--:-- 2 2022-09-20T04:08:04Z app[5683009c17548e] iad [info]OK 2022-09-20T04:08:07Z runner[5683009c17548e] iad [info]machine exited with exit code 0, not restarting 2022-09-20T04:08:10Z app[9080514c12d787] iad [info]I, [2022-09-20T04:08:10.238155 #514] INFO -- : [ActiveJob] [MachineJob] [7984003d-bb82-4815-acff-81d1ba91539f] Deleted machine: 5683009c17548e 2022-09-20T04:08:10Z app[9080514c12d787] iad [info]I, [2022-09-20T04:08:10.238536 #514] INFO -- : [ActiveJob] [MachineJob] [7984003d-bb82-4815-acff-81d1ba91539f] Performed MachineJob (Job ID: 7984003d-bb82-4815-acff-81d1ba91539f) from Async(default) in 10691.24ms ``` -------------------------------- ### Fly CLI Help for Config Source: https://github.com/superfly/docs/blob/main/flyctl/cmd/fly_postgres_backup_config.md Displays help information for the 'config' command within the 'fly postgres backup' context. Useful for understanding available subcommands and options. ```bash fly postgres backup config --help ``` -------------------------------- ### View machine leases with configuration file Source: https://github.com/superfly/docs/blob/main/flyctl/cmd/fly_machine_leases_view.md Use the `-c` or `--config` flag to specify the path to the application configuration file. ```bash fly machine leases view -c ``` -------------------------------- ### Install Node.js and Build Assets in Final Docker Image Source: https://github.com/superfly/docs/blob/main/laravel/advanced-guides/using-inertia-ssr.html.md This Dockerfile snippet shows how to install Node.js directly into the final 'fly-laravel' image. It includes steps to download and run the NodeSource setup script, install Node.js, and then conditionally build frontend assets using npm, yarn, or pnpm based on lock files. Finally, it ensures correct file ownership for the web server. ```dockerfile # Install node in fly-laravel image RUN cd ~ \ && curl -sL https://deb.nodesource.com/setup_18.x -o nodesource_setup.sh \ && bash nodesource_setup.sh \ && apt install nodejs \ && cd /var/www/html # The snippet below already exists in the Dockerfile btw, # In the multi-stage build set up: RUN if [ -f "vite.config.js" ]; then \ ASSET_CMD="build"; \ else \ ASSET_CMD="production"; \ fi; \ if [ -f "yarn.lock" ]; then \ yarn install --frozen-lockfile; \ yarn $ASSET_CMD; \ elif [ -f "pnpm-lock.yaml" ]; then \ corepack enable && corepack prepare pnpm@latest-8 --activate; \ pnpm install --frozen-lockfile; \ pnpm run $ASSET_CMD; \ elif [ -f "package-lock.json" ]; then \ npm ci --no-audit; \ npm run $ASSET_CMD; \ else \ npm install; \ npm run $ASSET_CMD; \ fi; RUN chown -R www-data:www-data /var/www/html/public EXPOSE 8080 ENTRYPOINT ["/entrypoint"] ``` -------------------------------- ### Create and Activate Virtual Environment (Unix/macOS) Source: https://github.com/superfly/docs/blob/main/django/getting-started/index.html.md Creates a Python virtual environment named '.venv' using the 'venv' module and then activates it. This isolates project dependencies. ```shell # Unix/macOS $ python3 -m venv .venv $ source .venv/bin/activate (.venv) $ ``` -------------------------------- ### List Applications with Help Information Source: https://github.com/superfly/docs/blob/main/flyctl/cmd/fly_apps_list.md Access help information for the 'fly apps list' command using the --help flag. ```bash fly apps list --help ``` -------------------------------- ### Remove Multi-Stage Build Setup for Node Assets Source: https://github.com/superfly/docs/blob/main/laravel/advanced-guides/using-inertia-ssr.html.md This Dockerfile snippet shows lines that should be removed when opting to install Node.js directly in the final image. It specifically targets the removal of the multi-stage build setup that uses a separate 'node' image for building assets and node_modules, as well as the subsequent copying of these assets. ```dockerfile # Remove the "multi stage build setup" lines below: - FROM node:${NODE_VERSION} as node_modules_go_brrr - RUN mkdir /app - RUN mkdir -p /app - WORKDIR /app - COPY . . - COPY --from=base /var/www/html/vendor /app/vendor # Remove the "set up to copy asset folder from node image to fly-laravel image" # lines below: - COPY --from=node_modules_go_brrr /app/public /var/www/html/public-npm - RUN rsync -ar /var/www/html/public-npm/ /var/www/html/public/ && rm -rf /var/www/html/public-npm ``` -------------------------------- ### Provisioning Response Example (JSON) Source: https://github.com/superfly/docs/blob/main/reference/extensions_api.html.md This snippet illustrates a typical provisioning response from the Fly.io extensions API. It includes a unique ID for the provisioned resource, a configuration object containing environment variables for the associated Fly.io application, and optionally, the Fly.io application name for Flycast traffic. ```json { "id": "432cb1c9-4d06-4a91-95dc-bc7aa27b896d", "config": { "LOGJAM_URL": "https://user:password@test.logjam.io" }, "name": "logjam-1bd03ba", "fly_app_name": "logjam-production" } ``` -------------------------------- ### API: Get Platform Regions Source: https://github.com/superfly/docs/blob/main/machines/guides-examples/machine-placement.html.md This is an example of how to retrieve information about available regions and their capacity using the Fly.io Machines API. The 'Get Regions' endpoint provides a snapshot of CPU core availability, which can help in planning machine placement. This is typically used programmatically to inform placement decisions. ```http GET https://api.machines.dev/v4/platform/regions ``` -------------------------------- ### List Applications Source: https://github.com/superfly/docs/blob/main/flyctl/cmd/fly_apps_list.md Use this command to list all applications available to the current user. It shows the app name, owner organization, status, and last deployment time. ```bash fly apps list [flags] ``` -------------------------------- ### Check Certificate and DNS Configuration Source: https://github.com/superfly/docs/blob/main/flyctl/cmd/fly_certs_check.md Use this command to view detailed certificate information and verify the DNS configuration for a specified hostname. No specific setup is required beyond having the Fly CLI installed and authenticated. ```bash fly certs check [flags] ``` -------------------------------- ### Create and Activate Virtual Environment (Windows PowerShell) Source: https://github.com/superfly/docs/blob/main/django/getting-started/index.html.md Creates a Python virtual environment named '.venv' using the 'venv' module and then activates it. This isolates project dependencies. ```powershell # Windows (PowerShell) > python -m venv .venv > .venv\Scripts\Activate.ps1 (.venv) ...> ``` -------------------------------- ### Create a New Python Project with Poetry Source: https://github.com/superfly/docs/blob/main/python/the-basics/initial-setup.html.md Initializes a new Python project with the specified application name using Poetry. This command sets up the basic project structure and a `pyproject.toml` file. ```shell poetry new ``` -------------------------------- ### Launch Desktop Commander MCP Server Source: https://github.com/superfly/docs/blob/main/mcp/examples.html.md Launches the Desktop Commander MCP server, which requires a setup step. It uses '--claude' as the host and names the server 'desktop-commander'. ```shell fly mcp launch "npx @wonderwhy-er/desktop-commander@latest" \ --claude --server desktop-commander \ --setup "RUN npx -y @wonderwhy-er/desktop-commander@latest setup" ``` -------------------------------- ### Fly Certs Setup Options Source: https://github.com/superfly/docs/blob/main/flyctl/cmd/fly_certs_setup.md These are the available options for the `fly certs setup` command. The `-a` flag specifies the application name, `-c` the config file path, `-h` for help, and `-j` for JSON output. ```bash -a, --app string Application name -c, --config string Path to application configuration file -h, --help help for setup -j, --json JSON output ``` -------------------------------- ### Setting Database Credentials as Secrets Source: https://github.com/superfly/docs/blob/main/blueprints/n-tier-architecture.html.md This command securely stores your database connection string as an environment secret. Your application can then access this URL to connect to the provisioned PostgreSQL database. ```cmd fly secrets set DATABASE_URL=postgres://:@/ ``` -------------------------------- ### Create App Usage Source: https://github.com/superfly/docs/blob/main/flyctl/cmd/fly_apps_create.md Basic usage for creating a new application on Fly. You must provide an app name. ```bash fly apps create [flags] ``` -------------------------------- ### Dockerfile for Go Application Source: https://github.com/superfly/docs/blob/main/blueprints/using-base-images-for-faster-deployments.html.md A Dockerfile to build a Go application. It installs Go, copies the application code, compiles it, and sets the command to run the compiled binary. This is used as the initial application before creating a base image. ```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" ] ``` -------------------------------- ### Proxy MCP Server with flyctl Source: https://github.com/superfly/docs/blob/main/mcp/deploy-with/fly-launch.html.md This command starts an MCP proxy, allowing you to access and test your MCP server locally. It's a Node.js application, so Node.js must be installed. ```shell fly mcp proxy -i ``` -------------------------------- ### Fly Postgres Help Options Source: https://github.com/superfly/docs/blob/main/flyctl/cmd/fly_postgres.md Displays help information for the postgres command. Use this to see available subcommands and options. ```bash -h, --help help for postgres ``` -------------------------------- ### Deploy Application with Fly.io Source: https://github.com/superfly/docs/blob/main/rails/advanced-guides/machine.html.md This command deploys your application to Fly.io. Ensure you have the Fly.io CLI installed and are authenticated. The command executes the deployment process, and its output indicates success or failure. ```cmd bin/rails deploy ``` -------------------------------- ### Staging-to-Production Promotion Workflow Source: https://github.com/superfly/docs/blob/main/flyctl/integrating.html.md Automate deployments to staging on every push to main and to production when a release is published. Ensure you have separate app names for staging and production. ```yaml name: Deploy on: push: branches: [main] release: types: [published] jobs: staging: if: github.event_name == 'push' runs-on: ubuntu-latest concurrency: deploy-staging steps: - uses: actions/checkout@v4 - uses: superfly/flyctl-actions/setup-flyctl@master - run: flyctl deploy --remote-only -a my-app-staging env: FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }} production: if: github.event_name == 'release' runs-on: ubuntu-latest concurrency: deploy-production steps: - uses: actions/checkout@v4 - uses: superfly/flyctl-actions/setup-flyctl@master - run: flyctl deploy --remote-only -a my-app env: FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }} ``` -------------------------------- ### Start flyctl MCP server with inspector Source: https://github.com/superfly/docs/blob/main/mcp/flyctl-server.html.md Launches the flyctl MCP server with the inspector enabled for interactive exploration. This requires Node.js to be installed on the system. The inspector is accessible via a local web server. ```bash fly mcp server -i ``` -------------------------------- ### Creating Data Tier with Fly Managed Postgres Source: https://github.com/superfly/docs/blob/main/blueprints/n-tier-architecture.html.md This command provisions a new PostgreSQL cluster in the same region as your application, serving as the data tier. It automatically configures monitoring, backups, and failover. ```cmd fly mpg create ``` -------------------------------- ### fly certs setup Source: https://github.com/superfly/docs/blob/main/flyctl/cmd/fly_certs_setup.md Retrieves the necessary DNS record configuration instructions for a specific certificate hostname. ```APIDOC ## GET /certs/setup ### Description Shows setup instructions for configuring DNS records for a certificate. ### Endpoint fly certs setup ### Parameters #### Path Parameters - **hostname** (string) - Required - The hostname for which to show setup instructions. #### Options - **-a, --app** (string) - Optional - Application name - **-c, --config** (string) - Optional - Path to application configuration file - **-h, --help** - Optional - Help for setup - **-j, --json** - Optional - JSON output ### Global Options - **-t, --access-token** (string) - Optional - Fly API Access Token - **--debug** - Optional - Print additional logs and traces - **--verbose** - Optional - Verbose output ``` -------------------------------- ### Run Django Database Migrations (Command Line) Source: https://github.com/superfly/docs/blob/main/django/getting-started/index.html.md Applies pending database migrations for Django's built-in apps. This command sets up the necessary database tables for features like the admin interface. ```cmd python manage.py migrate ``` -------------------------------- ### Create a new organization Source: https://github.com/superfly/docs/blob/main/flyctl/cmd/fly_orgs_create.md Use this command to initialize a new organization. Additional users can be invited to the organization after creation. ```bash fly orgs create [name] [flags] ``` -------------------------------- ### POST /fly/machine/start Source: https://github.com/superfly/docs/blob/main/flyctl/cmd/fly_machine_start.md Starts one or more specified Fly machines. You can provide machine IDs as arguments. ```APIDOC ## POST /fly/machine/start ### Description Starts one or more Fly machines. ### Method POST ### Endpoint /fly/machine/start ### Parameters #### Path Parameters - **id** (string) - Required - The ID(s) of the machine(s) to start. #### Query Parameters - **app** (string) - Optional - Application name. - **config** (string) - Optional - Path to application configuration file. - **access-token** (string) - Optional - Fly API Access Token. - **debug** (boolean) - Optional - Print additional logs and traces. - **verbose** (boolean) - Optional - Verbose output. ### Request Example ```json { "command": "fly machine start", "args": ["machine-id-1", "machine-id-2"], "options": { "app": "my-app", "access-token": "my-token" } } ``` ### Response #### Success Response (200) - **message** (string) - Confirmation message indicating the machines have started. #### Response Example ```json { "message": "Machines machine-id-1, machine-id-2 started successfully." } ``` ```