Created
April 21, 2018 15:02
-
-
Save dinamycam/03f84210bed22e2575011ca45dcab501 to your computer and use it in GitHub Desktop.
Makefile for django deployment
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
PROJECT_NAME = ProjectName | |
MAKE := make | |
PWD := $(shell dirname $(realpath $(lastword $(MAKEFILE_LIST)))) | |
# you can either have a single settings.py | |
# or multiple settings in projectpath/settings/{local, production,...} | |
# The later is assumed to be the case | |
SETTING_FILE = local | |
SETTINGS_MODULE = $(PROJECT_NAME).settings.$(SETTING_FILE) | |
wsgifile = wsgi.ini | |
.PHONY: all run serve \ | |
check_dependencies update \ | |
update_pip update migrations migrate \ | |
setup clean | |
all: update migrations migrate run | |
# for running the dev server | |
run: | |
python manage.py runserver --settings $(SETTINGS_MODULE) 0.0.0.0:8888 | |
# for production server | |
serve: | |
@echo 'starting uwsgi' | |
@echo '--------------' | |
uwsgi --ini $(wsgifile) & | |
@echo '+++++++++++++++' | |
@echo 'restarting nginx' | |
@echo '--------------' | |
sudo systemctl restart nginx | |
update: update_pip | |
update_pip: | |
@echo 'installing pip package dependencies.' | |
@echo '<<<< make sure >>>> you are in the <<< virtual environment >>>' | |
@echo '--------------------------------------------------------------' | |
pip install -r requirements | |
check_dependencies: | |
@echo 'Checking for outdated dependencies' | |
@echo '--------------' | |
pip list --outdated | |
migrations: | |
@echo 'Creating migrations for all apps' | |
@echo '------------------------------' | |
python manage.py makemigrations --settings $(SETTINGS_MODULE) | |
migrate: | |
@echo 'Running migrations' | |
@echo '------------------' | |
python manage.py migrate --settings $(SETTINGS_MODULE) | |
setup: update | |
@echo '------------------------' | |
@echo 'setting up nginx' | |
@echo '------------------------' | |
sudo ln -s $(PWD)/nginx.conf /etc/nginx/sites-enabled/ARShop.conf | |
$(MAKE) migrate | |
@echo '$(PROJECT_NAME) is ready. make run to start development server.' | |
clean: | |
find . -name "*.pyc" -exec rm -rf {} \; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment