-
-
Notifications
You must be signed in to change notification settings - Fork 6
/
makefile
139 lines (97 loc) · 2.66 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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
.PHONY: app
#################
### VARIABLES ###
#################
API_TOKEN=`grep 'API_TOKEN' config.env | sed 's/^.*=//'`
HEROKU_EMAIL=`grep 'HEROKU_EMAIL' config.env | sed 's/^.*=//'`
HEROKU_API_KEY=`grep 'HEROKU_API_KEY' config.env | sed 's/^.*=//'`
APP_PORT = 8501
CONTAINER_NAME = noise-dashboard
PROD_IMAGE_NAME = noise-dashboard
DEV_IMAGE_NAME = $(PROD_IMAGE_NAME)-dev
HEROKU_APP_NAME = noise-dashboard
api_token:
echo $(API_TOKEN)
#############
### HOOKS ###
#############
install-pre-commit:
pip install pre-commit
setup-pre-commit:
pre-commit install
##############
### HEROKU ###
##############
heroku_login:
echo "machine api.heroku.com" > ~/.netrc;\
echo " login $(HEROKU_EMAIL)" >> ~/.netrc;\
echo " password $(HEROKU_API_KEY)" >> ~/.netrc;\
echo "machine git.heroku.com" >> ~/.netrc;\
echo " login $(HEROKU_EMAIL)" >> ~/.netrc;\
echo " password $(HEROKU_API_KEY)" >> ~/.netrc;\
docker login --username=$(HEROKU_EMAIL) --password=$(HEROKU_API_KEY) registry.heroku.com;
heroku_push:
docker tag $(PROD_IMAGE_NAME) registry.heroku.com/$(HEROKU_APP_NAME)/web
docker push registry.heroku.com/$(HEROKU_APP_NAME)/web
heroku_release:
heroku container:release web -a $(HEROKU_APP_NAME)
##############
### DOCKER ###
##############
build: dev_build prod_build
### RUN ###
dev_container: docker_clean
docker run -it\
-v "$(PWD)":/project\
-p $(APP_PORT):$(APP_PORT)\
-p 8888:8888\
-w /project\
-e PORT=$(APP_PORT)\
--name $(CONTAINER_NAME)\
$(DEV_IMAGE_NAME)
prod_container: docker_clean
docker run -d\
-p $(APP_PORT):$(APP_PORT)\
-e PORT=$(APP_PORT)\
--name $(CONTAINER_NAME)\
$(PROD_IMAGE_NAME)
### BUILD ###
prod_build:
docker build --build-arg TOKEN=$(API_TOKEN) --no-cache --target prod-builder -t $(PROD_IMAGE_NAME) .
dev_build:
docker build --build-arg TOKEN=$(API_TOKEN) --target dev-builder -t $(DEV_IMAGE_NAME) .
### COMPOSE ###
# dev_compose:
# docker compose -f docker-compose.dev.yml up -d --build
# prod_compose:
# docker compose -f docker-compose.yml up -d --build
### CLEANUP ###
docker_clean:
docker stop $(CONTAINER_NAME) || true && docker container rm $(CONTAINER_NAME) || true
###############
### TESTING ###
###############
test:
pytest .
###########
### PIP ###
###########
pip_export:
pip freeze > requirements.txt
################
### RUN APPs ###
################
notebook:
jupyter notebook --ip 0.0.0.0 --no-browser --allow-root
app:
(cd /project/app; gunicorn --bind 0.0.0.0:$(APP_PORT) app:server)
debug:
(cd /project/app; python app.py)
#############
### Utils ###
#############
count:
wc -l **/*.py makefile Dockerfile README.md
remove_branch:
git push -d origin $(BRANCH)
git branch -d $(BRANCH)