Setting environment variables does not work for fly launch but works for fly deploy. I have tested on Docker image and Elixir Phoenix application using flyctl v0.0.456 linux/amd64 Commit: 43371b58 BuildDate: 2023-02-08T22:32:29Z
If you can split the command I hope it will help in your case:
The usecase is that we’re trying to provide instructions to our users for quickly launching our product on Fly.
These users aren’t necessarily familiar with Fly (or any kind of hosting provider); so reducing edge-cases, number-of-commands run, and the amount of times they need to edit a config, is a huge benefit.
The main concern is fly launch -e 'PORT=8080'.
It’s a documented feature, but appears to do nothing (for the deploy, or for the config).
I believe, the -e switch merely takes precedence over env vars specified in fly.toml. I don’t think a subsequent call to fly config save (docs) is supposed to pickup variables set with -e from a prior run (afaik, this isn’t mentioned in the docs anywhere), but that’s an interesting and valid expectation. You could consider filing a flyctl feature request on github.