GoogleCloudPlatform / cloud-sdk-docker

Google Cloud CLI Docker Image - Docker Image containing the gcloud CLI and its bundled components.
https://cloud.google.com/sdk/docs/downloads-docker
Apache License 2.0
746 stars 231 forks source link

So bloated #297

Open twocs opened 1 year ago

twocs commented 1 year ago

I literally only want to use gcloud auth with a service account that can push to a bucket. Yet the smallest image available is over 200MB. Please make images that give gcloud auth and absolutely nothing else.

Wallman commented 11 months ago

Agree, size is an issue! We are facing long CI pipelines because of this

nroose commented 10 months ago

Seems clear that Google needs the money that they charge us for downloading the additional size. Just really atrocious.

anindyatahsin commented 4 months ago

A new version of docker image (use tag :stable-alpha) with a much smaller footprint is now available for testing. Please feel free to test the image out and provide feedback as appropriate.

To pull the new image use: docker pull gcr.io/google.com/cloudsdktool/google-cloud-cli:stable-alpha

nroose commented 4 months ago

I am trying to figure out how to try this. We currently mostly use other images and install gcloud sometimes on those images, to use things like docker and use gcloud for auth and configure docker. Is there some way to do the install that is also smaller? Thank you!

twocs commented 4 months ago

I am trying to figure out how to try this. We currently mostly use other images and install gcloud sometimes on those images, to use things like docker and use gcloud for auth and configure docker. Is there some way to do the install that is also smaller? Thank you!

If you want to continue to use other images and install gcloud, it might be useful to look at their Dockerfile, which is here for stable-alpha: https://github.com/GoogleCloudPlatform/cloud-sdk-docker/blob/master/stable/Dockerfile

For some of the Dockerfile (e.g. Google AppEngine Base) https://github.com/GoogleCloudPlatform/cloud-sdk-docker/blob/master/google_appengine_base/Dockerfile) they do this step, which seems fairly efficient:

RUN wget https://dl.google.com/dl/cloudsdk/channels/rapid/google-cloud-sdk.zip && unzip google-cloud-sdk.zip && rm google-cloud-sdk.zip

Alternately, for some tasks we are able to skip the Gcloud image. For example, to push an image to GCP, since docker has login:

            - echo ${GCLOUD_API_KEYFILE} | base64 -d > /tmp/gcloud-api-key.json
            - cat /tmp/gcloud-api-key.json | docker login -u _json_key --password-stdin https://gcr.io
            - docker image push $IMAGE_NAME

We are still using the cloud SDK for authenticated actions with kubectl. Would really love a Docker image or other method that allows the authenticated actions with kubectl without any other portion of the Google Cloud SDK.

anindyatahsin commented 2 weeks ago

Hi @twocs, The new :stable image is the smallest gcloud cli image that is available right now. The size of the image is significantly smaller than the other existing docker images (25% smaller than the :alpine, 63% smaller than the :slim and 93% smaller than the :latest gcloud cli image). The stable image also have the lowest number of CVEs so it is the most secure among the existing docker images. Hope this new image helps your use case.