Skip to content

Commit

Permalink
Make make docker-clean to remove docker build cache (#1790)
Browse files Browse the repository at this point in the history
Makefile: add docker-clean sub-targets to remove not only image but cache (eats lot of space sometimes) & update help output / add clean-up of docker cache to deploy.sh as well

Co-authored-by: Ben V. Brown <[email protected]>
  • Loading branch information
ia and Ralim authored Aug 9, 2023
1 parent d5035bb commit 130e73c
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 15 deletions.
36 changes: 22 additions & 14 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -79,16 +79,18 @@ help:
list:
@echo
@echo "Supported top-level targets:"
@echo " * help - shows short basic help"
@echo " * list - this output"
@echo " * docker-shell - start docker container with shell inside to work on IronOS with all tools needed"
@echo " * docker-build - compile builds of IronOS for supported models inside docker container and place them to \"scripts/ci/artefacts/\""
@echo " * docker-clean - delete created docker container (but not pre-downloaded data for it)"
@echo " * docs - generate \"site\"/ directory with documentation in a form of static html files using ReadTheDocs framework and $(MKDOCS_YML) local config file"
@echo " * docs-deploy - generate & deploy docs online to gh-pages branch of current github repo"
@echo " * tests - run set of checks, linters & tests (equivalent of github CI IronOS project settings for push trigger)"
@echo " * clean-build - delete generated files & dirs produced during builds EXCEPT generated docker container image"
@echo " * clean-full - delete generated files & dirs produced during builds INCLUDING generated docker container image"
@echo " * help - shows short basic help"
@echo " * list - this output"
@echo " * docker-shell - start docker container with shell inside to work on IronOS with all tools needed"
@echo " * docker-build - compile builds of IronOS for supported models inside docker container and place them to $(OUT_DIR) (set OUT env var to override: OUT=/path/to/dir make ...)"
@echo " * docker-clean - delete created docker image for IronOS & its build cache objects (to free a lot of space)"
@echo " * docker-clean-cache - delete build cache objects of IronOS docker image EXCEPT the image itself"
@echo " * docker-clean-image - delete docker image for IronOS EXCEPT its build cache objects"
@echo " * docs - generate \"site\"/ directory with documentation in a form of static html files using ReadTheDocs framework and $(MKDOCS_YML) local config file"
@echo " * docs-deploy - generate & deploy docs online to gh-pages branch of current github repo"
@echo " * tests - run set of checks, linters & tests (equivalent of github CI IronOS project settings for push trigger)"
@echo " * clean-build - delete generated files & dirs produced during builds EXCEPT docker image & its build cache"
@echo " * clean-full - delete generated files & dirs produced during builds INCLUDING docker image & its build cache"
@echo ""
@echo "NOTES on supported pass-trough targets:"
@echo " * main Makefile is located in source/ directory and used to build the firmware itself;"
Expand Down Expand Up @@ -123,10 +125,17 @@ docker-shell: docker-check $(DOCKER_DEPS)
docker-build: docker-check $(DOCKER_DEPS)
$(DOCKER_CMD) make build-all

# delete container
docker-clean: docker-check
# delete docker image
docker-clean-image:
-docker rmi ironos-builder:latest

# delete docker build cache objects
docker-clean-cache:
-docker system prune --filter label=ironos-builder:latest --force

# delete docker image & cache related to IronOS container
docker-clean: docker-clean-image docker-clean-cache

# generate docs in site/ directory (DIR for -d is relative to mkdocs.yml file location, hence use default name/location site by setting up ../site)
docs: $(MKDOCS_YML) Documentation/* Documentation/Flashing/* Documentation/images/*
$(MKDOCS) build -f $(MKDOCS_YML) -d ../site
Expand Down Expand Up @@ -222,15 +231,14 @@ ci: tests build-all build-multilang
clean-build:
$(MAKE) -C source/ clean-all
rm -Rf site
rm -Rf scripts/ci/artefacts
rm -Rf $(OUT_DIR)

# global clean-up target
clean-full: clean-build docker-clean

# phony targets
.PHONY: help list
.PHONY: docker-check docker-shell docker-build docker-clean
.PHONY: docker-check docker-shell docker-build docker-clean-image docker-clean-cache docker-clean
.PHONY: docs docs-deploy
.PHONY: test-md test-sh test-py test-ccpp tests
.PHONY: build-all build-multilang ci
Expand Down
3 changes: 2 additions & 1 deletion scripts/deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ usage()
echo "CMD (docker related):"
echo -e "\tshell - start docker container with shell inside to work on IronOS with all tools needed"
echo -e "\tbuild - compile builds of IronOS inside docker container for supported hardware"
echo -e "\tclean - delete created docker container (but not pre-downloaded data for it)\n"
echo -e "\tclean - delete created docker image for IronOS & its build cache objects\n"
echo "CMD (helper routines):"
echo -e "\tdocs_readme - generate & OVERWRITE(!) README.md inside Documentation/ based on nav section from mkdocs.yml if it changed\n"
echo -e "\tcheck_style_file SRC - run code style checks based on clang-format & custom parsers for source code file SRC\n"
Expand Down Expand Up @@ -194,6 +194,7 @@ elif [ "${cmd}" = "build" ]; then
docker_cmd="run --rm builder make build-all OUT=${OUT}"
elif [ "${cmd}" = "clean" ]; then
docker rmi ironos-builder:latest
docker system prune --filter label=ironos-builder:latest --force
exit "${?}"
else
usage
Expand Down

0 comments on commit 130e73c

Please sign in to comment.