Deploy to Flydotio

In this short guide, we will discuss how to deploy to . allows users to deploy apps and databases close to users.

Getting started

Create an account on and install the CLI.


The primary way to interact with the platform is via CLI. Follow the instructions here to install the CLI.


The project comes with an example fly.toml config file with all the settings you need to deploy to . Let’s go over the main sections.

app = "x40"
primary_region = "lax"
kill_signal = "SIGINT"
kill_timeout = "5s"

  auto_rollback = true

  dockerfile = "./Dockerfile"

  release_command = "/"

  DJANGO_SETTINGS_MODULE = "config.settings.production"
  PORT = "8080"
  CDN_URL="" # has scheme
  S3_ENABLED = "True"

  app = "uvicorn config.asgi:application --host --port 8080"
  worker = "python run_huey"

  protocol = "tcp"
  internal_port = 8080
  processes = ["app"]

    port = 80
    handlers = ["http"]
    force_https = true

    port = 443
    handlers = ["tls", "http"]
    type = "connections"
    hard_limit = 25
    soft_limit = 20

    interval = "15s"
    timeout = "2s"
    grace_period = "1s"
  • build - this is where you specify your Dockerfile. Notice we are referencing the Dockerfile included in the project’s ops folder. There is one small change you will have to make to the Dockerfile.

  • app - this is your unique app name. You will be prompted to add one later when you launch the app.

  • deploy - this is the release command that will be run when you deploy the app. A basic deployment is: build image → push to fly registry → deploy → run release task. In our case, the release task will run migrations and collect static files to S3 or R2 if like to live on the bleeding edge.

  • process - this section defines your app’s processes. In our case, we are running the web server and the background worker.

  • services - this section includes configuration for mapping application ports to the flu platform. In our example, the web service exposed on port 8080 in the Dockerfile will be mapped to the external port 80 .

Env Variables and Secrets

Add your environment variables to the fly.toml file and set any secrets using fly secrets set SECRET_NAME=secret OTHER_SECRET=next. You are now ready to launch and deploy your app.

Create a new app

Run the following to create a new app and launch it on . Follow the instructions and respond to the CLI prompts. When asked to create a new database cluster on , create a new cluster, and it will be automatically attached to the app.


$ flyctl launch --vm-memory=1024

> An existing fly.toml file was found for app project
? Would you like to copy its configuration to the new app? (y/N) 

$ y

You can respond ‘y’ to this prompt. Fly will reuse the configuration already specified in the file. It will replace the app name with an automatically generated one or a new one if you specify it.

I have noticed that Fly will replace the [build].. section during this process. Make sure it is still available after you have finished setting up your app.

Postgres Cluster

Remember to take note of the Postgres cluster credentials. They will only be shown once. You can create multiple databases in the same cluster.

Postgres on flydotio

Postgres on fly is NOT a managed database. Please be aware of this if you have selected as your host. You will have to manage backups, maintenance, and upgrades. See the post below on PG backups.

Further Reading