Setting environment variables in fly.toml and on the CLI when deploying

If I run fly deploy, it looks like the app gets the environment variables set in fly.toml. However, if I run fly deploy --env APP_VERSION=$git_hash, the app only gets the FOO environment variable. I would like to pass in the APP_VERSION variable on the command line in our CI, and the rest in the fly.toml file because they don’t change.

I’d suggest setting this as a build argument.

Set it as an environment variable in your Dockerfile (assuming you’re using one):

# ...
# default value of "unknown"
ARG APP_VERSION=unknown
ENV APP_VERSION=$APP_VERSION
# ...

Deploy using --build-arg:

flyctl deploy --build-arg APP_VERSION=$git_hash

If you’re not using a Dockerfile, then it’s trickier.

This could be a good feature to have :thinking:.