Skip to main content
GitHub
flydotio

Update app config on Fly.io without rebuilding the image

2024-10-09 in Particles

The way to change an app’s configuration on Fly.io is to run the fly deploy command. If the build section of your config file doesn’t indicate otherwise, fly deploy defaults to building a new Docker image from your source code, but for a simple config change, you don’t need to spend the time or resources on that, nor on running a release command for, e.g., database migrations.

Trimming those steps out is just a matter of a couple of flags (of which fly deploy has many).

To apply the settings in an app’s config file (fly.toml by default), without rebuilding its Docker image:

  1. Find the current image with fly image show.

  2. Then run fly deploy with the --image (or -i) flag to reuse that image:

fly deploy -i <registry>/<repository>:<tag>

e.g.

fly deploy -i registry.fly.io/clutterstack:deployment-01J8Z5SMZH0M4DNE1PMVEGQFB8

If the app has a release command for database migrations or whatever, there’s also a --skip-release-command flag.

Thanks to yet more flags, you can also do the opposite piece. Build a new Docker image and push it to the Fly.io registry without touching your app’s Machines:

fly deploy --build-only --push

I’m not sure there’s a flyctl command to list the images stored in the Fly.io registry for an app. There is a page in the web dashboard, but when I ran this command, my tagged image wasn’t listed. I suspect only images used in deployment releases show up. Nonetheless, when the build finishes, the image reference shows up in the command output, and you can feed that back into a fly deploy -i command to use it.