From 8750ce6ca381211e4920ea8a6bc8a1645d6aa82a Mon Sep 17 00:00:00 2001 From: Jose Martins Date: Fri, 13 Oct 2023 13:12:33 +0100 Subject: [PATCH] feat(docker): add option to run without pulling latest image Signed-off-by: Jose Martins --- README.md | 12 +++++++++++- docker/Makefile | 6 +++++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 3b1c5f4..1bc284b 100644 --- a/README.md +++ b/README.md @@ -127,12 +127,22 @@ You can also just invoke the container and work directly from its shell: make -C ci/docker shell ``` -If you prefer, you can build the container image locally by running: +Finally, if you prefer, you can build the container image locally by running: ```bash make -C ci/docker build ``` +In the case you want to use the locally built imaghe, or just not want to fetch +the latest available docker image, when invoking the Makefile you should tell it +you want to use the local image and not fetch it automatically. This is also +useful when you don't have a network connection or just want to skip that step +to speed up the command. For example: + +```bash +make -C ci/docker DOCKER_PULL=n format-check +``` + --- **NOTE** diff --git a/docker/Makefile b/docker/Makefile index f5f0877..378c535 100644 --- a/docker/Makefile +++ b/docker/Makefile @@ -7,7 +7,11 @@ DOCKER?=$(shell which docker) docker_repo:=baoproject/bao docker_tag:=latest docker_image:=$(docker_repo):$(docker_tag) -docker_run_cmd:=$(DOCKER) run --pull=always --rm -it -u bao -v \ +DOCKER_PULL?=y +ifeq ($(DOCKER_PULL),y) +docker_pull_option:=--pull=always +endif +docker_run_cmd:=$(DOCKER) run $(docker_pull_option) --rm -it -u bao -v \ $(root_dir):$(root_dir) -w $(root_dir) $(docker_image) override MAKEFLAGS:=$(addprefix -,$(MAKEFLAGS)) --no-print-directory