Skip to content

Commit 57ff4e6

Browse files
authored
Merge pull request #15 from devilbox/improve-pull-image
Allow for shell variables in docker FROM tag
2 parents 72d40dd + d77607c commit 57ff4e6

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

Makefile.docker

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -198,15 +198,18 @@ docker-load:
198198
# -------------------------------------------------------------------------------------------------
199199
.PHONY: docker-pull-base-image
200200
_DOCKER_PULL_BASE_IMAGES_FOUND = $(shell grep FROM $(DIR)/$(FILE) | sed 's/^FROM\s*//g' | sed 's/\s.*$$//g' | sort -u )
201+
DOCKER_PULL_VARIABLES = VERSION=$(VERSION)
201202
docker-pull-base-image:
202203
@echo "################################################################################"
203204
@echo "# Pulling Base Image (platform: $(ARCH))"
204205
@echo "################################################################################"
205206
@echo "Docker File: $(DIR)/$(FILE)"
206-
@echo "Images Found: $(_DOCKER_PULL_BASE_IMAGES_FOUND)"
207-
@echo "Images Ignore: $(DOCKER_PULL_BASE_IMAGES_IGNORE)"
207+
@if [ -n "$(DOCKER_PULL_VARIABLES)" ]; then for e in "$(DOCKER_PULL_VARIABLES)";do export "$${e}";done; fi; echo "Images Found: $(_DOCKER_PULL_BASE_IMAGES_FOUND)"
208+
@if [ -n "$(DOCKER_PULL_VARIABLES)" ]; then for e in "$(DOCKER_PULL_VARIABLES)";do export "$${e}";done; fi; echo "Images Ignore: $(DOCKER_PULL_BASE_IMAGES_IGNORE)"
208209
@echo
209-
@echo $(_DOCKER_PULL_BASE_IMAGES_FOUND) | sed 's/\s/\n/g' | while read -r line; do \
210+
@# These variables will be exported to the shell
211+
@if [ -n "$(DOCKER_PULL_VARIABLES)" ]; then for e in "$(DOCKER_PULL_VARIABLES)";do export "$${e}";done; fi; \
212+
echo $(_DOCKER_PULL_BASE_IMAGES_FOUND) | sed 's/\s/\n/g' | while read -r line; do \
210213
if echo "$(DOCKER_PULL_BASE_IMAGES_IGNORE)" | grep -F "$${line}" >/dev/null; then \
211214
continue; \
212215
fi; \

0 commit comments

Comments
 (0)