build(Makefile): restrict stack builds to half the number of local cpu cores

This commit is contained in:
Sarah Vaupel 2024-11-06 16:27:44 +01:00
parent 5e49b73a0a
commit 125b999dd0

View File

@ -1,6 +1,9 @@
export SHELL=bash export SHELL=bash
# System information
export CPU_CORES = $(shell cat /proc/cpuinfo | grep '^processor' | wc -l)
export CONTAINER_COMMAND ?= podman export CONTAINER_COMMAND ?= podman
export CONTAINER_BGRUN ?= $(CONTAINER_COMMAND) run -dit --network=host --replace export CONTAINER_BGRUN ?= $(CONTAINER_COMMAND) run -dit --network=host --replace
export CONTAINER_FGRUN ?= $(CONTAINER_COMMAND) run -it --network=host --replace export CONTAINER_FGRUN ?= $(CONTAINER_COMMAND) run -it --network=host --replace
@ -27,6 +30,7 @@ export CONTAINER_CMD
export ENTRYPOINT export ENTRYPOINT
export EXEC_OPTS export EXEC_OPTS
export STACK_CORES = $(shell echo $(($(CPU_CORES)/2)))
export BASE_PORTS export BASE_PORTS
export UNIWORXDB_OPTS ?= -cf export UNIWORXDB_OPTS ?= -cf
export PROD ?= false export PROD ?= false
@ -109,7 +113,7 @@ start:
%-hoogle: CONTAINER_CMD=localhost/fradrive/backend %-hoogle: CONTAINER_CMD=localhost/fradrive/backend
--start-hoogle: --start-hoogle:
HOOGLE_PORT=`cat $(CONTAINER_FILE) | grep 'HOOGLE_PORT=' | sed 's/HOOGLE_PORT=//'` ; \ HOOGLE_PORT=`cat $(CONTAINER_FILE) | grep 'HOOGLE_PORT=' | sed 's/HOOGLE_PORT=//'` ; \
stack --work-dir=.stack-work-doc hoogle -- server --local --port $${HOOGLE_PORT} stack --work-dir=.stack-work-doc $(STACK_CORES) hoogle -- server --local --port $${HOOGLE_PORT}
.PHONY: %-frontend .PHONY: %-frontend
%-frontend: SERVICE=frontend %-frontend: SERVICE=frontend
@ -234,19 +238,19 @@ endif
--start-backend: --start-backend:
DEV_PORT_HTTP=`cat $(CONTAINER_FILE) | grep 'DEV_PORT_HTTP=' | sed 's/DEV_PORT_HTTP=//'`; \ DEV_PORT_HTTP=`cat $(CONTAINER_FILE) | grep 'DEV_PORT_HTTP=' | sed 's/DEV_PORT_HTTP=//'`; \
DEV_PORT_HTTPS=`cat $(CONTAINER_FILE) | grep 'DEV_PORT_HTTPS=' | sed 's/DEV_PORT_HTTPS=//'`; \ DEV_PORT_HTTPS=`cat $(CONTAINER_FILE) | grep 'DEV_PORT_HTTPS=' | sed 's/DEV_PORT_HTTPS=//'`; \
stack --work-dir=.stack-work-run --lock-file ignore exec -- yesod devel -p "$${DEV_PORT_HTTP}" -q "$${DEV_PORT_HTTPS}" stack --work-dir=.stack-work-run $(STACK_CORES) --lock-file ignore exec -- yesod devel -p "$${DEV_PORT_HTTP}" -q "$${DEV_PORT_HTTPS}"
# HELP(compile-backend): compile backend binaries # HELP(compile-backend): compile backend binaries
--compile-backend: --compile-backend:
stack build --fast --profile --library-profiling --lock-file ignore --executable-profiling --flag uniworx:-library-only $(--DEVELOPMENT) --local-bin-path $$(pwd)/bin stack build $(STACK_CORES) --fast --profile --library-profiling --lock-file ignore --executable-profiling --flag uniworx:-library-only $(--DEVELOPMENT) --local-bin-path $$(pwd)/bin
# HELP(dependencies-backend): (re-)build backend dependencies # HELP(dependencies-backend): (re-)build backend dependencies
--dependencies-backend: stack.yaml stack.yaml.lock package.yaml --dependencies-backend: stack.yaml stack.yaml.lock package.yaml
stack build --fast --only-dependencies stack build $(STACK_CORES) --fast --only-dependencies
# HELP(lint-backend): lint backend # HELP(lint-backend): lint backend
--lint-backend: --lint-backend:
stack build --test --fast --work-dir=.stack-work-test --flag uniworx:library-only $(--DEVELOPMENT) uniworx:test:hlint stack build $(STACK_CORES) --test --fast --work-dir=.stack-work-test --flag uniworx:library-only $(--DEVELOPMENT) uniworx:test:hlint
# HELP(test-backend): test backend # HELP(test-backend): test backend
--test-backend: --test-backend:
stack build --test --coverage --fast --work-dir=.stack-work-test --flag uniworx:library-only $(--DEVELOPMENT) stack build $(STACK_CORES) --test --coverage --fast --work-dir=.stack-work-test --flag uniworx:library-only $(--DEVELOPMENT)
# HELP(compile-frontend): compile frontend assets # HELP(compile-frontend): compile frontend assets
--compile-frontend: node_modules assets esbuild.config.mjs --compile-frontend: node_modules assets esbuild.config.mjs