I am building a google-cloud-sdk base-image and I am trying to keep it lean.
ARG GCLOUD_SDK_VERSION=285.0.1-alpine
FROM google/cloud-sdk:$GCLOUD_SDK_VERSION
# Install Java 8 for Datastore emulator
RUN apk add --update --no-cache \
openjdk8-jre
RUN gcloud components install \
cloud-datastore-emulator \
pubsub-emulator \
beta \
--quiet
...
So far everything is fine. And when I build and look at the output of the gcloud components install command I feel confident:
┌──────────────────────────────────────────────────┐
│ These components will be installed. │
├──────────────────────────┬────────────┬──────────┤
│ Name │ Version │ Size │
├──────────────────────────┼────────────┼──────────┤
│ Cloud Datastore Emulator │ 2.1.0 │ 18.4 MiB │
│ Cloud Pub/Sub Emulator │ 2019.09.27 │ 34.9 MiB │
│ gcloud Beta Commands │ 2019.05.17 │ < 1 MiB │
└──────────────────────────┴────────────┴──────────┘
My final image size, however, is shocking: 1.11GB. When I look at docker history I see that the component installation actually contributed 654MB to the final image size:
CREATED BY SIZE
/bin/sh -c gcloud components install … 654MB
/bin/sh -c apk add --update --no-cache … 78.2MB
I am currently assuming it has something to do with the final line of the installation process.
╔════════════════════════════════════════════════════════════╗
╠═ Creating backup and activating new installation ═╣
╚════════════════════════════════════════════════════════════╝
That appears to be a nice thing to have on your local workstation but not in a docker image. I tried to see if I can deactivate this backup or delete it afterward. There was no helpful paragraph in the man pages and searching online always directs me to some cloud database backup procedures you can initiate using gcloud commands.
Does anyone have further knowledge about what is happening here? Maybe it is not the backup at all that is contributing to most of the overhead?