diff --git a/Makefile b/Makefile index ac48c2800..9f6926236 100644 --- a/Makefile +++ b/Makefile @@ -1,34 +1,42 @@ export SHELL=bash +export CLEAN_DEPENDENCIES ?= false + .PHONY: help # HELP: print out this help message help: - @if [ -z "$$(which perl 2>/dev/null)" ] ; then \ - $(CONTAINER_FGRUN) .:/mnt 'debian:12.5' '/mnt/utils/makehelp.pl' '/mnt/Makefile' ; \ - else \ - utils/makehelp.pl Makefile ; \ - fi + docker compose run help .PHONY: clean -# HELP: stop all running containers and remove all compilation results in the directory (but leave images including dependencies unharmed) -clean: - -rm -rf frontend/node_modules .npm .cache frontend/assets/icons frontend/assets/favicons frontend/static well-known config/manifest.json frontend/src/env.sass - -rm -rf .stack-work .stack-work.lock - -rm -rf bin .Dockerfile develop - -$(CONTAINER_COMMAND) container prune --force -.PHONY: clean-images -# HELP: stop all running containers and clean all images from local repositories -clean-images: - rm -rf develop - sleep 5 - -$(CONTAINER_COMMAND) system prune --all --force --volumes - -$(CONTAINER_COMMAND) image prune --all --force - -$(CONTAINER_COMMAND) volume prune --force +# HELP: clean compilation caches +clean: clean-frontend clean-backend ; .PHONY: clean-all -# HELP: like clean but with full container, image, and volume prune -clean-all: clean - -rm -rf .stack - $(CONTAINER_COMMAND) system reset --force +# HELP: clean everything, including dependency and image caches +clean-all: CLEAN_DEPENDENCIES = true +clean-all: clean ; + +.PHONY: clean-% +# HELP(clean-$SERVICE): invalidate caches for a given service. Supported services: frontend, backend. +clean-%: + $(MAKE) stop-$* + @$(MAKE) -- --clean-$* + @echo "Cleaned $* build files and binaries." +ifeq ("$(CLEAN_DEPENDENCIES)", "true") + @$(MAKE) -- --clean-$*-deps + @echo "Cleaned $* dependencies." +endif +--clean-frontend: + -rm -rf assets/icons assets/favicons + -rm -rf static well-known +--clean-frontend-deps: + -rm -rf frontend/node_modules + -rm -rf frontend/.npm +--clean-backend: + -rm -rf backend/.stack-work + -rm -rf bin/ +--clean-backend-deps: + -rf -rf backend/.stack + .PHONY: release # HELP: create, commit and push a new release diff --git a/compose.yaml b/compose.yaml index 0ab141b0d..dad29e1bc 100644 --- a/compose.yaml +++ b/compose.yaml @@ -1,4 +1,12 @@ services: + help: + image: docker.io/library/perl:stable + pull_policy: if_not_present + volumes: + - ./utils/makehelp.pl:/mnt/utils/makehelp.pl + - ./Makefile:/tmp/Makefile + command: perl /mnt/utils/makehelp.pl + frontend: build: context: ./frontend @@ -22,6 +30,7 @@ services: userns_mode: host volumes: - ./backend:/fradrive + - ./bin:/usr/bin/fradrive - ./assets:/fradrive/assets:ro - ./static:/fradrive/static:ro - ./well-known:/fradrive/well-known:ro