diff --git a/README.md b/README.md index 9e1c43b..c3fa7de 100644 --- a/README.md +++ b/README.md @@ -121,12 +121,28 @@ example, if you want to run the format check in the container just: make -C ci/docker format-check ``` -If you prefer, you can build the container image locally by running: +You can also just invoke the container and work directly from its shell: + +```bash +make -C ci/docker shell +``` + +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 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 +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 f41fa7e..3f0f560 100644 --- a/docker/Makefile +++ b/docker/Makefile @@ -1,33 +1,29 @@ -## - # 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. - # -## - -root_dir?=$(realpath ../..) +# SPDX-License-Identifier: Apache-2.0 +# Copyright (c) Bao Project and Contributors. All rights reserved + +ROOT_DIR?=$(realpath ../..) DOCKER?=$(shell which docker) docker_repo:=baoproject/bao docker_tag:=latest docker_image:=$(docker_repo):$(docker_tag) +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 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) . @@ -36,4 +32,4 @@ push: build @echo "Pushing container image to $(docker_repo)" @$(DOCKER) push $(docker_image) -.PHONY: all build push +.PHONY: all build push shell