1
votes

I want to run a k8s_objects Bazel rule from a Google Cloud Build step, which deploys new configurations to my cluster. Hence I need a Docker image with

  • bazel (obviously for running bazel targets)
  • kubectl (for applying new configuration to my cluster)
  • gcloud (for authenticating to my Google Kubernetes Engine cluster)

installed. Currently I have this huge docker image which is 1GB in size and probably cluttered with stuff I don't need. Therefore my build times skyrocket to 10 minutes and more.

This is how my cloudbuild.yaml looks like:

steps:
  - name: eu.gcr.io/cents-ideas/slim-bazel-kubectl
    entrypoint: /bin/sh
    args:
      - -c
      - |
        gcloud container clusters get-credentials cents-ideas --zone europe-west3-a --project cents-ideas

What would a small docker image with only the packages I need look like?

1
An example of a smaller Dockerfile that has bazel, kubectl and gcloud you can find here.Deniss Tsokarev
awesome, I'll try that! :)Florian Ludewig
I think this image is out of date. Getting error: COPY failed: stat /var/lib/docker/tmp/docker-builder613695822/gcloud.pub.gpg: no such file or directoryFlorian Ludewig
Please double check because the COPY instruction in the Dockerfile copies the files in src to dest folder. You must be either missing the gcloud.pub.gpg file or building the Dockerfile from the wrong directory.sllopis

1 Answers

0
votes

Currently I use the image below. However it doesn't have kubectl installed

FROM ubuntu:18.04

RUN apt-get update
RUN apt-get -y install curl gnupg unzip python python3 git build-essential

# nodejs
RUN apt-get -y install nodejs

# yarn
RUN curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - && \
  echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list && \
  apt-get update && apt-get -y install yarn

# bazelisk
RUN yarn global add @bazel/bazelisk --prefix /usr/local && bazelisk version

WORKDIR /app

ENTRYPOINT [ "bazelisk" ]