I’m exploring the GitHub / Fly.io integration and Launch UI to figure out whether auto-deploy on push to GitHub is right for me.
My fly org has two apps, designated staging
and production
.
Both apps share a single Github repo and a single fly.toml
file.
The shared fly.toml
file omits the app
key, and instead expects the --app
argument to be provided at deploy time, indicating the target for the deployment:
fly deploy --app staging # deploy to staging
fly deploy --app production # deploy to production
Question 1
From the Launch UI, when I connect the staging
app to the GitHub repo (that has an existing fly.toml
file with no app
key), does it infer the app
based on which Fly app it is connected to?
Or is it mandatory for the app
key to be specified in fly.toml
when using the GitHub integration?
Question 2
When deploying with the CLI, my Dockerfile
expects a --build-arg
that indicates the base image version to use:
fly deploy --build-arg NODE_VERSION=X.y.z
# Dockerfile
ARG NODE_VERSION
FROM node:${NODE_VERSION}-alpine
The intention here is to replicate something similar to how Heroku’s nodejs buildpack works (which auto-detects the version of node to use from the engines.node
property in package.json
).
For reference, here’s what a Heroku build log looks like, showing it detecting the node/npm versions to use:
-----> Building on the Heroku-24 stack
-----> Deleting 15 files matching .slugignore patterns.
-----> Using buildpack: heroku/nodejs
-----> Node.js app detected
-----> Installing binaries
engines.node (package.json): 22.11.0
engines.npm (package.json): 10.9.1
Resolving node version 22.11.0...
Downloading and installing node 22.11.0...
Bootstrapping npm 10.9.1 (replacing 10.9.0)...
npm 10.9.1 installed
My deploy commands are defined as npm scripts that read the engines.node
version and pass it as a --build-arg
:
{
"scripts": {
"deploy": "fly deploy --build-arg NODE_VERSION=$npm_package_engines_node",
"deploy:staging": "npm run deploy -- --app staging",
"deploy:production": "npm run deploy -- --app production"
},
"engines": {
"node": "22.11.0"
}
}
Of course, I could simply specify this in fly.toml
:
[build.args]
NODE_VERSION="22.11.0"
…but I’m trying to avoid having multiple places that need to be updated when the version of Node changes, and I like the idea of engines.node
being the canonical place to store this.
With all that said, does this suggest that auto-deploy on push to GitHub is unlikely to work in my scenario given that I’m providing both --app
and --build-arg
at deploy time?
Question 3
When linking the staging
app and GitHub repo through the Launch UI, it creates a production
environment in GitHub that deploys go to.
Can the GitHub environment name be changed to staging
, or does the Fly.io integration specifically need an environment named production
?