Compare commits

...

4 Commits

View File

@ -2,18 +2,21 @@ SHELL=bash
# MAKE=make -d
export CONTAINER_COMMAND ?= podman
export CONTAINER_INTERACTIVE
export CONTAINER_PORTS ?= --network=host
export CONTAINER_RUN ?= $(CONTAINER_COMMAND) run -it --network=host
export IN_CONTAINER ?= false
export IN_CI ?= false
export WATCH
export db ?= -cf
export DEV_PORT_HTTP
export DEV_PORT_HTTPS
export MEMCACHED_IMAGE = docker.io/memcached:latest
export MINIO_IMAGE = docker.io/minio/minio:latest
export MAILDEV_IMAGE = docker.io/maildev/maildev:latest
export IMAGE_REGISTRY = docker.io
export MEMCACHED_IMAGE = $(IMAGE_REGISTRY)/memcached:latest
export MINIO_IMAGE = $(IMAGE_REGISTRY)/minio/minio:latest
export MAILDEV_IMAGE = $(IMAGE_REGISTRY)/maildev/maildev:latest
# HELP HEADER START
# To see the definition of all available targets, take a look into the Makefile.
@ -34,7 +37,7 @@ export MAILDEV_IMAGE = docker.io/maildev/maildev:latest
# HELP: print out this help message
help:
@if [ -z "$$(which perl 2>/dev/null)" ] ; then \
$(CONTAINER_COMMAND) run -v .:/mnt 'debian:12.5' '/mnt/utils/makehelp.pl' '/mnt/Makefile' ; \
$(CONTAINER_RUN) .:/mnt 'debian:12.5' '/mnt/utils/makehelp.pl' '/mnt/Makefile' ; \
else \
utils/makehelp.pl Makefile ; \
fi
@ -42,7 +45,7 @@ help:
.PHONY: clean
# HELP: remove all compilation results in the directory but leave containers and images unharmed
clean:
rm -rf node_modules .npm .cache assets/icons assets/favicons static
rm -rf node_modules .npm .cache assets/icons assets/favicons static well-known
rm -rf .stack .stack-work .stack-work-build .stack-work-run .stack-work-test .stack-work-doc
rm -rf bin/ .Dockerfile .dev-port-http .dev-port-https
.PHONY: clean-all
@ -67,7 +70,7 @@ release:
MOUNT_DIR=/mnt/fradrive ; \
FRADRIVE_SERVICE=$* ; \
$(MAKE) -- --image-build FRADRIVE_SERVICE=$${FRADRIVE_SERVICE} ; \
$(CONTAINER_COMMAND) run -it -v $(PWD):$${MOUNT_DIR} $(CONTAINER_PORTS) --env IN_CONTAINER=true --entrypoint /bin/bash --name fradrive.$${FRADRIVE_SERVICE}.interactive.$$(date +'%Y-%m-%dT%H-%M-%S') fradrive/$${FRADRIVE_SERVICE}
$(CONTAINER_RUN) -v $(PWD):$${MOUNT_DIR} --env IN_CONTAINER=true --entrypoint /bin/bash --name fradrive.$${FRADRIVE_SERVICE}.interactive.$$(date +'%Y-%m-%dT%H-%M-%S') fradrive/$${FRADRIVE_SERVICE}
##### GENERAL TARGETS #####
###########################
@ -83,7 +86,6 @@ release:
# - additionally provide targets for termination of running containers
.PHONY: serve
# HELP: serve frontend, backend, and database
serve: CONTAINER_INTERACTIVE=-it
serve:
$(MAKE) serve-database &
$(MAKE) serve-memcached &
@ -115,15 +117,14 @@ test: test-frontend test-backend i18n-check
%-frontend: FRADRIVE_SERVICE=frontend
%-frontend: --image-build --containerized---%-frontend;
--%-frontend: --containerized-static-frontend;
--%-frontend: --containerized-static-frontend --containerized-well-known-frontend;
# HELP(compile-frontend): compile frontend
--compile-frontend: static
--compile-frontend: static well-known
npm run build
.PHONY: serve-frontend
# HELP: serve frontend (watch file changes)
serve-frontend: CONTAINER_INTERACTIVE=-it
serve-frontend:
$(MAKE) -- --containerized---compile-frontend WATCH=--watch
@ -146,7 +147,7 @@ node_modules: package.json package-lock.json
package-lock.json: package.json
npm install --cache .npm --prefer-offline
assets: assets/favicons assets/icons
assets: assets/favicons assets/icons;
assets/favicons:
./utils/faviconize.pl assets/favicon.svg long assets/favicons
assets/icons: node_modules
@ -155,6 +156,7 @@ assets/icons: node_modules
static: node_modules esbuild.config.mjs assets
npm run build
well-known: static;
##### FRONTEND TARGETS #####
############################
@ -181,7 +183,6 @@ static: node_modules esbuild.config.mjs assets
.PHONY: serve-backend
# HELP: serve backend
serve-backend: CONTAINER_INTERACTIVE=-it
serve-backend:
DEV_PORT_HTTP=`docker/backend/dev_port.pl 3000 | tee .dev-port-http`; \
DEV_PORT_HTTPS=`docker/backend/dev_port.pl 3443 | tee .dev-port-https`; \
@ -217,10 +218,6 @@ PHONY: --db-%-backend
--.stack: stack.yaml stack.yaml.lock
stack build --fast --only-dependencies $(stackopts)
# TODO: deprecated, remove
# .stack-work.lock:
# [ "${FLOCKER}" != "$0" ] && exec env FLOCKER="$0" flock -en .stack-work.lock "$0" "$@" || :
##### BACKEND TARGETS #####
###########################
@ -230,24 +227,22 @@ PHONY: --db-%-backend
.PHONY: serve-database
# HELP: serve database
serve-database: CONTAINER_INTERACTIVE=-it
serve-database: --containerized-database;
--containerized-database: FRADRIVE_SERVICE=database
# port forwarding is disabled in --network=host mode; nevertheless it is stated here for documentation reasons
# --containerized-database: CONTAINER_PORTS=--network=host -p 5432:5432/tcp
--containerized-database: docker/database/initdb.sh docker/database/pg_hba.conf docker/database/postgresql.conf docker/database/schema.sql --image-build
if [ "$(IN_CONTAINER)" == "false" ] ; then \
$(CONTAINER_COMMAND) run -it $(CONTAINER_PORTS) --name fradrive.$(FRADRIVE_SERVICE).$$(date +'%Y-%m-%dT%H-%M-%S') fradrive/$(FRADRIVE_SERVICE) ; \
$(CONTAINER_RUN) --name fradrive.$(FRADRIVE_SERVICE).$$(date +'%Y-%m-%dT%H-%M-%S') fradrive/$(FRADRIVE_SERVICE) ; \
fi
.PHONY: serve-memcached
serve-memcached:
$(CONTAINER_COMMAND) run -it --network=host $(MEMCACHED_IMAGE)
$(CONTAINER_RUN) $(MEMCACHED_IMAGE)
.PHONY: serve-minio
serve-minio:
$(CONTAINER_COMMAND) run -it --network=host $(MINIO_IMAGE) -- server $$(mktemp)
$(CONTAINER_RUN) $(MINIO_IMAGE) -- server $$(mktemp)
##### DATABASE TARGETS #####
############################
@ -258,13 +253,10 @@ serve-minio:
.PHONY: --containerized-%-frontend
--containerized-%-frontend: FRADRIVE_SERVICE=frontend
#--containerized-%-frontend: --image-build --image-run-%-frontend;
--containerized-%-frontend: --image-build
$(MAKE) -- --image-run-$*-frontend
--containerized-%-backend: FRADRIVE_SERVICE=backend
#--containerized-%-backend: --image-build --image-run-%-backend;
# --containerized-%-backend: CONTAINER_PORTS=--network=host -p $(DEV_PORT_HTTP):3000 -p $(DEV_PORT_HTTPS):3443
--containerized-%-backend: --image-build
$(MAKE) -- --image-run-$*-backend
@ -289,7 +281,7 @@ image-rebuild-%:
if [ "$(IN_CONTAINER)" == "true" ] ; then \
$(MAKE) -- $* ; \
else \
$(CONTAINER_COMMAND) run $(CONTAINER_INTERACTIVE) -v $(PWD):$${MOUNT_DIR} $(CONTAINER_PORTS) --env IN_CONTAINER=true --env FRADRIVE_MAKE_TARGET=$* --env WATCH=$(WATCH) --name fradrive.$(FRADRIVE_SERVICE).$$(date +'%Y-%m-%dT%H-%M-%S') localhost/fradrive/$(FRADRIVE_SERVICE) ; \
$(CONTAINER_RUN) -v $(PWD):$${MOUNT_DIR} --env IN_CONTAINER=true --env FRADRIVE_MAKE_TARGET=$* --env WATCH=$(WATCH) --name fradrive.$(FRADRIVE_SERVICE).$$(date +'%Y-%m-%dT%H-%M-%S') localhost/fradrive/$(FRADRIVE_SERVICE) ; \
fi
##### CONTAINER TARGETS #####