GoogleCloudPlatform / GoogleCloudPlatform/cloud-builders

Docs refer to stale bazel-provided images, new images aren't compatible with Cloud Build

Open
#927 3 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
Go
Stars
1.5k
Forks
616
PR merge metrics
No merged PRs in 30d

Description

A couple of the READMEs refer to `gcr.io/cloud-marketplace-containers/google/bazel` as alternative images provided by the bazel team, but it looks like this repo hasn't been updated since 2020.

The [bazel docs](https://bazel.build/install/ubuntu) now point at `gcr.io/bazel-public/bazel` which does seem to be up-to-date.

However, I was unable to get these images to work as a drop-in replacement with Cloud Build.

Small example:

```yaml
steps:
- id: 'Bazel version'
name: 'gcr.io/bazel-public/bazel:6.2.1'
entrypoint: 'bazel'
args: ['version']
```

Gives:

```
Step #0 - "Bazel version": Status: Downloaded newer image for [gcr.io/bazel-public/bazel:6.2.1](http://gcr.io/bazel-public/bazel:6.2.1)
Step #0 - "Bazel version": [gcr.io/bazel-public/bazel:6.2.1](http://gcr.io/bazel-public/bazel:6.2.1)
Step #0 - "Bazel version": FATAL: mkdir('/builder/home/.cache/bazel/_bazel_ubuntu'): (error: 13): Permission denied
Finished Step #0 - "Bazel version"
```

I think this is because the bazel [Dockerfile](https://github.com/bazelbuild/continuous-integration/blob/master/bazel/oci/Dockerfile) is setting up an `ubuntu` user rather than running as root. Another consequence of this is that `/workspace/` is not writeable which makes it painful to pass around outputs between build steps.

One workaround for the cache issue is to pass `--output_user_root` like this:

```yaml
steps:
- id: 'Bazel version'
name: 'gcr.io/bazel-public/bazel:6.2.1'
entrypoint: 'bazel'
args: ['--output_user_root=/home/ubuntu/.bazel', 'version']
```

But that still doesn't resolve the `/workspace/` issues.

So how should the cloud-builders READMEs be updated? I can send a PR to update the stale reference to gcr.io/bazel-public/bazel, but as the images are not drop-in replacements I think it would cause more confusion.

Maybe https://github.com/GoogleCloudPlatform/cloud-builders/blob/master/bazel/README.md can provide a bit more detail and the top-level README could point there?

Maybe there's a deeper compatibility issue which needs resolving? It is surprising that two Google-maintained bits of build infrastructure don't play nicely together.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.