So you have done a “bad” deploy.
Don’t panic. Everyone does one at some point, we’ve all been there. We don’t have a full UI-integrated rollback system, but it does not mean you can’t roll back. Actually you can and it’s not that hard. See for yourself:
Most common case, you’ve only made a (bad) change in your app’s code that you want to revert:
We do keep your previous app’s image builds. To see them, run:
fly releases --image
Spot a previous release you want to redeploy, find its image name in the
DOCKER IMAGE column, and run:
fly deploy -i <image-name>
(The image name should be like
Shortcut: if you have
jq installed, the steps above can be combined in this one-liner:
fly deploy -i `fly releases -j | jq "..ImageRef" -r`
→ You’re saved!
If also you want to be able to revert changes made to your app’s configuration (services, env…), keep reading for an idea of a more resilient deployment process:
We keep your app’s previous builds, but your app’s configuration (stuff that’s in your
fly.toml like services, environment variables…) is harder to retrieve. But here’s an idea: you can easily™ run a command to back up your
fly.toml contents as you deploy:
Instead of just running
fly deploy you can run (assuming you have
mkdir -p fly_deployments && \ export FLY_DEPLOY_DATE=`TZ=GMT date +"%Y-%m-%dT%H:%M:%SZ"` && \ cp fly.toml fly_deployments/"$FLY_DEPLOY_DATE"_fly.toml && \ fly deploy && \ echo "\n\n[build]\n image = \"`fly releases -j | jq "..ImageRef" -r`\"\n" >> fly_deployments/"$FLY_DEPLOY_DATE"_fly.toml
What this does is:
- back up your config
fly.tomlin a local
fly_deploymentsfolder by prepending the ISO8601-formatted date and time of the deployment to the backup filename (
- get the build & deployed image name, and append it to the backed-up
→ This way if you want to roll back later (including services, environment variables…), all you need to do is:
fly deploy -c fly_deployments/DATE_OF_PREVIOUS_DEPLOYEMENT_fly.toml
This will use the previously backed up
fly.toml config, that will include previous services, env. vars… and your previously built app image!
Now tell us what you think! What’s your experience about rollbacks? What do you dream / have nightmares of?