Merged PR 18666: Update to docker compose
This commit is contained in:
commit
79e0d5a642
@ -1,3 +0,0 @@
|
||||
SPDX-FileCopyrightText: 2022 Felix Hamann <felix.hamann@campus.lmu.de>,Sarah Vaupel <sarah.vaupel@ifi.lmu.de>,Sarah Vaupel <vaupel.sarah@campus.lmu.de>
|
||||
|
||||
SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
@ -1,3 +0,0 @@
|
||||
SPDX-FileCopyrightText: 2022 Gregor Kleen <gregor.kleen@ifi.lmu.de>,Sarah Vaupel <sarah.vaupel@ifi.lmu.de>,Sarah Vaupel <vaupel.sarah@campus.lmu.de>
|
||||
|
||||
SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
18
.gitignore
vendored
18
.gitignore
vendored
@ -2,8 +2,10 @@
|
||||
dist*
|
||||
develop
|
||||
node_modules/
|
||||
assets/icons
|
||||
assets/favicons
|
||||
.npm/
|
||||
.node_repl_history
|
||||
**/assets/icons
|
||||
**/assets/favicons
|
||||
bin/
|
||||
assets/fonts/
|
||||
*.hi
|
||||
@ -38,22 +40,20 @@ uniworx.nix
|
||||
.kateproject
|
||||
src/Handler/Assist.bak
|
||||
src/Handler/Course.SnapCustom.hs
|
||||
frontend/src/env.sass
|
||||
*.orig
|
||||
/instance
|
||||
.stack-work-*
|
||||
.stack-work.lock
|
||||
.directory
|
||||
tags
|
||||
test.log
|
||||
*.dump-splices
|
||||
/.stack-work.lock
|
||||
/.npmrc
|
||||
/.npm/
|
||||
/config/manifest.json
|
||||
tunnel.log
|
||||
/static
|
||||
/well-known
|
||||
/.well-known-cache
|
||||
static
|
||||
well-known
|
||||
.well-known-cache
|
||||
manifest.json
|
||||
/.nix-well-known
|
||||
/**/tmp-*
|
||||
/testdata/bigAlloc_*.csv
|
||||
|
||||
@ -1,3 +0,0 @@
|
||||
SPDX-FileCopyrightText: 2022 Gregor Kleen <gregor.kleen@ifi.lmu.de>
|
||||
|
||||
SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
@ -2,6 +2,8 @@
|
||||
|
||||
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
|
||||
|
||||
## [27.4.59-0.0.20+145-build-system-rewrite](https://fraport@dev.azure.com/fraport/Fahrerausbildung/_git/FRADrive//compare/27.4.59-0.0.19+145-build-system-rewrite...27.4.59-0.0.20+145-build-system-rewrite) (2025-03-19)
|
||||
|
||||
## [27.4.59-0.0.19+145-build-system-rewrite](https://fraport@dev.azure.com/fraport/Fahrerausbildung/_git/FRADrive//compare/27.4.59-0.0.18+145-build-system-rewrite...27.4.59-0.0.19+145-build-system-rewrite) (2025-03-17)
|
||||
|
||||
## [27.4.59-0.0.18+145-build-system-rewrite](https://fraport@dev.azure.com/fraport/Fahrerausbildung/_git/FRADrive//compare/v27.4.59-test-g0.0.17...27.4.59-0.0.18+145-build-system-rewrite) (2025-03-17)
|
||||
|
||||
488
Makefile
488
Makefile
@ -1,95 +1,55 @@
|
||||
|
||||
export SHELL=bash
|
||||
|
||||
# MAKE=make -f Makefile-loggingsymbols
|
||||
# MAKE=make -d
|
||||
|
||||
# System information
|
||||
export CPU_CORES = $(shell cat /proc/cpuinfo | grep '^processor' | wc -l)
|
||||
|
||||
export CONTAINER_COMMAND ?= podman
|
||||
export CONTAINER_BGRUN ?= $(CONTAINER_COMMAND) run -dit --network=host --replace
|
||||
export CONTAINER_FGRUN ?= $(CONTAINER_COMMAND) run -it --network=host --replace
|
||||
|
||||
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 # TODO: needs different port than 1025 to avoid conflicts
|
||||
export POSTGRES_IMAGE = $(IMAGE_REGISTRY)/library/postgres:12
|
||||
export LOCAL_CONTAINERFILE
|
||||
|
||||
export IN_CONTAINER ?= false
|
||||
export IN_CI ?= false
|
||||
export CONTAINER_FILE
|
||||
export CONTAINER_IDENT
|
||||
export CF_PREFIX
|
||||
export DEVELOP
|
||||
export CONTAINER_ATTACHED
|
||||
export CONTAINER_INIT
|
||||
export CONTAINER_CLEANUP
|
||||
export PROJECT_DIR=/fradrive
|
||||
|
||||
export SERVICE
|
||||
export SERVICE_VARIANT ?= $(SERVICE)
|
||||
export JOB
|
||||
export IMAGE
|
||||
export MAKECALL
|
||||
export ENTRYPOINT
|
||||
export EXEC_OPTS
|
||||
|
||||
export STACK_CORES = $(shell echo $(($(CPU_CORES)/2)))
|
||||
export BASE_PORTS
|
||||
export UNIWORXDB_OPTS ?= -cf
|
||||
export PROD ?= false
|
||||
export SRC
|
||||
|
||||
ifeq ($(PROD),true)
|
||||
export --DEVELOPMENT=--flag uniworx:-dev
|
||||
else
|
||||
export --DEVELOPMENT=--flag uniworx:dev
|
||||
endif
|
||||
|
||||
export DATE := $(shell date +'%Y-%m-%dT%H-%M-%S')
|
||||
|
||||
export CURR_DEV = $(shell cat develop/.current 2>/dev/null)
|
||||
export SET_DEVELOP = $(eval DEVELOP=develop/$$(CURR_DEV))
|
||||
export NEW_DEVELOP = $(eval DEVELOP=develop/$$(DATE))
|
||||
|
||||
export CLEAN_DEPENDENCIES ?= false
|
||||
export CLEAN_IMAGES ?= 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)
|
||||
# HELP: clean compilation caches
|
||||
clean:
|
||||
rm -rf develop
|
||||
-rm -rf node_modules .npm .cache assets/icons assets/favicons 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
|
||||
$(MAKE) clean-frontend CLEAN_DEPENDENCIES=$(CLEAN_DEPENDENCIES) CLEAN_IMAGES=$(CLEAN_IMAGES)
|
||||
$(MAKE) clean-backend CLEAN_DEPENDENCIES=$(CLEAN_DEPENDENCIES) CLEAN_IMAGES=$(CLEAN_IMAGES)
|
||||
.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_IMAGES = 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
|
||||
ifeq ("$(CLEAN_IMAGES)", "true")
|
||||
docker compose rm --force --volumes
|
||||
docker compose down --rmi 'all' --volumes
|
||||
@echo "Cleaned $* image."
|
||||
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
|
||||
|
||||
|
||||
# TODO: only release when build and tests are passing!!!
|
||||
.PHONY: release
|
||||
# HELP: create, commit and push a new release
|
||||
# TODO: only release when build and tests are passing!!!
|
||||
release:
|
||||
VERSION=`./utils/version.pl -changelog CHANGELOG.md -v` ; \
|
||||
git add CHANGELOG.md ; \
|
||||
@ -100,353 +60,47 @@ release:
|
||||
|
||||
.PHONY: compile
|
||||
# HELP: perform full compilation (frontend and backend)
|
||||
compile:
|
||||
$(MAKE) compile-frontend
|
||||
$(MAKE) compile-backend
|
||||
compile: compile-frontend compile-backend ;
|
||||
.PHONY: compile-%
|
||||
# HELP(compile-$SERVICE): compile a given service once
|
||||
compile-%:
|
||||
docker compose run --remove-orphans --build --no-deps $* make compile
|
||||
|
||||
.PHONY: start
|
||||
# HELP: start complete development environment with a fresh test database
|
||||
start:
|
||||
$(MAKE) start-postgres
|
||||
$(MAKE) start-memcached
|
||||
$(MAKE) start-minio
|
||||
$(MAKE) start-maildev
|
||||
$(MAKE) compile-frontend
|
||||
$(MAKE) compile-uniworxdb
|
||||
$(MAKE) start-backend
|
||||
|
||||
.PHONY: %-backend
|
||||
%-backend: SERVICE=backend
|
||||
%-backend: SERVICE_VARIANT=backend
|
||||
%-backend: LOCAL_CONTAINERFILE=true
|
||||
%-backend: IMAGE=localhost/fradrive/backend
|
||||
%-backend: BASE_PORTS = "DEV_PORT_HTTP=3000" "DEV_PORT_HTTPS=3443"
|
||||
|
||||
.PHONY: %-uniworxdb
|
||||
%-uniworxdb: SERVICE=backend
|
||||
%-uniworxdb: SERVICE_VARIANT=uniworxdb
|
||||
%-uniworxdb: IMAGE=localhost/fradrive/backend
|
||||
%-uniworxdb: LOCAL_CONTAINERFILE=true
|
||||
|
||||
.PHONY: %-ghci
|
||||
%-ghci: SERVICE=backend
|
||||
%-ghci: SERVICE_VARIANT=ghci
|
||||
%-ghci: IMAGE=localhost/fradrive/backend
|
||||
%-ghci: LOCAL_CONTAINERFILE=true
|
||||
|
||||
.PHONY: %-hoogle
|
||||
%-hoogle: SERVICE=backend
|
||||
%-hoogle: SERVICE_VARIANT=hoogle
|
||||
%-hoogle: BASE_PORTS = "HOOGLE_PORT=8081"
|
||||
%-hoogle: IMAGE=localhost/fradrive/backend
|
||||
%-hoogle: LOCAL_CONTAINERFILE=true
|
||||
--start-hoogle:
|
||||
HOOGLE_PORT=`cat $(CONTAINER_FILE) | grep 'HOOGLE_PORT=' | sed 's/HOOGLE_PORT=//'` ; \
|
||||
stack $(STACK_CORES) hoogle -- server --local --port $${HOOGLE_PORT}
|
||||
|
||||
.PHONY: %-frontend
|
||||
%-frontend: SERVICE=frontend
|
||||
%-frontend: SERVICE_VARIANT=frontend
|
||||
%-frontend: LOCAL_CONTAINERFILE=true
|
||||
%-frontend: IMAGE=localhost/fradrive/frontend
|
||||
|
||||
.PHONY: %-postgres
|
||||
%-postgres: SERVICE=postgres
|
||||
%-postgres: SERVICE_VARIANT=postgres
|
||||
%-postgres: BASE_PORTS = "PGPORT=5432"
|
||||
%-postgres: IMAGE=--env POSTGRES_HOST_AUTH_METHOD=trust -v ./docker/postgres/pg_hba.conf:/tmp/pg_hba.conf -v ./docker/postgres/postgresql.conf:/tmp/postgresql.conf -v ./docker/postgres/pgconfig.sh:/docker-entrypoint-initdb.d/_pgconfig.sh -v ./docker/postgres/schema.sql:/docker-entrypoint-initdb.d/schema.sql $$(POSTGRES_IMAGE)
|
||||
%-postgres: LOCAL_CONTAINERFILE=false
|
||||
|
||||
.PHONY: %-memcached
|
||||
%-memcached: SERVICE=memcached
|
||||
%-memcached: SERVICE_VARIANT=memcached
|
||||
%-memcached: IMAGE=$$(MEMCACHED_IMAGE) --port=11211
|
||||
%-memcached: LOCAL_CONTAINERFILE=false
|
||||
%-memcached: BASE_PORTS = "MEMCACHED_PORT=11211"
|
||||
|
||||
.PHONY: %-maildev
|
||||
%-maildev: SERVICE=maildev
|
||||
%-maildev: SERVICE_VARIANT=maildev
|
||||
%-maildev: IMAGE=$$(MAILDEV_IMAGE) --port=1025
|
||||
%-maildev: LOCAL_CONTAINERFILE=false
|
||||
%-maildev: BASE_PORTS = "MAILDEV_PORT=1025"
|
||||
|
||||
.PHONY: %-release
|
||||
%-release: PROD=true
|
||||
%-release: SERVICE=fradrive
|
||||
%-release: SERVICE_VARIANT=fradrive
|
||||
%-release: IMAGE=localhost/fradrive/fradrive
|
||||
%-release: LOCAL_CONTAINERFILE=true
|
||||
|
||||
.PHONY: %-minio
|
||||
%-minio: SERVICE=minio
|
||||
%-minio: SERVICE_VARIANT=minio
|
||||
%-minio: IMAGE=$$(MINIO_IMAGE) -- server /tmp/minio
|
||||
%-minio: LOCAL_CONTAINERFILE=false
|
||||
%-minio: BASE_PORTS = "UPLOAD_S3_PORT=9000"
|
||||
|
||||
start: start-postgres start-maildev start-memcached start-minio start-backend
|
||||
docker compose run backend make start
|
||||
.PHONY: start-%
|
||||
start-%: JOB=start
|
||||
start-%: CF_PREFIX = start-
|
||||
start-%: CONTAINER_ATTACHED = false
|
||||
start-%: --act ;
|
||||
|
||||
.PHONY: compile-%
|
||||
compile-%: JOB=compile
|
||||
compile-%: CF_PREFIX = compile-
|
||||
compile-%: CONTAINER_ATTACHED = true
|
||||
compile-%: --act ;
|
||||
|
||||
.PHONY: dependencies-%
|
||||
dependencies-%: JOB=dependencies
|
||||
dependencies-%: CF_PREFIX = dependencies-
|
||||
dependencies-%: CONTAINER_ATTACHED = true
|
||||
dependencies-%: --act ;
|
||||
|
||||
.PHONY: test-%
|
||||
test-%: JOB=test
|
||||
test-%: CF_PREFIX = test-
|
||||
test-%: CONTAINER_ATTACHED = true
|
||||
test-%: --act ;
|
||||
|
||||
.PHONY: lint-%
|
||||
lint-%: JOB=lint
|
||||
lint-%: CF_PREFIX = lint-
|
||||
lint-%: CONTAINER_ATTACHED = true
|
||||
lint-%: --act ;
|
||||
|
||||
.PHONY: shell-%
|
||||
# HELP(shell-$SERVICE): launch (bash) shell inside a new $SERVICE container
|
||||
shell-%: JOB=shell
|
||||
shell-%: CF_PREFIX=shell-
|
||||
shell-%: CONTAINER_ATTACHED=true
|
||||
shell-%: --act ;
|
||||
.PHONY: ghci
|
||||
# HELP(ghci): launch new backend instance and enter interactive ghci shell
|
||||
ghci: shell-ghci;
|
||||
|
||||
--act: --develop_containerized;
|
||||
|
||||
--develop_%: PORTS = $(foreach PORT,$(BASE_PORTS),$(shell utils/next_free_port.pl $(PORT)))
|
||||
--develop_%: --ensure-develop
|
||||
DEVELOP=develop/`cat develop/.current` ; \
|
||||
CONTAINER_IDENT=$(CF_PREFIX)$(SERVICE_VARIANT) ; \
|
||||
CONTAINER_FILE=$${DEVELOP}/$${CONTAINER_IDENT} ; \
|
||||
if [[ -e $${CONTAINER_FILE} ]]; then \
|
||||
>&2 echo "Another $* service is already running! Use \"make new-develop\" to start a new develop instance despite currently running services." ; \
|
||||
exit 1 ; \
|
||||
fi ; \
|
||||
echo "$(PORTS)" | sed 's/ /\n/g' > $${CONTAINER_FILE} ; \
|
||||
$(MAKE) -- --$* CONTAINER_FILE=$${CONTAINER_FILE} CONTAINER_IDENT=$${CONTAINER_IDENT} JOB=$(JOB)
|
||||
|
||||
.PHONY: rebuild-%
|
||||
# HELP(rebuild-{backend,frontend,database,memcached,minio}): force-rebuild a given container image
|
||||
rebuild-%:
|
||||
$(MAKE) -- --image-build SERVICE=$* NO_CACHE=--no-cache
|
||||
--image-build:
|
||||
ifeq "$(LOCAL_CONTAINERFILE)" "true"
|
||||
rm -f .Dockerfile
|
||||
ln -s docker/$(SERVICE)/Dockerfile .Dockerfile
|
||||
PROJECT_DIR=/fradrive; \
|
||||
if [ "$(IN_CONTAINER)" == "false" ] ; then \
|
||||
$(CONTAINER_COMMAND) build $(NO_CACHE) \
|
||||
-v $(PWD):$${PROJECT_DIR}:rw \
|
||||
--build-arg PROJECT_DIR=$${PROJECT_DIR} \
|
||||
--env IN_CONTAINER=true \
|
||||
--env JOB=$(JOB) \
|
||||
--tag fradrive/$(SERVICE) \
|
||||
--file $(PWD)/.Dockerfile ; \
|
||||
fi
|
||||
else
|
||||
:
|
||||
endif
|
||||
|
||||
--containerized: --image-build
|
||||
DEVELOP=`cat develop/.current` ; \
|
||||
./utils/watchcontainerrun.sh "$(CONTAINER_COMMAND)" "$(CONTAINER_FILE)" "$(CONTAINER_INIT)" "$(CONTAINER_CLEANUP)" & \
|
||||
CONTAINER_NAME=fradrive.$(CURR_DEV).$(CONTAINER_IDENT) ; \
|
||||
if [ "$(LOCAL_CONTAINERFILE)" = "true" ] ; \
|
||||
then \
|
||||
MAKECALL="make -- --$(JOB)-$(SERVICE_VARIANT) IN_CONTAINER=true" ; \
|
||||
fi ; \
|
||||
CONTAINER_ID=`$(CONTAINER_BGRUN) \
|
||||
-v $(PWD):$(PROJECT_DIR):rw \
|
||||
--env IN_CONTAINER=true \
|
||||
--env CONTAINER_FILE=$(CONTAINER_FILE) \
|
||||
--env CONTAINER_NAME=$${CONTAINER_NAME} \
|
||||
--env JOB=$(JOB) \
|
||||
--env SRC=$(SRC) \
|
||||
--name $${CONTAINER_NAME} \
|
||||
$(IMAGE) \
|
||||
$${MAKECALL} \
|
||||
` ; \
|
||||
printf "CONTAINER_ID=$${CONTAINER_ID}" >> "$(CONTAINER_FILE)" ; \
|
||||
if [[ "true" == "$(CONTAINER_ATTACHED)" ]] ; then \
|
||||
$(CONTAINER_COMMAND) attach $${CONTAINER_ID} || : ; \
|
||||
fi
|
||||
|
||||
# For Reverse Proxy Problem see: https://groups.google.com/g/yesodweb/c/2EO53kSOuy0/m/Lw6tq2VYat4J
|
||||
# HELP(start-backend): start development instance
|
||||
--start-backend: --dependencies-backend
|
||||
export YESOD_IP_FROM_HEADER=true; \
|
||||
export DEV_PORT_HTTP=`cat $(CONTAINER_FILE) | grep 'DEV_PORT_HTTP=' | sed 's/DEV_PORT_HTTP=//'`; \
|
||||
export DEV_PORT_HTTPS=`cat $(CONTAINER_FILE) | grep 'DEV_PORT_HTTPS=' | sed 's/DEV_PORT_HTTPS=//'`; \
|
||||
export HOST=127.0.0.1 ; \
|
||||
export PORT=$${PORT:-$${DEV_PORT_HTTP}} ; \
|
||||
export DETAILED_LOGGING=$${DETAILED_LOGGING:-true} ; \
|
||||
export LOG_ALL=$${LOG_ALL:-false} ; \
|
||||
export LOGLEVEL=$${LOGLEVEL:-info} ; \
|
||||
export DUMMY_LOGIN=$${DUMMY_LOGIN:-true} ; \
|
||||
export SERVER_SESSION_ACID_FALLBACK=$${SERVER_SESSION_ACID_FALLBACK:-true} ; \
|
||||
export SERVER_SESSION_COOKIES_SECURE=$${SERVER_SESSION_COOKIES_SECURE:-false} ; \
|
||||
export COOKIES_SECURE=$${COOKIES_SECURE:-false} ; \
|
||||
export ALLOW_DEPRECATED=$${ALLOW_DEPRECATED:-true} ; \
|
||||
export ENCRYPT_ERRORS=$${ENCRYPT_ERRORS:-false} ; \
|
||||
export RIBBON=$${RIBBON:-$${HOST:-localhost}} ; \
|
||||
export APPROOT=$${APPROOT:-http://localhost:$${DEV_PORT_HTTP}} ; \
|
||||
export AVSPASS=$${AVSPASS:-nopasswordset} ; \
|
||||
stack $(STACK_CORES) exec --local-bin-path $$(pwd)/bin --copy-bins -- yesod devel -p "$${DEV_PORT_HTTP}" -q "$${DEV_PORT_HTTPS}"
|
||||
# HELP(compile-backend): compile backend binaries
|
||||
--compile-backend: --dependencies-backend
|
||||
stack build $(STACK_CORES) --fast --profile --library-profiling --executable-profiling --flag uniworx:-library-only $(--DEVELOPMENT) --local-bin-path $$(pwd)/bin --copy-bins
|
||||
# HELP(dependencies-backend): (re-)build backend dependencies
|
||||
--dependencies-backend: #uniworx.cabal
|
||||
chown -R `id -un`:`id -gn` "$(PROJECT_DIR)"; \
|
||||
stack install hpack; stack install yesod-bin; \
|
||||
stack build -j2 --only-dependencies
|
||||
# HELP(lint-backend): lint backend
|
||||
--lint-backend:
|
||||
stack build $(STACK_CORES) --test --fast --flag uniworx:library-only $(--DEVELOPMENT) uniworx:test:hlint
|
||||
# HELP(test-backend): test backend
|
||||
--test-backend:
|
||||
stack build $(STACK_CORES) --test --coverage --fast --flag uniworx:library-only $(--DEVELOPMENT)
|
||||
# uniworx.cabal:
|
||||
# stack exec -- hpack --force
|
||||
|
||||
# HELP(compile-frontend): compile frontend assets
|
||||
--compile-frontend: --dependencies-frontend
|
||||
npm run build
|
||||
--start-frontend: --compile-frontend;
|
||||
--dependencies-frontend: node_modules assets esbuild.config.mjs frontend/src/env.sass;
|
||||
node_modules: package.json package-lock.json
|
||||
npm install --cache .npm --prefer-offline
|
||||
package-lock.json: package.json
|
||||
npm install --cache .npm --prefer-offline
|
||||
assets: assets/favicons assets/icons;
|
||||
assets/favicons:
|
||||
./utils/faviconize.pl assets/favicon.svg long assets/favicons
|
||||
assets/icons: node_modules assets/icons-src/fontawesome.json
|
||||
./utils/renamer.pl node_modules/@fortawesome/fontawesome-free/svgs/solid assets/icons-src/fontawesome.json assets/icons/fradrive
|
||||
./utils/renamer.pl node_modules/@fortawesome/fontawesome-free/svgs/regular assets/icons-src/fontawesome.json assets/icons/fradrive
|
||||
-cp assets/icons-src/*.svg assets/icons/fradrive
|
||||
frontend/src/env.sass:
|
||||
echo "\$$path: '$${PROJECT_DIR}'" > frontend/src/env.sass
|
||||
static: --dependencies-frontend
|
||||
npm run build
|
||||
well-known: static;
|
||||
--lint-frontend: --compile-frontend
|
||||
npm run lint
|
||||
--test-frontend: --compile-frontend
|
||||
npm run test
|
||||
|
||||
# HELP(compile-uniworxdb): clear and fill database. requires running postgres instance (use "make start-postgres" to start one)
|
||||
# TODO (db-m-$MIGRATION-backend): apply migration (see src/Model/Migration/Definition.hs for list of available migrations)
|
||||
--compile-uniworxdb: --compile-backend
|
||||
SERVER_SESSION_ACID_FALLBACK=${SERVER_SESSION_ACID_FALLBACK:-true} ; \
|
||||
AVSPASS=${AVSPASS:-nopasswordset} ; \
|
||||
./bin/uniworxdb $(UNIWORXDB_OPTS)
|
||||
|
||||
# HELP(shell-ghci): enter ghci shell. Use "make ghci SRC=<MODULE_FILE.hs>" to load specific source modules."
|
||||
--shell-ghci:
|
||||
stack ghci -- $(SRC)
|
||||
# --main-is uniworx:exe:uniworx
|
||||
|
||||
# HELP(shell-{backend,frontend,memcached,minio,postgres}): enter (bash) shell inside a new container of a given service
|
||||
--shell-%:
|
||||
/bin/bash
|
||||
|
||||
# HELP(start-minio): start minio service
|
||||
|
||||
.PHONY: status
|
||||
# HELP: print develop status: running containers, used ports
|
||||
status:
|
||||
@./utils/develop-status.pl -a
|
||||
|
||||
.PHONY: log-%
|
||||
# HELP(log-$(JOB)-$(SERVICE)): inspect output of a given service. The service must be currently running When a service supports multiple running instances in one develop (i.e. backend), you need to specify the exact instance by its associated file (e.g. backend-1, backend-2, etc.), please check the contents of the develop/ directory for a list of running instances.
|
||||
log-%:
|
||||
DEVELOP=develop/`cat develop/.current` ; \
|
||||
SEARCH_FILE="$${DEVELOP}/$*" ; \
|
||||
if [[ ! -e "$${SEARCH_FILE}" ]] ; then \
|
||||
SEARCH_FILE="$${DEVELOP}/.exited.$*" ; \
|
||||
fi ; \
|
||||
if [[ -e "$${SEARCH_FILE}" ]] ; then \
|
||||
$(CONTAINER_COMMAND) logs --follow `cat "$${SEARCH_FILE}" | grep CONTAINER_ID= | sed 's/^CONTAINER_ID=//'` ; \
|
||||
else \
|
||||
>&2 echo "Cannot show log: No develop file found for '$*'" ; \
|
||||
exit 1 ; \
|
||||
fi
|
||||
|
||||
.PHONY: enter
|
||||
# HELP: launch (bash) shell inside a currently running container. Use ./enter shell wrapper for more convenient usage, possibly with tab-completion in the future
|
||||
enter: --ensure-develop
|
||||
$(MAKE) -- --enter
|
||||
|
||||
.PHONY: psql
|
||||
# HELP: enter psql (postgresql) cli inside a currently running database container
|
||||
psql: ENTRYPOINT=/usr/bin/psql -d uniworx
|
||||
psql: EXEC_OPTS=--user postgres
|
||||
psql: --ensure-develop
|
||||
$(MAKE) -- --enter CONTAINER_FILE=develop/`cat develop/.current`/start-postgres
|
||||
|
||||
--enter:
|
||||
CONTAINER_ID=`cat $(CONTAINER_FILE) | grep 'CONTAINER_ID=' | sed 's/CONTAINER_ID=//'` ; \
|
||||
$(CONTAINER_COMMAND) exec -it $(EXEC_OPTS) $${CONTAINER_ID} $(if $(ENTRYPOINT),$(ENTRYPOINT),/bin/bash)
|
||||
# HELP(start-$SERVICE): start a given service
|
||||
start-%:
|
||||
docker compose up -d --build $*
|
||||
|
||||
.PHONY: stop
|
||||
# HELP: stop all currently running develop instances
|
||||
# HELP: stop all services
|
||||
stop:
|
||||
rm -rf develop
|
||||
docker compose down
|
||||
.PHONY: stop-%
|
||||
# HELP(stop-SERVICE): stop all currently running develop instances of a given service (i.e. backend,frontend,uniworxdb,hoogle,postgres,...)
|
||||
# HELP(stop-JOB): stop all currently running develop instances of a given job (i.e. compile,start,test,lint)
|
||||
stop-compile: CF_PREFIX=compile-
|
||||
stop-start: CF_PREFIX=start-
|
||||
stop-test: CF_PREFIX=test-
|
||||
stop-lint: CF_PREFIX=lint-
|
||||
stop-%: --stop;
|
||||
--stop:
|
||||
$(SET_DEVELOP)
|
||||
ifdef CF_PREFIX
|
||||
rm -rf $(DEVELOP)/$(CF_PREFIX)*
|
||||
endif
|
||||
ifdef SERVICE_VARIANT
|
||||
rm -rf $(DEVELOP)/*-$(SERVICE_VARIANT)
|
||||
endif
|
||||
# HELP(stop-$SERVICE): stop a given service
|
||||
stop-%:
|
||||
docker compose down $*
|
||||
.PHONY: kill-%
|
||||
# HELP(kill-$SERVICE): kill a given service the hard way. Use this if the servive does not respond to stop.
|
||||
kill-%:
|
||||
docker compose kill $*
|
||||
|
||||
.PHONY: new-develop
|
||||
# HELP: instantiate new development bundle, i.e. create new directory under develop/
|
||||
new-develop:
|
||||
$(NEW_DEVELOP)
|
||||
mkdir -p $(DEVELOP)
|
||||
$(MAKE) develop/.current
|
||||
.PHONY: switch-develop
|
||||
# HELP: switch current develop instance to DEVELOP=...
|
||||
switch-develop:
|
||||
if ! [ -e develop/$(DEVELOP) ]; then \
|
||||
echo "Specified develop $(DEVELOP) does not exist! Not switching." ; \
|
||||
exit 1 ; \
|
||||
fi ; \
|
||||
echo "$(DEVELOP)" > develop/.current
|
||||
--ensure-develop:
|
||||
if ! [[ -e develop ]]; then \
|
||||
$(MAKE) new-develop; \
|
||||
fi
|
||||
$(MAKE) develop/.current
|
||||
$(SET_DEVELOP)
|
||||
.PHONY: develop/.current
|
||||
develop/.current:
|
||||
ls -1 develop | tail -n1 > develop/.current
|
||||
.PHONY: status
|
||||
# HELP: print an overview of currently running services and their health
|
||||
status:
|
||||
docker compose ps
|
||||
.PHONY: top
|
||||
# HELP: print an overview of the ressource usage of the currently running services
|
||||
top:
|
||||
docker compose stats
|
||||
|
||||
.PHONY: log-%
|
||||
# HELP(log-$SERVICE): follow the output of a given service. Service must be running.
|
||||
log-%:
|
||||
docker compose logs --follow --timestamps $*
|
||||
|
||||
.PHONY: --%
|
||||
.SUFFIXES: # Delete all default suffixes
|
||||
|
||||
0
backend/.ghc/ghci_history
Normal file
0
backend/.ghc/ghci_history
Normal file
@ -17,41 +17,16 @@ RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \
|
||||
apt-get -y update && apt-get install -y --no-install-recommends locales locales-all
|
||||
|
||||
# run-time dependencies for uniworx binary
|
||||
RUN apt-get -y update && apt-get -y install fonts-roboto
|
||||
# RUN apt-get -y update && apt-get -y install pdftk
|
||||
# RUN apt-get -y update && apt-get -y install \
|
||||
# texlive texlive-latex-recommended texlive-luatex texlive-plain-generic texlive-lang-german texlive-lang-english
|
||||
RUN apt-get -y update && apt-get -y install \
|
||||
wget \
|
||||
perl \
|
||||
xz-utils \
|
||||
fonts-roboto \
|
||||
texlive \
|
||||
texlive-luatex \
|
||||
texlive-latex-extra \
|
||||
texlive-fonts-recommended \
|
||||
texlive-fonts-extra \
|
||||
&& apt-get clean
|
||||
RUN apt-get -y update && apt-get -y install texlive
|
||||
# RUN ls /usr/local/texlive
|
||||
# RUN chown -hR root /usr/local/texlive/2018
|
||||
ENV PATH="/usr/local/texlive/2018/bin/x86_64-linux:${PATH}"
|
||||
ENV TEXLIVE_VERSION=2018
|
||||
RUN tlmgr init-usertree
|
||||
RUN tlmgr option repository ftp://tug.org/historic/systems/texlive/2018/tlnet-final
|
||||
RUN tlmgr update --self --all
|
||||
RUN tlmgr install \
|
||||
babel \
|
||||
babel-english \
|
||||
babel-german \
|
||||
booktabs \
|
||||
textpos \
|
||||
enumitem \
|
||||
# luatex lualatex luatexbase lualatex-math eurosym \
|
||||
# above line requires tlmgr to run in -sys mode (~root?! apparently -privileged is missing)
|
||||
koma-script \
|
||||
unicode-math \
|
||||
selnolig
|
||||
|
||||
|
||||
# RUN tlmgr init-usertree
|
||||
# RUN tlmgr option repository ftp://tug.org/historic/systems/texlive/2018/tlnet-final
|
||||
# RUN tlmgr update --self --all
|
||||
|
||||
ARG PROJECT_DIR=/fradrive
|
||||
ENV PROJECT_DIR=${PROJECT_DIR}
|
||||
52
backend/Makefile
Normal file
52
backend/Makefile
Normal file
@ -0,0 +1,52 @@
|
||||
export CPU_CORES = $(shell cat /proc/cpuinfo | grep '^processor' | wc -l)
|
||||
export STACK_CORES = $(shell echo $(($(CPU_CORES)/2)))
|
||||
|
||||
ifeq ($(PROD),true)
|
||||
export --DEVELOPMENT=--flag uniworx:-dev
|
||||
else
|
||||
export --DEVELOPMENT=--flag uniworx:dev
|
||||
endif
|
||||
|
||||
.PHONY: dependencies
|
||||
dependencies:
|
||||
chown -R `id -un`:`id -gn` "$(PROJECT_DIR)"; \
|
||||
stack install hpack; stack install yesod-bin; \
|
||||
stack build -j2 --only-dependencies
|
||||
|
||||
.PHONY: compile
|
||||
compile: dependencies
|
||||
stack build $(STACK_CORES) --fast --profile --library-profiling --executable-profiling --flag uniworx:-library-only $(--DEVELOPMENT) --local-bin-path $$(pwd)/bin --copy-bins
|
||||
|
||||
.PHONY: lint
|
||||
lint:
|
||||
stack build $(STACK_CORES) --test --fast --flag uniworx:library-only $(--DEVELOPMENT) uniworx:test:hlint
|
||||
|
||||
.PHONY: test
|
||||
test:
|
||||
stack build $(STACK_CORES) --test --coverage --fast --flag uniworx:library-only $(--DEVELOPMENT)
|
||||
|
||||
# For Reverse Proxy Problem see: https://groups.google.com/g/yesodweb/c/2EO53kSOuy0/m/Lw6tq2VYat4J
|
||||
.PHONY: start
|
||||
start: dependencies
|
||||
export YESOD_IP_FROM_HEADER=true; \
|
||||
export DEV_PORT_HTTP=3000; \
|
||||
export DEV_PORT_HTTPS=3443; \
|
||||
export HOST=127.0.0.1 ; \
|
||||
export PORT=$${PORT:-$${DEV_PORT_HTTP}} ; \
|
||||
export DETAILED_LOGGING=$${DETAILED_LOGGING:-true} ; \
|
||||
export LOG_ALL=$${LOG_ALL:-false} ; \
|
||||
export LOGLEVEL=$${LOGLEVEL:-info} ; \
|
||||
export DUMMY_LOGIN=$${DUMMY_LOGIN:-true} ; \
|
||||
export SERVER_SESSION_ACID_FALLBACK=$${SERVER_SESSION_ACID_FALLBACK:-true} ; \
|
||||
export SERVER_SESSION_COOKIES_SECURE=$${SERVER_SESSION_COOKIES_SECURE:-false} ; \
|
||||
export COOKIES_SECURE=$${COOKIES_SECURE:-false} ; \
|
||||
export ALLOW_DEPRECATED=$${ALLOW_DEPRECATED:-true} ; \
|
||||
export ENCRYPT_ERRORS=$${ENCRYPT_ERRORS:-false} ; \
|
||||
export RIBBON=$${RIBBON:-$${HOST:-localhost}} ; \
|
||||
export APPROOT=$${APPROOT:-http://localhost:$${DEV_PORT_HTTP}} ; \
|
||||
export AVSPASS=$${AVSPASS:-nopasswordset} ; \
|
||||
stack $(STACK_CORES) exec --local-bin-path $$(pwd)/bin --copy-bins -- yesod devel -p "$${DEV_PORT_HTTP}" -q "$${DEV_PORT_HTTPS}"
|
||||
|
||||
.PHONY: clean
|
||||
clean:
|
||||
rm -rf .stack-work .stack uniworx.cabal .ghc
|
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user