FR: Allow passing substitutions directly to pusher
🚀 feature request
Relevant Rules
Description
container_push is a bit of an odd duck. The README suggests using bazel stamping or --define flags to vary where images get pushed.
Both of these options have unfortunate consequences for the cache such that pushing a large number of images is very slow.
Common scenarios where this pops up:
- I want to push to multiple regions.
- I want multiple tags for my image.
- I have multiple environments (dev, staging, prod) that I want to manage.
If all of these apply to you, you may end up with O(100s) of pushes, so it's important not to blow away the cache.
Describe the solution you'd like
I propose adding a --subtitutions flag that takes key-value pairs to augment the existing stamper.
container_push(
name = "publish",
registry = "{REGION}-docker.pkg.dev",
repository = "my-project/my-image/example",
tag = "{VERSION}",
)
for region in $(gcloud artifacts locations list --format='value(name)'); do
bazel run :publish -- --substitutions=REGION="${region}",VERSION=v2
done
Happy to bikeshed on the exact flag name.
Describe alternatives you've considered
It's technically possible to do this today with the --stamp-info-file flag, e.g. something like:
for region in $(gcloud artifacts locations list --format='value(name)'); do
bazel run :publish -- --stamp-info-file=<(echo REGION "${region}"; echo VERSION v2)
done
However, I see two issues with this approach:
- The added indirection with having to produce a file is fairly cumbersome, and I'd rather just pass key-value pairs directly.
- This method relies on the same flag value that stamping uses, which we might want to have different behavior from the user-provided substitutions. Having this be a separate flag with expected documented usage under here would give us more flexibility to modify stamping.
This issue has been automatically marked as stale because it has not had any activity for 180 days. It will be closed if no further activity occurs in 30 days. Collaborators can add an assignee to keep this open indefinitely. Thanks for your contributions to rules_docker!
This issue was automatically closed because it went 30 days without a reply since it was labeled "Can Close?"