Skip to content

Deploying Projects on fly.io

We use fly.io to deploy all projects (currently considering moving to a VPS). This guide is a generic guide for deploying a project to fly.io - there will be some parts that will be different depending on the tech stack for the project - in which case, good luck debugging... #not my problem

First, make sure you have flyctl installed.

Deploying the project

  1. git clone the project.
  2. cd into the project.
  3. make a new branch (if you can, follow any conventions that leads want you to follow).
  4. run fly launch on the repo.
  5. if a prompt pops up asking if you want to tweak settings - select yes.

    Settings to be tweaked

    • App name should be <project>-prod - e.g. ayo-prod
    • Organisation should be set to the appropriate project organisation
    • VM memory should be set to 256mb (might be too small?)
    • Everything else should be default
  6. say yes to creating the .dockerignore file.

  7. then, it should automatically deploy (you can also manually do this using fly deploy).

Setting up CD

Inside the repository, there should be a file called .github/workflows/fly-deploy.yml.

It should be already set to be running on every push to main but add workflow_dispatch so that we can run it manually as well.

name: Fly Deploy
on:
  push:
    branches:
      - main
  workflow_dispatch:        # add this line

...

Once this is done, you can make a PR for the branch and merge it into main after setting up the env variables on GitHub.

Setting up GitHub Env Vars

  1. Run fly tokens create deploy from the command line.
  2. On GitHub:
    1. Go to settings -> secrets and variables -> actions -> new repository secret.
    2. Fill in the following:
      • name: FLY_API_TOKEN
      • paste the token into the secrets text field.

Once this is set up, merge your PR to main and it should build and deploy successfully.