whalebrew/whalebrew

Allow to expose multiple executable commands from a single docker image

creasty opened this issue · 2 comments

Why

Google Cloud SDK, for example, contains multiple executable files -- bq, gcloud, and gsutil.
Without being able to expose each commands (meaning create files in /usr/local/bin), we have to create individual docker images for them, which is ridiculous.

What

So here's my naive suggestion:

# Specify which commands to expose:
LABEL io.whalebrew.config.commands '["bq", "gcloud", "gsutil"]'

# And to configure volumes and ports:
LABEL io.whalebrew.config.command.bq.volumes ...
LABEL io.whalebrew.config.command.bq.ports ...
LABEL io.whalebrew.config.command.gcloud.ports ...
...

But it may brings a sort of complexity, wanna hear ur opinion.

Yes, this make it rather complicated. I rather like the idea of enforcing the concept of a package == a command. Ideally, they'd be the same name too, which reduces the cognitive overhead of trying to figure out the name of the command you just installed, and make it much easier to discover commands you want to install.

How about just using separate packages for the Google Cloud packages? brew install gcloud and brew install kubectl, in the case of whalebrew/whalebrew-packages#23.

Thanks for the comment.

Turned out that a single executable and aliases are all I needed.
And supposedly the problem I had was not meant for whalebrew to solve.

#!/usr/bin/env bash

set -eu
set -o pipefail

docker run \
  --rm \
  -it \
  -w /workdir \
  -v `pwd`:/workdir \
  -e "K8S_SERVER=${K8S_SERVER:-}" \
  -e "K8S_TOKEN=${K8S_TOKEN:-}" \
  google/cloud-sdk:latest \
  "$@"
alias gcloud='google-cloud-sdk gcloud'
alias gsutil='google-cloud-sdk gsutil'
alias bq='google-cloud-sdk bq'
alias kubectl='google-cloud-sdk kubectl'