Skip to content

Commit

Permalink
Easy deploy via Makefile.
Browse files Browse the repository at this point in the history
  • Loading branch information
toddbirchard committed Oct 16, 2020
1 parent 67fba43 commit 7fdbffa
Show file tree
Hide file tree
Showing 5 changed files with 95 additions and 29 deletions.
58 changes: 58 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
SRCPATH := $(CURDIR)
PROJECTNAME := $(shell basename $(CURDIR))

define HELP
Manage $(PROJECTNAME). Usage:

make run - Run $(PROJECTNAME).
make deploy - Install requirements and run app for the first time.
make update - Update pip dependencies via Python Poetry.
make format - Format code with Python's `Black` library.
make clean - Remove cached files and lock files.
endef
export HELP

.PHONY: run deploy update format clean help


requirements: .requirements.txt


.requirements.txt: requirements.txt
$(shell . .venv/bin/activate && pip install -r requirements.txt)


all help:
@echo "$$HELP"


.PHONY: run
run:
$(shell . .venv/bin/activate && python3 wsgi.py)


.PHONY: deploy
deploy:
$(shell . ./deploy.sh)


.PHONY: update
update:
poetry shell && poetry update
pip freeze > requirements.txt
exit


.PHONY: format
format: requirements
$(shell . .venv/bin/activate)
$(shell isort -rc ./)
$(shell black ./)


.PHONY: clean
clean:
find . -name '*.pyc' -delete
find . -name '__pycache__' -delete
find . -name 'poetry.lock' -delete
find . -name 'Pipefile.lock' -delete
14 changes: 14 additions & 0 deletions deploy.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/bash

if [ -d ".venv" ]
then
source .venv/bin/activate
pip install -r requirements.txt
python3 wsgi.py
else
python3 -m venv .venv
source .venv/bin/activate
python3 -m pip install --upgrade pip
pip install -r requirements.txt
python3 wsgi.py
fi
2 changes: 1 addition & 1 deletion flask_assets_tutorial/assets.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def compile_static_assets(assets):
assets.register('main_styles', main_style_bundle)
assets.register('main_js', main_js_bundle)
assets.register('admin_styles', admin_style_bundle)
if app.config['FLASK_ENV'] == 'development':
if app.config['FLASK_ENV'] != 'production':
main_style_bundle.build()
main_js_bundle.build()
admin_style_bundle.build()
Expand Down
42 changes: 14 additions & 28 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,14 +1,22 @@
attrs==20.2.0
click==7.1.2
cssmin==0.2.0
Flask==1.1.2
Flask-Assets==2.0
iniconfig==1.1.1
itsdangerous==1.1.0
Jinja2==2.11.2
jsmin==2.2.2
lesscpy==0.14.0
MarkupSafe==1.1.1
packaging==20.4
pluggy==0.13.1
ply==3.11
py==1.9.0
pyparsing==2.4.7
pytest==6.1.1
python-dotenv==0.14.0
six==1.15.0
toml==0.10.1
webassets==2.0
Werkzeug==1.0.1

0 comments on commit 7fdbffa

Please sign in to comment.