-
Notifications
You must be signed in to change notification settings - Fork 33
Deploying 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.
-
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.
-
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.
-
Note the Heroku App URL and the Heroku Git URL for future reference.
-
Click on the "Get Add-Ons" link in your Heroku app configuration page.
-
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.)
-
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.
-
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.
-
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. -
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.
-
Clone the trailsy repository. It's a git submodule of trailsyserver, so the process is a little different:
git submodule init git submodule update
-
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)
-
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
-
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]
-
Push the master branch of the code to Heroku. This will take a while:
git push heroku master
-
Now set up the database:
heroku run rake db:migrate
-
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]
-
Now add the initial users and organizations (NPS and MPSSC):
heroku run rake db:seed
-
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
-
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"