basecamp / kamal

Deploy web apps anywhere.
https://kamal-deploy.org
MIT License
9.39k stars 359 forks source link

Env merging for destinations doesn't work #803

Closed nuschk closed 3 weeks ago

nuschk commented 1 month ago

I'm trying to upgrade to 1.5.2 from 1.3. In 1.3 (and also 1.4.0), environment variables were joined from the base config to the destination config.

deploy.yml:

env:
  clear:
    DEBUG: False
  secret:
    - SECRET_KEY

deploy.prod.yml:

env:
  clear:
    ENVIRONMENT: production

Running kamal env push -d prod would yield:

SECRET_KEY=<secret_key>
DEBUG=false
ENVIRONMENT=production

With newer versions, starting with 1.5.0, it now looks like this:

SECRET_KEY=<secret_key>

I.e., all clear keys are missing.

Now, while playing with it, I can see that with 1.3, clear env variables were merged, whereas secret ones were replaced (i.e., you couldn't just add a secret env in a particular destination config without having to write out the complete set). Also weird.

Maybe I'm doing it all wrong, in that case, what's the intent here? I liked the merging, as it allowed to declare in the base config which variables would need to be present in ALL environments. But I can also adjust.

Thank you so much for the work on such a great tool!

bjarkevad commented 3 weeks ago

I think this may be related to https://github.com/basecamp/kamal/pull/732 - particularly this:

We'll keep the env file, but now it just contains secrets. The clear values are passed directly to docker run. Which means that the environment is still set for the containers, just not pushed as .env files.

nuschk commented 3 weeks ago

Hah, you're right! I'm sorry, I must've missed the variables in the docker command, I could have sworn they were missing in the final env.

Anyhow, sorry for the ruckus. Thanks for your answer!