bazel icon indicating copy to clipboard operation
bazel copied to clipboard

Can we have official Bazel Dockerfiles on the Docker Hub?

Open snsokolov opened this issue 7 years ago • 16 comments

Description of the problem / feature request:

Can we have official Bazel Dockerfiles to pull from the Docker Hub?

Feature requests: what underlying problem are you trying to solve with this feature?

Developers, who are just trying to play with Bazel inside of the Docker container, don't have an easy way to do so. They have to search for third_party Dockerfiles available or create their own by learning how to install Java in Docker etc., basically converting https://docs.bazel.build/versions/master/install-ubuntu.html instructions into Dockerfile format each time.

The proposal is to create few official Bazel Dockerfiles, which users can pull from the Bazel official Docker Hub to do their experiments with Bazel.

Something like this:

FROM openjdk:8

RUN echo "deb [arch=amd64] http://storage.googleapis.com/bazel-apt stable jdk1.8" | tee /etc/apt/sources.list.d/bazel.list \
  && curl https://bazel.build/bazel-release.pub.gpg | apt-key add -

RUN apt-get update \
  && apt-get install -y bazel \
&& rm -rf /var/lib/apt/lists/*

Have you found anything relevant by searching the web?

There are many Bazel Dockerfiles on Github, but nothing official yet.

snsokolov avatar Feb 20 '18 02:02 snsokolov

Maybe even an alpine tag...

phedoreanu avatar Jun 14 '18 11:06 phedoreanu

This would be super handy...

AlexHayton avatar Aug 21 '18 16:08 AlexHayton

We recently launched an Ubuntu16.04 based Bazel container under Google Cloud Marketplace. See announcement email here https://groups.google.com/forum/#!topic/bazel-discuss/fKEdrrCUC0s. The container can be directly pulled at l.gcr.io/google/bazel:latest and latest version currently is 0.16.1 (of Bazel).

Instead of using Dockerfiles, we use rules_docker to generate the container using Bazel. Generating images using rules_docker has advantages over using Dockerfile such as 1. don't require root access; 2. don't require docker installed to create the image; and 3. can create deterministic and reproducible images in most cases.

xingao267 avatar Sep 10 '18 19:09 xingao267

@xingao267

we use rules_docker to generate the container using Bazel

If it's not too much trouble, could you attach a link to the build file that does it? I couldn't find one in this or other bazel-related repositories myself.

Monnoroch avatar Nov 22 '18 16:11 Monnoroch

@Monnoroch The target used to generate the ubuntu1604 bazel container is here https://github.com/bazelbuild/bazel-toolchains/blob/master/container/ubuntu16_04/builders/bazel/BUILD.

xingao267 avatar Nov 22 '18 16:11 xingao267

@xingao267, thanks!

Monnoroch avatar Nov 22 '18 16:11 Monnoroch

@xingao267 sorry for asking it here, but seems like the most appropriate issue. When is the 0.20.0 going to be pushed? It's been almost a week since the release was published.

Monnoroch avatar Dec 05 '18 15:12 Monnoroch

@Monnoroch I'm working on it today. Sorry for the delay. It should be published today or tomorrow.

xingao267 avatar Dec 05 '18 15:12 xingao267

@xingao267 any chance can this be done automatically when a new release is created?

The issue is that the local bazel wrapper script automatically updates bazel. I can work around it, of course, but normally I'm totally fine with this behavior. However, this creates a problem: local and CI bazel versions become different. Because of incompatible changes, I'm forced to update some WOKSPACE deps but I can't submit these changes until there's a new official bazel image (well, of course I could build one myself, but it's always nicer to use the official one). So I end up with different versions of deps locally and in CI. Bummer.

Again, all this can be worked around, but using shiny new versions feels so good :)

Monnoroch avatar Dec 22 '18 23:12 Monnoroch

+1 for automatic.

Also I looked the image up and it is still around one gigabyte, which is really a lot to download each time. Is there a way to get bare bones image without the support of all languages? It is a shame, that entire linux image is 50M and this basic infrastructure tool weights 950M extra.

Is it the language support that takes so much space? If so it would be great to have specific images to build specific languages. For example I don't care about building Java or Go. Downloading hundreds of megs just to get a language support that user doesn't need is a waste.

On Sat, Dec 22, 2018 at 3:50 PM Max [email protected] wrote:

@xingao267 https://github.com/xingao267 any chance can this be done automatically when new release is created?

The issue is that the local bazel wrapper script automatically updates bazel. I can work around it, of course, but normally I'm totally fine with this behavior. However, this creates a problem: local and CI bazel versions become different. Because of incompatible changes, I'm forced to update some WOKSPACE deps but I can't submit these changes until there's a new official bazel image (well, of course I could build one myself, but it's always nicer to use the official one). So I end up with different versions of deps locally and in CI. Bummer.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/bazelbuild/bazel/issues/4661#issuecomment-449604664, or mute the thread https://github.com/notifications/unsubscribe-auth/AC_peEasKjHlmCiFTTJ0c3fzNb4KgSd_ks5u7sVegaJpZM4SLVwE .

snsokolov avatar Dec 23 '18 20:12 snsokolov

Is there a way to get bare bones image without the support of all languages?

+1 to that!

Monnoroch avatar Dec 23 '18 21:12 Monnoroch

Thanks @Monnoroch and @snsokolov for your feedback. We are currently working on a more automated process for releasing of all our containers, which, although can't releases the Bazel container instantaneously after a new Bazel release is out, but can reduce the gap to be within 1 or 2 days.

Regarding language specific Bazel containers, we will discuss and evaluate that. During the meantime, you can easily craft one yourself. The general steps are the following:

  1. Clone the bazel-toolchains repo
  2. Modify this BUILD file: a. In the toolchain_container target, remove the layers you do not want. For example, if you just need the clang layer (to build c projects), remove java-ltl, java10-ltl and python-ltl lines. Note that both bazel and bazel tools layers are necessary.
  3. Then you run
bazel run //container/ubuntu16_04/builders/bazel:bazel_{version}

where version being one of the keys from this.

It will create a new container in your local docker registry and you can push it to your own online registry.

If you would like some testing of if the right content for those layers are installed in your container, you can also run the corresponding test target:

bazel test //container/ubuntu16_04/builders/bazel:bazel_{version}-test

But remember to remove the corresponding testing yaml files for the layers you removed from the toolchain_container target.

Hope that helps, Xin

xingao267 avatar Dec 27 '18 16:12 xingao267

@xingao267 Looks like the containers folder does not exist anymore. Is it still possible to create a docker image using this repo?

MikhailTymchukFT avatar Apr 20 '20 10:04 MikhailTymchukFT

@MikhailTymchukFT The new link is https://github.com/GoogleCloudPlatform/container-definitions/blob/master/ubuntu1604_bazel/BUILD

xingao267 avatar Apr 20 '20 15:04 xingao267

any update on this? i just burned 30 minutes trying to figure out how to produce a JSON Key from a gcloud account and the instructions at https://cloud.google.com/container-registry/docs/advanced-authentication#json-key don't work (i have no container role in my account)

would be easier to just docker pull....

parisholley avatar Sep 10 '20 00:09 parisholley

+1 to making this available without authentication. Having to authenticate to use the Bazel image creates a ton of extra hassle in many situations (e.g. configuring a CI workflow to run using that image). It's actually much easier to use Bazel in Docker by using the node image and running npm install -g @bazel/bazelisk.

stabai avatar Aug 05 '22 19:08 stabai

Thank you for contributing to the Bazel repository! This issue has been marked as stale since it has not had any activity in the last 1+ years. It will be closed in the next 90 days unless any other activity occurs or one of the following labels is added: "not stale", "awaiting-bazeler". Please reach out to the triage team (@bazelbuild/triage) if you think this issue is still relevant or you are interested in getting the issue resolved.

github-actions[bot] avatar Oct 10 '23 01:10 github-actions[bot]

This issue has been automatically closed due to inactivity. If you're still interested in pursuing this, please reach out to the triage team (@bazelbuild/triage). Thanks!

github-actions[bot] avatar Jan 08 '24 01:01 github-actions[bot]