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 .
2 Likes
I need the same!! I will do this!
But it seems like a really nice feature.
Maybe have the ability to add this type of data to the release?
❯ fly releases -a [app_name] --json
[
{
"ID": "ID_HERE",
"Version": 103,
"Stable": true,
"InProgress": false,
"Reason": "release",
"Description": "Deploy image",
"Status": "succeeded",
"DeploymentStrategy": "",
"Metadata": { # some new attribute like this
"GitHash": "asdasdasdasdadsadasdasd"
},
"User": {
"ID": "ID_HERE",
"Name": "Federico Otaran",
"Email": "otaran.federico@gmail.com"
},
"CreatedAt": "2021-12-01T14:56:08Z"
},
...
]
1 Like
I also need this, and was extremely confused for a couple of hours when fly deploy
suddenly started silently ignoring the [env]
section of my fly.toml file when I added -e FOO=bar
to my deploy command.
This bug was filed a while ago but hasn’t been addressed yet. I’ll bump it’s priority as it keeps coming back to haunt people.