Create a static website on Fly

Getting an application running on Fly is essentially working out how to package it as a deployable image. Once packaged it can be deployed to the Fly infrastructure to run on the global application platform.

In this guide we'll learn how to deploy a static site on Fly.

The HelloStatic Site

Our example will be a be hosting a HTML file. There's no need for any tools. Feel free to add in any HTML files you'd like to serve too.

Either use an existing directory with an index.html, or clone our example from the hellostatic Github repository. Just git clone to get a local copy. Here's all the code for our index.html:

      Hello from Fly
    <h1>Hello from Fly with a static web site</h1>

Install Flyctl and Login

We are ready to start working with Fly and that means we need flyctl, our CLI app for managing apps on Fly. If you've already installed it, carry on. If not, hop over to our installation guide. Once that's installed you'll want to log in to Fly.

Configuring the App for Fly

Each Fly application needs a fly.toml file to tell the system how we'd like to deploy it. The fly.toml can be automatically generated with flyctl launch.

flyctl launch
Creating app in /apps/hello-static
Scanning source code
Detected a Static app
? App Name (leave blank to use an auto-generated name):
? Select organization: flyorg (flyorg)
? Select region: lax (Los Angeles, California (US))
Created app hellostatic in organization flyorg
Wrote config file fly.toml
? Would you like to deploy now? Yes

Next you'll be prompted for an organization. Organizations are a way of sharing applications between Fly users. When you are asked to select an organization, there should be one with your account name; this is your personal organization. Select that.

Viewing your static site

The quickest way to browse your newly deployed application is with the flyctl open command.

flyctl open

Your browser will be sent to the displayed URL. Fly will auto-upgrade this URL to an HTTPS secured URL.