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
git clonethe project.cdinto the project.- make a new branch (if you can, follow any conventions that leads want you to follow).
- run
fly launchon the repo. -
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
- App name should be
-
say
yesto creating the.dockerignorefile. - 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.
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
- Run
fly tokens create deployfrom the command line. - On GitHub:
- Go to
settings->secrets and variables->actions->new repository secret. - Fill in the following:
- name:
FLY_API_TOKEN - paste the token into the
secretstext field.
- name:
- Go to
Once this is set up, merge your PR to main and it should build and deploy successfully.