kamal
kamal copied to clipboard
starting with just `kamal deploy` fails (no `kamal setup`)
I've manually installed the pre-requisites on the target machine. An initial deploy fails due to a missing .env
file it seems:
INFO [392febf3] Running docker container start traefik || docker run --name traefik --detach --restart unless-stopped --publish 80:80 --volume /var/run/docker.sock:/var/run/docker.sock --env-file .kamal/env/traefik/traefik.env --log-opt max-size="10m" traefik:v2.9 --providers.docker --log.level="DEBUG" on vagrant-box
Releasing the deploy lock...
Finished all in 16.9 seconds
ERROR (SSHKit::Command::Failed): Exception while executing on host vagrant-box: docker exit status: 125
docker stdout: Nothing written
docker stderr: Error response from daemon: No such container: traefik
Error: failed to start containers: traefik
docker: open .kamal/env/traefik/traefik.env: no such file or directory.
See 'docker run --help'.
It's remedied by executing the setup
command first (which is in itself oddly named and I wouldn't expect it to deploy anything). However the docs state that it should not be necessary to run this step. Personally I'm not convinced the server setup should be conflated with the tool itself, but that's a digression.
I agree, lost quite a bit of time before I figured out that if I add additional server roles or accessories I need to run setup
again.
Someone correct me if I'm wrong but I believe running kamal env push
creates the requisite directories on the remote server.
Also you can use kamal server bootstrap
to set up the servers without deploying.
kamal env push
creates the env directories and pushes the distilled .env files for each container as far as I understand. However when I added a new accessory, a simple deploy
didn't work. Maybe it was related to something else. When I nuked everything and retried with setup
then everything started working.
Thank you
Also ran into this issue. The docs make it seem that you only need to do kamal setup
and everything will work, however I do get this same error when I do the setup step only.
It looks like kamal env push
does fix this issue (if you do it before the setup step)
Can someone confirm that this is required? Should the docs be updated? Or is this a bug?
I ran into this error even though the only command I had been running was kamal setup
(as advertised in https://kamal-deploy.org/docs/installation/).
I had to explicitly run kamal env push
to pass this step.
I ran into this error even though the only command I had been running was
kamal setup
(as advertised in https://kamal-deploy.org/docs/installation/).I had to explicitly run
kamal env push
to pass this step.
exact same issue on fresh setup to Digital Ocean Ubuntu 24.04; followed the README and got blocked by the OPs same error. Was only able to resolve after kamal env push
followed by the kamal setup
.. my guess is that the setup setup should be running kamal env push
before running traefik
?
We might need some clarity on the reading of the docs here since this seems to be a pretty common issue.. From my the docs I see the following called out for what kamal setup
is doing
1. Connect to the servers over SSH (using root by default, authenticated by your ssh key).
2. Install Docker and curl on any server that might be missing it (using apt-get): root access is needed via ssh for this.
3. Log into the registry both locally and remotely.
4. Build the image using the standard Dockerfile in the root of the application.
5. Push the image to the registry.
6. Pull the image from the registry onto the servers.
7. Push the ENV variables from .env onto the servers.
8. Ensure Traefik is running and accepting traffic on port 80.
9. Ensure your app responds with 200 OK to GET /up (you must have curl installed inside your app image!).
10. Start a new container with the version of the app that matches the current git version hash.
11. Stop the old container running the previous version of the app.
12. Prune unused images and stopped containers to ensure servers don’t fill up.
From that it seems like Step-7/ kamal env push
should be run before Step-8/ensure Traefik step
In the code for kamal setup
we can see that invoke "kamal:cli:main:envify"
is being called but I believe this should be an invoke to cli:env:push
https://github.com/basecamp/kamal/blob/main/lib/kamal/cli/main.rb#L12-L13
As I'm new to working with kamal
and just trying to wrap my head around the codebase I'd be curious to hear the thoughts of maintainers and @dhh on how this should be addressed (might just be a non-issue).
It's obvious there is history here as the add of envify
to kamal setup
happened at a time when both envify
and env:push
(https://github.com/basecamp/kamal/commit/7cac7e6fb0e77c946ea1f2407cb9677499f69adb).. little bit late here to be groking code but ill revisit release notes, etc tomorrow and sure it'll be clearer.
(possible issue?.. not sure the statement is true
kamal envify
will dokamal env push
for us, so no need to call it ourselves during setup.")
^^ @djmb and others know the codebase much better than I and its probably my mental model is off on how the CLI is working
Reference Links:
@djmb - is this expected behavior? Probably would just need an update to the docs if env push
is now required before setup
will work
Hmm kamal envify
sometimes calls kamal env push
, but not always! That's my mistake. I'll revert that change.
Reverted here - https://github.com/basecamp/kamal/pull/845
Hmm
kamal envify
sometimes callskamal env push
, but not always! That's my mistake. I'll revert that change.
Appreciate the reply and fix! Will confirm on my side by I suspect this should close the original issue as well.
@djmb - confirmed that this is fixed with multiple fresh deploys since the last comment. Had a colleague confirm as well and believe that this issue can be closed.