From 99c751045921ebcc5cdffd6df810e673fd70dd70 Mon Sep 17 00:00:00 2001 From: Jose Martins Date: Fri, 13 Oct 2023 12:53:57 +0100 Subject: [PATCH 1/5] doc(license): update to apachev2 in docker makefile Signed-off-by: Jose Martins --- docker/Makefile | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) diff --git a/docker/Makefile b/docker/Makefile index f41fa7e..1e0d1d8 100644 --- a/docker/Makefile +++ b/docker/Makefile @@ -1,17 +1,5 @@ -## - # Bao, a Lightweight Static Partitioning Hypervisor - # - # Copyright (c) Bao Project (www.bao-project.org), 2019- - # - # Authors: - # Jose Martins - # - # Bao is free software; you can redistribute it and/or modify it under the - # terms of the GNU General Public License version 2 as published by the Free - # Software Foundation, with a special exception exempting guest code from such - # license. See the COPYING file in the top-level directory for details. - # -## +# SPDX-License-Identifier: Apache-2.0 +# Copyright (c) Bao Project and Contributors. All rights reserved root_dir?=$(realpath ../..) From 979cb26cf0ab11ceb874a4c2a89fa6c43afc3e5a Mon Sep 17 00:00:00 2001 From: Jose Martins Date: Fri, 13 Oct 2023 12:54:21 +0100 Subject: [PATCH 2/5] fix(docker): remove make recipe error supression This is necessary so that when we run a check in the containter through the docker Makefile default rule, the error is propagated to the shell that is actually invoking the command. Signed-off-by: Jose Martins --- docker/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker/Makefile b/docker/Makefile index 1e0d1d8..40076b0 100644 --- a/docker/Makefile +++ b/docker/Makefile @@ -12,7 +12,7 @@ override MAKEFLAGS:=$(addprefix -,$(MAKEFLAGS)) --no-print-directory all .DEFAULT: @echo "Launching docker container..." - -@$(DOCKER) run --pull=always --rm -it -u bao -v $(root_dir):$(root_dir) -w $(root_dir) \ + @$(DOCKER) run --pull=always --rm -it -u bao -v $(root_dir):$(root_dir) -w $(root_dir) \ $(docker_image) $(MAKE) $(MAKEFLAGS) $(MAKEOVERRIDES) $@ @echo "Leaving and destroying docker container..." From 25e8952fb088175db92a3d02364e9bd118862c15 Mon Sep 17 00:00:00 2001 From: Jose Martins Date: Fri, 13 Oct 2023 13:04:33 +0100 Subject: [PATCH 3/5] feat(docker): add make target to start an interactive shell Signed-off-by: Jose Martins --- README.md | 6 ++++++ docker/Makefile | 10 +++++++--- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 9e1c43b..3b1c5f4 100644 --- a/README.md +++ b/README.md @@ -121,6 +121,12 @@ example, if you want to run the format check in the container just: make -C ci/docker format-check ``` +You can also just invoke the container and work directly from its shell: + +```bash +make -C ci/docker shell +``` + If you prefer, you can build the container image locally by running: ```bash diff --git a/docker/Makefile b/docker/Makefile index 40076b0..f5f0877 100644 --- a/docker/Makefile +++ b/docker/Makefile @@ -7,15 +7,19 @@ 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 \ + $(root_dir):$(root_dir) -w $(root_dir) $(docker_image) override MAKEFLAGS:=$(addprefix -,$(MAKEFLAGS)) --no-print-directory all .DEFAULT: @echo "Launching docker container..." - @$(DOCKER) run --pull=always --rm -it -u bao -v $(root_dir):$(root_dir) -w $(root_dir) \ - $(docker_image) $(MAKE) $(MAKEFLAGS) $(MAKEOVERRIDES) $@ + @$(docker_run_cmd) $(MAKE) $(MAKEFLAGS) $(MAKEOVERRIDES) $@ @echo "Leaving and destroying docker container..." +shell: + @$(docker_run_cmd) + build: @echo "Launching docker container..." @$(DOCKER) build -t $(docker_image) . @@ -24,4 +28,4 @@ push: build @echo "Pushing container image to $(docker_repo)" @$(DOCKER) push $(docker_image) -.PHONY: all build push +.PHONY: all build push shell From 8750ce6ca381211e4920ea8a6bc8a1645d6aa82a Mon Sep 17 00:00:00 2001 From: Jose Martins Date: Fri, 13 Oct 2023 13:12:33 +0100 Subject: [PATCH 4/5] 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 From ba2000b17d8c398a7ee7af28e6dd57af2332a1a1 Mon Sep 17 00:00:00 2001 From: Jose Martins Date: Fri, 13 Oct 2023 13:18:34 +0100 Subject: [PATCH 5/5] fix(docker): set ROOT_DIR var uppercase User-defined upper case variables are suppose to signal a user input option. That is, the use can decide what directory to run the container on. Signed-off-by: Jose Martins --- README.md | 2 +- docker/Makefile | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 1bc284b..c3fa7de 100644 --- a/README.md +++ b/README.md @@ -133,7 +133,7 @@ Finally, if you prefer, you can build the container image locally by running: make -C ci/docker build ``` -In the case you want to use the locally built imaghe, or just not want to fetch +In the case you want to use the locally built image, 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 diff --git a/docker/Makefile b/docker/Makefile index 378c535..3f0f560 100644 --- a/docker/Makefile +++ b/docker/Makefile @@ -1,7 +1,7 @@ # SPDX-License-Identifier: Apache-2.0 # Copyright (c) Bao Project and Contributors. All rights reserved -root_dir?=$(realpath ../..) +ROOT_DIR?=$(realpath ../..) DOCKER?=$(shell which docker) docker_repo:=baoproject/bao