- Python 2.7
- PostgreSQL
- Node.js
Optional:
- virtualenvwrapper
- autoenv
Follow the instructions below to set up the development environment.
Create a virtualenv:
$ mkvirtualenv bittivaihto
Make the virtualenv activate automagically when traversing inside the project directory:
$ echo -e "workon bittivaihton" > .env
Install Python dependencies:
$ pip install -r requirements-dev.txt
Install Node.js dependencies:
$ npm install
Create database for development and testing:
$ createdb bittivaihto $ createdb bittivaihto_test
Create database tables:
$ python manage.py syncdb
Finally, start the development server:
$ python manage.py runserver
Re-create the development database:
$ dropdb pelsu $ createdb pelsu
Copy the production database to the development database:
$ fab production copy_postgres:local
You can run the tests with py.test:
$ py.test
If someone has already created the Heroku applications for this project, you only need to add the following Git remotes to your local Git clone:
$ git remote add production git@heroku.com:pelastussuunnitelma.git $ git remote add staging git@heroku.com:pelastussuunnitelma-staging.git
Otherwise, follow the steps below to create the Heroku applications for this project.
Create a new Heroku application.:
$ heroku apps:create bittivaihto \ --buildpack https://github.com/fastmonkeys/heroku-buildpack-flask.git \ --remote production
Change the project name and remote argument, if you are creating a staging application. The above command assumes you are creating a production application.
Enable environmental variables during the slug compilation phase:
$ heroku labs:enable user_env_compile --remote production
Set the application to use production environment:
$ heroku config:add FLASK_ENV=production --remote production
Generate a secret key for the application:
$ heroku config:add SECRET_KEY=`python manage.py generate_secret_key` \ --remote production
Add Heroku PostgreSQL addon to the application for relational database support:
$ heroku addons:add heroku-postgresql:dev --remote production $ heroku pg:promote HEROKU_POSTGRESQL_COLOR --remote production
(Optional) Add New Relic addon to the application, if you want to monitor application's performance:
$ heroku addons:add newrelic --remote production
Deploying the application to Heroku is really easy.
If you are deploying to production:
$ fab production deploy
If you are deploying to staging:
$ fab staging deploy
This simple command will take care of
- pushing new code to Heroku
- migrating the database to the latest revision.