Last active
September 29, 2016 18:25
-
-
Save diegosorrilha/68e2f411265c81e79ebc379a9ac26d49 to your computer and use it in GitHub Desktop.
Script that creates a app in heroku and deploy a Django App.
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
# Shell script to create a app in heroku and deploy this. | |
# Working for python 3.5.0 | |
# This script require heroku toolbelt installed and configured | |
# Usage: | |
# cd my_django_project | |
# curl https://gist.githubusercontent.com/diegosorrilha/68e2f411265c81e79ebc379a9ac26d49/raw/6b9c22779bbaf58a9de914ac78848f4701211e2b/django-start-deploy-heroku.sh -o ../django-start-deploy-heroku.sh | |
# WARNING: <namemyappdjango> Name need be same of the your app django | |
# source ../django-start-deploy-heroku.sh namemyappdjango | |
# rm ../django-start-deploy-heroku.sh | |
# Colors | |
red=`tput setaf 1` | |
green=`tput setaf 2` | |
yellow=`tput setaf 3` | |
reset=`tput sgr0` | |
PROJECT=$1 | |
echo "${green}>>> Creating the Procfile${reset}" | |
cat << EOF > Procfile | |
web: gunicorn $PROJECT.wsgi --log-file - | |
EOF | |
echo "${green}>>> Creating the runtime.txt${reset}" | |
cat << EOF > runtime.txt | |
python-3.5.0 | |
EOF | |
echo "${green}>>> Commiting config files${reset}" | |
echo "git add . && git commit -m 'Add config files - Heroku'" | |
git add . && git commit -m "Add config files - Heroku" | |
echo "${green}>>> Creating app in Heroku${reset}" | |
heroku create $PROJECT | |
echo "${green}>>> Sending config to Heroku${reset}" | |
heroku config:push --app $PROJECT | |
heroku config:set --app $PROJECT SECRET_KEY=`python contrib/secret_gen.py` | |
heroku config:set --app $PROJECT DEBUG=False | |
echo "${green}>>> Deploying app${reset}" | |
git push heroku master --force | |
heroku run python manage.py makemigrations | |
heroku run python manage.py migrate | |
clear | |
echo -n "Create superuser in Heroku? (y/N) " | |
read answer | |
if [ "$answer" == "y" ]; then | |
echo "${green}>>> Creating a superuser ...${reset}" | |
echo "${green}>>> The password must contain at least 8 characters.${reset}" | |
echo "${green}>>> Password suggestions: demodemo${reset}" | |
heroku run python manage.py createsuperuser | |
fi | |
clear | |
echo "${yellow}>>> Great! Project running in http://$PROJECT.herokuapp.com :)${reset}" | |
heroku open |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment