Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Copy env files to remote hosts #438

Merged
merged 1 commit into from
Sep 7, 2023
Merged

Copy env files to remote hosts #438

merged 1 commit into from
Sep 7, 2023

Conversation

djmb
Copy link
Collaborator

@djmb djmb commented Aug 30, 2023

Setting env variables in the docker arguments requires having them on the deploy host.

Instead we'll add two new commands kamal env push and kamal env delete which will manage copying the environment as .env files to the remote host.

Docker will pick up the file with --env-file <path-to-file>. Env files will be stored under <kamal run directory>/env.

Running kamal env push will create env files for each role and accessory, and traefik if required.

kamal envify has been updated to also push the env files.

By avoiding using kamal envify and creating the local and remote secrets manually, you can now avoid accessing secrets needed for the docker runtime environment locally. You will still need build secrets.

One thing to note - the Docker doesn't parse the environment variables in the env file, one result of this is that you can't specify multi-line values - see moby/moby#12997.

We maybe need to look docker config or docker secrets longer term to get around this.

Hat-tip to @kevinmcconnell - this was his idea.

Docs PR: basecamp/kamal-site#22

djmb added a commit to basecamp/kamal-site that referenced this pull request Aug 31, 2023
@djmb djmb changed the base branch from kamal-run-directory to main September 6, 2023 13:31
Setting env variables in the docker arguments requires having them on
the deploy host.

Instead we'll add two new commands `kamal env push` and
`kamal env delete` which will manage copying the environment as .env
files to the remote host.

Docker will pick up the file with `--env-file <path-to-file>`. Env files
will be stored under `<kamal run directory>/env`.

Running `kamal env push` will create env files for each role and
accessory, and traefik if required.

`kamal envify` has been updated to also push the env files.

By avoiding using `kamal envify` and creating the local and remote
secrets manually, you can now avoid accessing secrets needed
for the docker runtime environment locally. You will still need build
secrets.

One thing to note - the Docker doesn't parse the environment variables
in the env file, one result of this is that you can't specify multi-line
values - see moby/moby#12997.

We maybe need to look docker config or docker secrets longer term to get
around this.

Hattip to @kevinmcconnell - this was all his idea.
@djmb djmb merged commit 6263bf9 into main Sep 7, 2023
6 checks passed
@djmb djmb deleted the remote-env-file branch September 7, 2023 08:34
@acidtib acidtib mentioned this pull request Sep 7, 2023
@snopoke
Copy link

snopoke commented Sep 20, 2023

FYI this broke our deploy since the env files didn't exist and aren't created by deploy. There is also no reference to this change in the docs.

Edit: I see there are some upgrade instructions in the release notes: https://github.com/basecamp/kamal/releases/tag/v1.0.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants