kamal icon indicating copy to clipboard operation
kamal copied to clipboard

Kamal setup fails (version 2.0.0.rc3 from docker)

Open a3kov opened this issue 1 year ago • 1 comments

Looks like there's a problem with secrets - the registry password is empty. I have proper .env file in the project directory containing KAMAL_REGISTRY_PASSWORD=mypassword

$ kamal setup
  INFO [4a37da09] Running /usr/bin/env mkdir -p .kamal on 1.2.3.4
  INFO [4a37da09] Finished in 5.948 seconds with exit status 0 (successful).
Acquiring the deploy lock...
Ensure Docker is installed...
  INFO [312bfcba] Running docker -v on 1.2.3.4
  INFO [312bfcba] Finished in 1.201 seconds with exit status 0 (successful).
  INFO [05559197] Running docker login registry.gitlab.com -u [REDACTED] -p [REDACTED] on 1.2.3.4
Releasing the deploy lock...
  Finished all in 9.5 seconds
  ERROR (SSHKit::Command::Failed): Exception while executing on host 1.2.3.4: docker exit status: 125
docker stdout: Nothing written
docker stderr: flag needs an argument: 'p' in -p
See 'docker login --help'.

a3kov avatar Sep 25 '24 02:09 a3kov

@a3kov - the secrets have moved in Kamal 2.0 - you should put them in .kamal/secrets instead now.

djmb avatar Sep 26 '24 10:09 djmb

Yes, I have KAMAL_REGISTRY_PASSWORD=$KAMAL_REGISTRY_PASSWORD I thought Kamal will read the .env file to substitute $KAMAL_REGISTRY_PASSWORD. Do I need to provide environment variables myself now ? That was totally unexpected

a3kov avatar Sep 26 '24 18:09 a3kov

Ok, now after reading https://github.com/basecamp/kamal/pull/924 it's a bit more clear..

a3kov avatar Sep 26 '24 19:09 a3kov

Hmm, after making KAMAL_REGISTRY_PASSWORD variable available in the current environment, it still doesn't work (same symptoms). Any ideas ?

a3kov avatar Sep 26 '24 19:09 a3kov

To anyone having the same problem: if you run Kamal from docker, you have to pass the environment inside the container, otherwise it won't be available to the Kamal process.

a3kov avatar Sep 26 '24 19:09 a3kov

I actually had multiple issues with the docker version of Kamal so I switched to the gem one. It seems nobody tests if the docker version even works

a3kov avatar Sep 26 '24 21:09 a3kov

To anyone having the same problem: if you run Kamal from docker, you have to pass the environment inside the container, otherwise it won't be available to the Kamal process.

Thank you for mentioning this! If all your Kamal env vars begin with KAMAL_, you can pass them to the container cleanly like this (MacOS version; the Linux one is slightly different, see Installation):

docker run -it --rm \
    -v "${PWD}:/workdir" \
    -v "/run/host-services/ssh-auth.sock:/run/host-services/ssh-auth.sock" \
    -e SSH_AUTH_SOCK="/run/host-services/ssh-auth.sock" \
    -v /var/run/docker.sock:/var/run/docker.sock \
    --env-file <(env | grep '^KAMAL_') \
    ghcr.io/basecamp/kamal:latest "$@"

mgax avatar Oct 25 '24 20:10 mgax

I've hit this several times too. Surprising that this happens given the assertion of registry.password's presence here.

andrewjanssen avatar Nov 15 '24 17:11 andrewjanssen

if anyone is running into this when just trying to set up kamal to deploy. Since the env vars are not loaded yet, we get this issue. I use dotenv so doing dotenv kamal secrets print adds the env vars for me.

santy18 avatar Nov 20 '24 06:11 santy18

So, I went to deploy today and now, KAMAL_REGISTRY_PASSWORD does not show up if I do either dotenv kamal secrets print or kamal secrets print Screenshot 2024-12-19 at 9 53 16 PM

When I add another letter to the env var it does show up.

Any idea what this could be? it was working well a while back :(

santy18 avatar Dec 20 '24 02:12 santy18