1 DEPLOY_HOST=halibut.cworth.org
2 DEPLOY_DIR=/srv/halibut.cworth.org/turbot
4 DO_NOT_DEPLOY=env .gitignore
5 DO_NOT_DELETE=.turbot.env
8 @echo "Available targets (in rough order of expected use):"
10 @echo " make bootstrap Setup python virtual environment"
11 @echo " make reqs Install dependencies into venv"
12 @echo " make run Run a local server for testing"
13 @echo " make deploy Deploy code to production"
18 ifeq (, $(wildcard env))
19 $(error "No virtualenv found. Try 'make bootstrap'")
22 $(error "No virtualenv active. Try '. ./env/bin/activate'")
27 @echo "=== Creating python virtual environment ==="
28 python3 -m virtualenv env
31 @echo "=== Installing pip-tools (to compile dependency list) ==="
32 (. ./env/bin/activate && pip install pip-tools)
35 @echo "Virtual environment is now available."
36 @echo "You must activate it by sourcing the activation script, such as:"
38 @echo " . ./env/bin/activate"
40 @echo "After that you can run 'make reqs' to install dependencies"
43 reqs: require-venv requirements.txt
44 pip install --require-hashes --upgrade -r requirements.txt
46 @echo "Dependencies are now installed. You can now do 'make run' or 'make deploy'"
48 requirements.txt: requirements.in
49 ifeq (, $(shell which pip-compile))
50 $(error "No pip-compile found. Try 'make bootstrap'")
52 pip-compile --no-index --generate-hashes --allow-unsafe
57 turbot.wsgi: turbot.wsgi.in Makefile
58 envsubst < turbot.wsgi.in > turbot.wsgi
62 git clone . .deploy-source
63 rm -rf .deploy-source/.git
64 make -C .deploy-source turbot.wsgi
65 (cd .deploy-source; rsync -avz \
66 $(DO_NOT_DEPLOY:%=--exclude=%) \
67 --exclude=$(DO_NOT_DELETE) \
70 ./ $(DEPLOY_HOST):$(DEPLOY_DIR) )
72 ssh $(DEPLOY_HOST) '(cd $(DEPLOY_DIR); make bootstrap; . env/bin/activate; make reqs)'