From: Stephen Finucane Date: Thu, 13 Sep 2018 17:13:20 +0000 (-0600) Subject: Add a Makefile X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=398cc2cc8baafff1931a7453f50f3e783d789c34;p=thirdparty%2Fpatchwork.git Add a Makefile Time to go old school. When using Docker, we can't simply use tox or manage.py command as commands should run inside the container and not on the host. To resolve this, we recommend using 'docker-compose run --rm web tox', which will run tox in the container. Having to remember these rather esoteric commands is annoying though (particularly when I haven't run it recently and therefore can't find the command with '+R'). A series of make targets make this a heck of a lot easier for us. Note that this isn't ideal and won't entirely remove the need to run the above command. This is mostly due to how make is designed: namely, we need to pass positional arguments but each positional argument in make should be a target. This does, however, cover the biggest use cases and is therefore worth doing. Signed-off-by: Stephen Finucane --- diff --git a/.gitignore b/.gitignore index 1282bc9f..248b1bd4 100644 --- a/.gitignore +++ b/.gitignore @@ -58,3 +58,6 @@ patchwork/settings/production.py # django-dbbackup files /.backups + +# Makefile state files +/.state diff --git a/Makefile b/Makefile new file mode 100644 index 00000000..2374f51b --- /dev/null +++ b/Makefile @@ -0,0 +1,44 @@ +MANAGE_PY := docker-compose run --rm web python manage.py + +default: + @echo "Call a specific subcommand" + @exit 1 + +.state/docker-build: docker-compose.yml tools/docker/Dockerfile requirements-dev.txt + docker-compose build + mkdir -p .state + touch .state/docker-build + +build: + docker-compose build + mkdir -p .state + touch .state/docker-build + +serve: .state/docker-build + docker-compose up + +tests: .state/docker-build + docker-compose run -e TOXENV=${TOXENV} --rm web tox + +manage: .state/docker-build + $(MANAGE_PY) $(CMD) + +dbshell: .state/docker-build + $(MANAGE_PY) dbshell + +shell: .state/docker-build + $(MANAGE_PY) shell + +migrate: .state/docker-build + $(MANAGE_PY) migrate + +makemigrations: .state/docker-build + $(MANAGE_PY) makemigrations + +dbbackup: .state/docker-build + $(MANAGE_PY) dbbackup + +dbrestore: .state/docker-build + $(MANAGE_PY) dbrestore + +.PHONY: default build serve tests dbshell shell manage migrate makemigrations dbbackup dbrestore