Skip to content

Deploying a New Instance

Dan Avery edited this page Nov 4, 2013 · 2 revisions

To The Trails: Creating a New Instance

This document gives step-by-step instructions for creating a completely new instance of To The Trails from scratch, deployed on Heroku.

  1. Create an Amazon Web Services account, if needed. In Amazon S3, create a bucket. This will be used for photo storage. For this document, it will be called "trailsy-photos", but you may create it with whatever name you like.

  2. Go to Heroku, and create a new app in your account. For purposes of this document, the app will be called "trailsy-setup". Substitute your app name for trailsy-setup wherever you see it in these instructions.

  3. Note the Heroku App URL and the Heroku Git URL for future reference.

  4. Click on the "Get Add-Ons" link in your Heroku app configuration page.

  5. Choose "Heroku Postgres" from the list presented. Choose the "Crane" service level and add it to the app. (Crane is currently the minimum DB service level that will allow PostGIS to be used.)

  6. You have to wait a few minutes for the DB to be set up. If you don't have the Heroku Toolbelt installed, this would be a good time add it. It's a command-line interface to Heroku. You'll also need to create/set-up Heroku ssh keys if you haven't already.

  7. Go back to the Heroku app add-ons page and choose "PG Backups". On that page, choose the "Auto - One Month Retention Add-on" and add it to your app.

  8. Note the environment variable created for you to point to your new database. It wil look like HEROKU_POSTGRESQL_[COLOR]_URL, where [COLOR] will be a random color.

  9. Clone the trailsyserver repository from Github. Assuming you have Git installed:

     git clone https://github.com/codeforamerica/trailsyserver.git
    

    This will create a "trailsyserver" directory with a clone of the repository.

  10. Clone the trailsy repository. It's a git submodule of trailsyserver, so the process is a little different:

     git submodule init
     git submodule update
    
  11. Now to go to the Postgres interactive terminal and install the PostGIS extension:

     heroku pg:psql --app trailsy-setup HEROKU_POSTGRESQL_[COLOR]_URL
     create extension postgis;
    

    (Then hit Ctrl-D to exit the psql terminal)

  12. Make the new DB instance you've created be the default DB for the app:

     heroku pg:promote HEROKU_POSTGRESQL_[COLOR]_URL --app trailsy-setup
    
  13. Create Heroku as a Git remote so you can push a clone of the repository there:

     git remote add heroku [the Heroku Git URL from above]
    
  14. Push the master branch of the code to Heroku. This will take a while:

     git push heroku master
    
  15. Now set up the database:

     heroku run rake db:migrate
    
  16. Once the database is set up, add the required environment variables (can be in one command--on separate lines for readability):

     heroku config:set BUILDPACK_URL=https://github.com/ddollar/heroku-buildpack-multi.git
     heroku config:set GDAL_BINDIR=/app/vendor/gdal/1.10.0/bin
     heroku config:set DEFAULT_ADMIN_USER=[email for the initial admin user]
     heroku config:set TEST_NPS_USER=[email for a test NPS user--does not need to be real]
     heroku config:set TEST_MPSSC_USER=[email for a test MPSSC user--does not need to be real]
     heroku config:set TRAILSY_AWS_ACCESS_KEY_ID=[your AWS access key]
     heroku config:set TRAILSY_AWS_BUCKET=trailsy-photos
     heroku config:set TRAILSY_AWS_SECRET_ACCESS_KEY=[your AWS secret key]
     heroku config:set DEFAULT_ADMIN_PASSWORD=[select an initial password for all three initial accounts]
    
  17. Now add the initial users and organizations (NPS and MPSSC):

     heroku run rake db:seed
    
  18. You can populate the database with some older sample data from Cuyahoga Valley National Park and Metro Parks, Serving Summit County:

     heroku run rake load:all
    
  19. Verify that the app is working at your Heroku app URL from the initial app creation. If the app is named "trailsy-setup", it will be "http://trailsy-setup.herokuapp.com". The admin interface will be at "http://trailsy-setup.herokuapp.com/admin"