Newer
Older
-include build/base.Makefile
-include build/docker.Makefile
help::
@echo "$(APP_NAME) targets:"
@echo " init.app - init application environment"
@echo " init.dev - init development environment"
@echo " spell - check spelling of text"
@echo " format - apply automatic formatting"
@echo " test - run test suite"
@echo " log - tail log file"
@echo " run - start app"
@echo " run.gunicorn - start app with gunicorn"
@echo " release - tags and pushes a release with current version"
AURA_ENGINE_API_HOST ?= 127.0.0.1
AURA_ENGINE_API_PORT ?= 8008
AURA_ENGINE_API_CONFIG := ${CURDIR}/config/engine-api.docker.ini
AURA_LOGS := ${CURDIR}/logs
AURA_UID := 2872
AURA_GID := 2872
DOCKER_RUN = @docker run \
--name $(APP_NAME) \
--network="host" \
--mount type=tmpfs,destination=/tmp \
-v "$(AURA_ENGINE_API_CONFIG)":"/etc/aura/engine-api.ini":ro \
-v "$(AURA_LOGS)":"/srv/logs" \
-u $(AURA_UID):$(AURA_GID) \
$(DOCKER_ENTRY_POINT) \
autoradio/$(APP_NAME)
# Targets
init.app:: pyproject.toml
cp -n config/sample.engine-api.ini config/engine-api.ini
cp -n config/sample/gunicorn/sample.gunicorn.conf.py config/gunicorn.conf.py
init.dev:: pyproject.toml
poetry run pre-commit autoupdate
poetry run pre-commit install
cp -n config/sample.engine-api.ini config/engine-api.ini
lint::
poetry run python3 -m flake8 .
spell::
poetry run codespell $(wildcard *.md) docs src tests config contrib
format::
poetry run python3 -m isort .
poetry run black .
# TODO tests are not yet implemented (https://gitlab.servus.at/aura/engine-api/-/issues/5)
test::
poetry run coverage run -m unittest discover . && poetry run coverage report -m
log::
tail -f logs/$(APP_NAME).log
run::
poetry run python3 -m aura_engine_api.app
run.gunicorn::
poetry run gunicorn -c config/gunicorn.conf.py aura_engine_api.app:app \
--bind $(AURA_ENGINE_API_HOST):$(AURA_ENGINE_API_PORT)
release:: VERSION := $(shell python3 -c 'import tomli; print(tomli.load(open("pyproject.toml", "rb"))["tool"]["poetry"]["version"])')
release::
git tag $(VERSION)
git push origin $(VERSION)
@echo "Release '$(VERSION)' tagged and pushed successfully."