Skip to content

Commit 7fdbffa

Browse files
committedOct 16, 2020
Easy deploy via Makefile.
1 parent 67fba43 commit 7fdbffa

File tree

5 files changed

+95
-29
lines changed

5 files changed

+95
-29
lines changed
 

‎Makefile

+58
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
SRCPATH := $(CURDIR)
2+
PROJECTNAME := $(shell basename $(CURDIR))
3+
4+
define HELP
5+
Manage $(PROJECTNAME). Usage:
6+
7+
make run - Run $(PROJECTNAME).
8+
make deploy - Install requirements and run app for the first time.
9+
make update - Update pip dependencies via Python Poetry.
10+
make format - Format code with Python's `Black` library.
11+
make clean - Remove cached files and lock files.
12+
endef
13+
export HELP
14+
15+
.PHONY: run deploy update format clean help
16+
17+
18+
requirements: .requirements.txt
19+
20+
21+
.requirements.txt: requirements.txt
22+
$(shell . .venv/bin/activate && pip install -r requirements.txt)
23+
24+
25+
all help:
26+
@echo "$$HELP"
27+
28+
29+
.PHONY: run
30+
run:
31+
$(shell . .venv/bin/activate && python3 wsgi.py)
32+
33+
34+
.PHONY: deploy
35+
deploy:
36+
$(shell . ./deploy.sh)
37+
38+
39+
.PHONY: update
40+
update:
41+
poetry shell && poetry update
42+
pip freeze > requirements.txt
43+
exit
44+
45+
46+
.PHONY: format
47+
format: requirements
48+
$(shell . .venv/bin/activate)
49+
$(shell isort -rc ./)
50+
$(shell black ./)
51+
52+
53+
.PHONY: clean
54+
clean:
55+
find . -name '*.pyc' -delete
56+
find . -name '__pycache__' -delete
57+
find . -name 'poetry.lock' -delete
58+
find . -name 'Pipefile.lock' -delete

‎deploy.sh

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#!/bin/bash
2+
3+
if [ -d ".venv" ]
4+
then
5+
source .venv/bin/activate
6+
pip install -r requirements.txt
7+
python3 wsgi.py
8+
else
9+
python3 -m venv .venv
10+
source .venv/bin/activate
11+
python3 -m pip install --upgrade pip
12+
pip install -r requirements.txt
13+
python3 wsgi.py
14+
fi

‎flask_assets_tutorial/assets.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ def compile_static_assets(assets):
2727
assets.register('main_styles', main_style_bundle)
2828
assets.register('main_js', main_js_bundle)
2929
assets.register('admin_styles', admin_style_bundle)
30-
if app.config['FLASK_ENV'] == 'development':
30+
if app.config['FLASK_ENV'] != 'production':
3131
main_style_bundle.build()
3232
main_js_bundle.build()
3333
admin_style_bundle.build()

‎poetry.lock

+14-28
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎requirements.txt

+8
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,22 @@
1+
attrs==20.2.0
12
click==7.1.2
23
cssmin==0.2.0
34
Flask==1.1.2
45
Flask-Assets==2.0
6+
iniconfig==1.1.1
57
itsdangerous==1.1.0
68
Jinja2==2.11.2
79
jsmin==2.2.2
810
lesscpy==0.14.0
911
MarkupSafe==1.1.1
12+
packaging==20.4
13+
pluggy==0.13.1
1014
ply==3.11
15+
py==1.9.0
16+
pyparsing==2.4.7
17+
pytest==6.1.1
1118
python-dotenv==0.14.0
1219
six==1.15.0
20+
toml==0.10.1
1321
webassets==2.0
1422
Werkzeug==1.0.1

0 commit comments

Comments
 (0)
Please sign in to comment.