| 1 | = Heroku = |
| 2 | [[TOC]] |
| 3 | |
| 4 | == Introduction == |
| 5 | Eden can be easily deployed on heroku. |
| 6 | The initial deployment is free of cost and does not require a credit card. |
| 7 | For making the deployment scalable, and to introduce more add-ons to the deployment, appropriate pricing is available. |
| 8 | |
| 9 | More information can be found here - [https://www.heroku.com/pricing Pricing] |
| 10 | |
| 11 | == Deployment == |
| 12 | |
| 13 | * The deployment process is very straightforward. |
| 14 | * Changes when committed and pushed to git automatically reflect in the deployment, and the application is rebuilt and redeployed. |
| 15 | |
| 16 | The following script will be useful in deploying eden on heroku - |
| 17 | |
| 18 | {{{ |
| 19 | # Choose the Admin Password |
| 20 | read -p "Choose your admin password?" passwd |
| 21 | |
| 22 | # Get latest web2py |
| 23 | git clone https://github.com/web2py/web2py.git web2py |
| 24 | cd web2py/applications |
| 25 | |
| 26 | # Get latest copy of Sahana Eden. |
| 27 | git clone https://github.com/flavour/eden.git eden |
| 28 | |
| 29 | # Copy and edit the config file |
| 30 | cp eden/private/templates/000_config.py eden/models/000_config.py |
| 31 | cat eden/models/000_config.py | sed "s/FINISHED_EDITING_CONFIG_FILE = False/FINISHED_EDITING_CONFIG_FILE = True/" > temp |
| 32 | mv temp eden/models/000_config.py |
| 33 | |
| 34 | cd .. |
| 35 | |
| 36 | # Install virtualenv and postgres DB |
| 37 | sudo pip install virtualenv |
| 38 | sudo pip install psycopg2 |
| 39 | |
| 40 | # Activate the virtual environment |
| 41 | virtualenv venv --distribute |
| 42 | source venv/bin/activate |
| 43 | |
| 44 | # Generate the requirements for Eden. |
| 45 | cp applications/eden/requirements.txt . |
| 46 | echo "" >> requirements.txt |
| 47 | pip freeze >> requirements.txt |
| 48 | |
| 49 | # Write the Procfile used by heroku |
| 50 | echo "web: python web2py.py -a '$passwd' -i 0.0.0.0 -p \$PORT" > Procfile |
| 51 | |
| 52 | # Create a remote for heroku |
| 53 | heroku create |
| 54 | |
| 55 | # Choose the application name |
| 56 | read -p "Choose your application name?" appname |
| 57 | heroku apps:rename $appname |
| 58 | |
| 59 | # Remove eden from version control and add it to web2py version control (there should be one version control) |
| 60 | cd applications/eden/ |
| 61 | rm -rf .git |
| 62 | git add -f . |
| 63 | cd ../../ |
| 64 | git add . |
| 65 | git add Procfile |
| 66 | |
| 67 | git commit -a -m "first commit" |
| 68 | |
| 69 | # Push Eden to heroku |
| 70 | git push heroku master |
| 71 | |
| 72 | # Add add-ons : Postgres DB |
| 73 | heroku addons:add heroku-postgresql:dev --app $appname |
| 74 | heroku scale web=1 --app $appname |
| 75 | |
| 76 | # Open the application. |
| 77 | heroku open --app $appname |
| 78 | |
| 79 | }}} |
| 80 | |
| 81 | * Whenever {{{git push heroku master}}} is done with some changes, those changes are pushed into the application deployed on heroku. |