Fix Docker image pre-pulling for arm64 Linux VMs     (#3014)

Before we pinned `@sha256:...` digests in `setup-docker.sh`, a line like
`docker pull "gcr.io/bazel-public/ubuntu2204"` automatically detected
the machine's CPU architecture and downloaded only the `amd64` image on
`x86_64` VMs, or only the `arm64` image on `arm64` VMs.

After pinning `@sha256:...` digests, `setup-docker.sh` unconditionally
pulled `amd64` `@sha256` digests on both `x86_64` and `aarch64` VMs,
causing `arm64` Linux agents to miss local Docker image caches on every
job. for example, in
[here](https://buildkite.com/bazel/bazel-bazel/builds/38292#01a1ca3f-48f4-4738-8b01-4c27a70a23c7)
the agent had to download and extract ~1 GB of layers from scratch,
adding ~18 seconds to job startup).

Fix:
In `setup-docker.sh`, we check the arctecture (the same check already
used earlier in that script) and pull the `arm64` digests from
`digests.json` on `arm64` machines, while pulling the `amd64` digests on
`x86_64` machines.
Because `update_docker_image_hashes.py` already loops over both `amd64`
and `arm64` hashes in `digests.json` and replaces matching strings in
`setup-docker.sh`, it will automatically keep both lists updated with
zero changes to the Python script.
1 file changed