Skip to content

Commit

Permalink
(apro) docker.mk: Allow overriding the tag expression on a per-image …
Browse files Browse the repository at this point in the history
…basis
  • Loading branch information
LukeShu committed Aug 14, 2019
1 parent 22d1751 commit e393331
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<!-- -*- fill-column: 100 -*- -->
# Datawire build-aux CHANGELOG

- 2019-08-14: `docker.mk`: Allow overriding the tag expression on a per-image basis.
- 2019-08-14: BREAKING CHANGE: `docker.mk`, `docker-cluster.mk`: Overhaul how tagging an pushing
works, to be more flexible:
* Have to call the `docker.tag.rule` macro, instead of setting the `DOCKER_IMAGE`
Expand Down
11 changes: 10 additions & 1 deletion docker.mk
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,12 @@
# * `$*` is set to SOMEPATH
# * `$<` is set to a file containing the image ID
#
# Additionally, you can override the EXPR on a per-image basis
# by overriding the `docker.tag.name.GROUP` variable on a
# per-target basis:
#
# SOMEPATH.docker.tag.GROUP: docker.tag.name.GROUP = EXPR
#
# - Pushing a tag: You can push tags that have been created with
# `SOMEPATH.docker.tag.GROUP` (see above) by depending on
# `SOMEPATH.docker.push.GROUP`.
Expand Down Expand Up @@ -130,14 +136,17 @@ docker.LOCALHOST = $(if $(filter darwin,$(GOHOSTOS)),host.docker.internal,localh
# TAG_EXPRESSION is evaluated in the context of
# %.docker.tag.TAG_GROUPNAME.
define docker.tag.rule
# The 'foreach' is to handle newlines as normal whitespace
docker.tag.name.$(strip $1) = $(foreach v,$(value $2),$v)

# file contents:
# line 1: image ID
# line 2: tag 1
# line 3: tag 2
# ...
%.docker.tag.$(strip $1): %.docker $$(WRITE_DOCKERTAGFILE) FORCE
# The 'foreach' is to handle newlines as normal whitespace
printf '%s\n' $$$$(cat $$<) $(foreach v,$(value $2),$v) | $$(WRITE_DOCKERTAGFILE) $$@
printf '%s\n' $$$$(cat $$<) $$(foreach v,$$(docker.tag.name.$(strip $1)),$$v) | $$(WRITE_DOCKERTAGFILE) $$@

# file contents:
# line 1: image ID
Expand Down

0 comments on commit e393331

Please sign in to comment.