Build and push with unique human-readable tags #2877
Terraform Plan for bazel-trusted 📖
Plan: 0 to add, 1 to change, 0 to destroy.
<details><summary>Show Plan</summary>
Terraform used the selected providers to generate the following execution
plan. Resource actions are indicated with the following symbols:
~ update in-place
Terraform will perform the following actions:
# buildkite_pipeline.create-linux-docker-images will be updated in-place
~ resource "buildkite_pipeline" "create-linux-docker-images" {
+ cluster_name = (known after apply)
id = "UGlwZWxpbmUtLS0wMTkzYjcwZC1hNTgyLTRlZGUtYjZkMi1jMGQxMzUxZWE2NDg="
name = "Create Linux Docker Images"
~ provider_settings = {
~ filter_condition = null -> (known after apply)
~ pull_request_branch_filter_configuration = null -> (known after apply)
# (22 unchanged attributes hidden)
}
~ slug = "create-linux-docker-images" -> (known after apply)
~ steps = <<-EOT
---
priority: 100
steps:
- command: |-
- docker builder prune -a -f
cd buildkite/docker
- [ "$BUILDKITE_BRANCH" = "master" ] || [ "$BUILDKITE_BRANCH" = "testing" ] && git checkout $BUILDKITE_BRANCH
- echo "--- Building docker images..."
- ./build.sh
- echo "--- Pushing docker images..."
- ./push.sh
+ ./build_and_push_with_tag.sh
label: ":pipeline: Create images"
agents:
- "queue=default"
EOT
tags = []
# (11 unchanged attributes hidden)
}
Plan: 0 to add, 1 to change, 0 to destroy.
</details>
Hm, I need to think about this a little more. As currently designed, the change will generate images tagged with e.g. 2026.09.22-1790102428. This is fine in the top-level script (build_and_push_with_tags.sh) since the image tag is pre-calculated and then explicitly passed to both build.sh and push.sh.
There could be a problem with local development though. If a dev is iterating on their machine, each set of images generated by build.sh will have a slightly different timestamp, and a subsequent call to push.sh will calculate its own timestamp, which will be different from any of the tags from build.sh.
I added the timestamp to the tag so that we could more-or-less guarantee unique tags per build.
I've updated build.sh to emit a small metadata file (.image_tag) with the latest successfully-built image tag that push.sh then reads. This should fix the local dev issues.
Please rebase
Rebased!
What if we push multiple images on a single day (possible when testing risky changes)? Maybe we should include hour and minute, too
Nice :)
The date tag is suffixed with the epoch timestamp (from date +%s), so the month and date are implicitly baked in. I should update the comment here. The actual tag will come out like 2026.09.24-1790258222.
Yun and I discussed this a bit today. I'm going to simplify the local dev tagging and use the buildkite build number for the tag suffix in CI builds to make it easier to read.
fweikert
ted-xie
This change will make all future Docker image builds (both automated and manual) tagged with a human-readable tag, such as:
2026.09.22-<epoch timestamp>.Note the change in push.sh: it looks like we're pushing twice the amount of content, but in reality we're only pushing twice the number of _tags_. The total size of the image registry will not balloon significantly with this change.