Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add docker pull ignore #13

Merged
merged 1 commit into from
Nov 6, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 19 additions & 2 deletions Makefile.docker
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ DOCKER_TAG = latest
DIR = .
FILE = Dockerfile

# Space separated Docker images (in FROM block) to not to pull
DOCKER_PULL_BASE_IMAGES_IGNORE =


# Auto-detect current platform and use it as default to build for
_PLATFORM = $(shell uname -m)
ifeq ($(strip $(_PLATFORM)),x86_64)
Expand Down Expand Up @@ -193,11 +197,24 @@ docker-load:
# Helper Targets
# -------------------------------------------------------------------------------------------------
.PHONY: docker-pull-base-image
_DOCKER_PULL_BASE_IMAGES_FOUND = $(shell grep FROM $(DIR)/$(FILE) | sed 's/^FROM\s*//g' | sed 's/\s.*$$//g' | sort -u )
_DOCKER_PULL_BASE_IMAGES_PULL = $(shell \
for img in $$( echo "$(_DOCKER_PULL_BASE_IMAGES_FOUND)" | sed 's/\s/\n/g' ); do \
if ! echo $(DOCKER_PULL_BASE_IMAGES_IGNORE) | grep -F "$${img}" >/dev/null; then \
echo "$${img}"; \
fi; \
done; \
)
docker-pull-base-image:
@echo "################################################################################"
@echo "# Pulling Base Image $(shell grep FROM $(DIR)/$(FILE) | sed 's/^FROM\s*//g';) (platform: $(ARCH))"
@echo "# Pulling Base Image (platform: $(ARCH))"
@echo "################################################################################"
@grep FROM $(DIR)/$(FILE) | sed 's/^FROM\s*//g' | sed 's/\s.*$$//g' | sort -u | while read -r line; do \
@echo "Docker File: $(DIR)/$(FILE)"
@echo "Images Found: $(_DOCKER_PULL_BASE_IMAGES_FOUND)"
@echo "Images Ignore: $(DOCKER_PULL_BASE_IMAGES_IGNORE)"
@echo "Images Actual: $(_DOCKER_PULL_BASE_IMAGES_PULL)"
@echo
@echo $(_DOCKER_PULL_BASE_IMAGES_PULL) | sed 's/\s/\n/g' | while read -r line; do \
echo "docker pull --platform $(ARCH) $${line}"; \
SUCC=0; \
for count in $$(seq 10); do \
Expand Down