Skip to content

Commit

Permalink
feat(docker): add make target to start an interactive shell
Browse files Browse the repository at this point in the history
Signed-off-by: Jose Martins <[email protected]>
  • Loading branch information
josecm committed Oct 13, 2023
1 parent 979cb26 commit 25e8952
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 7 additions & 3 deletions docker/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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) .
Expand All @@ -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

0 comments on commit 25e8952

Please sign in to comment.