kamal icon indicating copy to clipboard operation
kamal copied to clipboard

Bitwarden-Adapter: "bw" cli not found

Open bjesuiter opened this issue 1 year ago • 2 comments

What I want

Being able to fetch secrets via the bitwarden adapter

kamal secrets fetch --adapter bitwarden --account [email protected] --from Kamal/DOCKER_REGISTRY_PASSWORD

My System

  • MacOS Sequoia 15.0.0
  • Mac Book Pro with M3 Max Processor

Try 1: Running the command via the docker alias

alias kamal='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 ghcr.io/basecamp/kamal:latest'

kamal secrets fetch --adapter bitwarden --account [email protected] --from Kamal/DOCKER_REGISTRY_PASSWORD
 ERROR (Errno::ENOENT): No such file or directory - bw

=> The bw cli is probably not present in the kamal docker image

Try 2: mount my local bw cli into the kamal docker

by using -v $HOME/bin/bw:/usr/local/bin/bw

alias kamal-bw='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 -v $HOME/bin/bw:/usr/local/bin/bw ghcr.io/basecamp/kamal:latest'

kamal secrets fetch --adapter bitwarden --account [email protected] --from Kamal/DOCKER_REGISTRY_PASSWORD
Cannot run macOS (Mach-O) executable in Docker: Exec format error
  ERROR (JSON::ParserError): unexpected token at ''

=> I probably cannot run my macOS style bw executable in my linux style kamal docker

Try 3 - installing kamal as ruby gem

Problem 1: The default ruby version of my system is ruby 2.6.10p210 (2022-04-12 revision 67958) [universal.arm64e-darwin24] => too old for some dependencies

Problem 2: Installing newer ruby via "internet-recommended" rvm fails, because compilation fails for some reason for Mac 15.0/Arm64

Conclusion

There are more methods of setting up ruby, but I normally don't need a full ruby stack installed and I don't want to get into the weeds of this.

Also: the kamal docker image should work "out-of-the-box" in my opinion, providing the bw cli itself if it needs it.

bjesuiter avatar Oct 06 '24 18:10 bjesuiter

Update - solved via workaround

Works when I install the gem version with a ruby setup in homebrew:

brew install ruby 

# in your .zshrc 

# Ruby Setup - via brew
export HOMEBREW_PREFIX="$(brew --prefix)";
if [ -d "${HOMEBREW_PREFIX}/opt/ruby/bin" ]; then
  export PATH="${HOMEBREW_PREFIX}/opt/ruby/bin:$PATH"
  export PATH=`gem environment gemdir`/bin:$PATH
fi

But I still think that the alias version with docker should work out of the box

bjesuiter avatar Oct 06 '24 19:10 bjesuiter

@bjesuiter I've submitted the Dockerfile enhancement PR below:

  • #1075

Also pushed this update to DockerHub repository. If you'd like to use it, feel free to pull from here:

docker pull ptuladhar/kamal:latest

Forked repository: https://github.com/tuladhar/kamal

tuladhar avatar Oct 08 '24 05:10 tuladhar

I've updated the docs with a page on the limitations of running Docker in Kamal - https://kamal-deploy.org/docs/installation/dockerized/

djmb avatar Jan 20 '25 11:01 djmb

Closing this as it is a limitation of running Kamal via Docker rather than a bug.

djmb avatar Apr 18 '25 12:04 djmb