forked from ebreton/uptimerobot-proxy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
89 lines (77 loc) · 2.5 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
#!make
# Default values, can be overridden either on the command line of make
# or in .env
FLASK_DEBUG ?= 0
.PHONY: init vars coverage run gunicorn local deploy
vars:
@echo 'App-related vars:'
@echo ' APP_SECRET=${APP_SECRET}'
@echo ' E2EMONITORING_SERVICE=${E2EMONITORING_SERVICE}'
@echo ' E2EMONITORING_URL=${E2EMONITORING_URL}'
@echo ' STORAGE_TYPE=${STORAGE_TYPE}'
@echo ' DATABASE_URL=${DATABASE_URL}'
@echo ''
@echo 'Dev-related vars:'
@echo ' PYTHONPATH=${PYTHONPATH}'
@echo ' FLASK_APP=${FLASK_APP}'
@echo ' FLASK_DEBUG=${FLASK_DEBUG}'
@echo ' GUNICORN_APP=${GUNICORN_APP}'
@echo ''
@echo 'Heroku-related vars:'
@echo ' HEROKU_APP=${HEROKU_APP}'
@echo ' HEROKU_URL=${HEROKU_URL}'
@echo ' HEROKU_GIT=${HEROKU_GIT}'
@echo ' DB_URI_VAR_NAME=${DB_URI_VAR_NAME}'
@echo ' HEROKU_USERNAME=${HEROKU_USERNAME}'
@echo ' HEROKU_PASSWORD=xxx'
init-venv:
ifeq ($(wildcard .env),)
cp .env.sample .env
echo PYTHONPATH=`pwd`/src >> .env
endif
pipenv --update
pipenv update --dev --python 3
@echo "-> Set up your .env file before launching make init-heroku"
init-heroku:
heroku create ${HEROKU_APP} || true
heroku config:set PYTHONPATH="./src"
heroku config:set FLASK_DEBUG=0
heroku config:set APP_SECRET="${APP_SECRET}"
heroku config:set E2EMONITORING_SERVICE="${E2EMONITORING_SERVICE}"
heroku config:set E2EMONITORING_URL="${E2EMONITORING_URL}"
heroku config:set MAIL_USERNAME="${HEROKU_USERNAME}"
@heroku config:set MAIL_PASSWORD="${HEROKU_PASSWORD}" > /dev/null
heroku config:set STORAGE_TYPE="models.storage"
heroku addons:add heroku-postgresql:hobby-dev
@echo "-> Replace HEROKU_APP vars in your .env file"
@echo "-> Run 'heroku run init' when done"
info:
heroku apps
heroku addons
heroku config
test: check-env
flake8 src --max-line-length=120
pytest --cov=src test
coverage: test
coverage html
open htmlcov/index.html
run: test
flask run
gunicorn: test
ifeq (,$(wildcard ./src/gunicorn.db))
STORAGE_TYPE=models.storage DATABASE_URL=sqlite:///gunicorn.db python src/commands.py init-db
endif
STORAGE_TYPE=models.storage DATABASE_URL=sqlite:///gunicorn.db gunicorn ${GUNICORN_APP}
heroku: test
STORAGE_TYPE=models.storage DATABASE_URL=postgres://127.0.0.1/$(whoami) python src/commands.py init-db
STORAGE_TYPE=models.storage DATABASE_URL=postgres://127.0.0.1/$(whoami) heroku local -p 7000
deploy: test
git push heroku master
check-env:
ifeq ($(wildcard .env),)
@echo "Please create your .env file first, from .env.sample or by running make venv"
@exit 1
else
include .env
export
endif