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

Docker makefile misc improvements #63

Merged
merged 5 commits into from
Feb 2, 2024
Merged
Show file tree
Hide file tree
Changes from 4 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
18 changes: 17 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 imaghe, or just not want to fetch
AfonsoSantos96 marked this conversation as resolved.
Show resolved Hide resolved
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**
Expand Down
30 changes: 13 additions & 17 deletions docker/Makefile
Original file line number Diff line number Diff line change
@@ -1,33 +1,29 @@
##
# Bao, a Lightweight Static Partitioning Hypervisor
#
# Copyright (c) Bao Project (www.bao-project.org), 2019-
#
# Authors:
# Jose Martins <[email protected]>
#
# 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 ../..)

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) .
Expand All @@ -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