rules_docker icon indicating copy to clipboard operation
rules_docker copied to clipboard

Allow set `container_image` labels by json file

Open bozaro opened this issue 2 years ago • 5 comments

PR Type

What kind of change does this PR introduce?

  • [ ] Bugfix
  • [x] Feature
  • [ ] Code style update (formatting, local variables)
  • [ ] Refactoring (no functional changes, no api changes)
  • [ ] Build related changes
  • [ ] CI related changes
  • [ ] Documentation content changes
  • [ ] Other... Please describe:

What is the new behavior?

Allow set docker labels by .json file.

Does this PR introduce a breaking change?

  • [ ] Yes
  • [x] No

bozaro avatar Jan 12 '23 06:01 bozaro

Is there an issue open where this feature has been discussed? Could you explain why this may be useful?

uhthomas avatar Jan 13 '23 23:01 uhthomas

Is there an issue open where this feature has been discussed? No.

Could you explain why this may be useful? We use file for labels in two places:

  • set Docker labels for image garbage collector policy (we have differ policy for master and feature-branches. Branch type passed by stable stamping variables);
  • set marker for "upload if not uploaded yet" logic.

Little bit about "upload if not uploaded yet" workflow:

  • we check image in docker registry with upload marker (some uniuqe for build value) and return passed upload marker if image is not uploaded or image marker from uploaded image;
  • upload marker passed to labels;
  • rule makes push to registry.

As a result, we get the following effect:

  • initially image will be upload to registry;
  • if image already in registry, we got CACHE HIT (same image and upload marker) and push step will be skipped without downloading all layers to worker;
  • if image was remove from registry by GC, we got CACHE MISS (same image but new upload marker) and it will be upload.

bozaro avatar Jan 16 '23 06:01 bozaro

This Pull Request 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!

github-actions[bot] avatar Jul 16 '23 03:07 github-actions[bot]

Changes:

  • rebased to master;
  • use labels_file attribute instead of reusing label_files attribute.

bozaro avatar Jul 19 '23 07:07 bozaro