This document outlines the basic steps required to deploy lentil to the Heroku cloud platform. This outline is based on the lentil and Getting Started with Rails 3.x on Heroku documentation.
Create a new rails app using the lentil installation docs. Please note, there are several differences when creating a Heroku compliant rails application:
-
When creating a new application for lentil, the command should be invoked with a lentil compatible rails version:
rails _3.2.x_ new <name_of_app>
-
When editing the Gemfile, add the following gems in addition to the other modifications listed in the lentil documentation. Note: you may need to delete the
Gemfile.lock
before bundling.
ruby '2.1.5'
gem 'rails_12factor', group: :production
gem 'pg', group: :production
The gem definition for Sqlite3 should also be modified: gem 'sqlite3', group: :development
.
- In
config/application.rb
add:
config.assets.initialize_on_precompile = true
config.serve_static_assets = false
- In
config/database.yml
replace the production db definition with:
production:
adapter: postgresql
encoding: unicode
database: <name_of_app>_production
pool: 5
username: <name_of_app>
password:
-
Create a Herkou account.
-
Install the Heroku toolbelt for your operating system.
-
Login to Heroku from the command line using
heroku login
.
-
Store your app in git.
-
Create the app on Heroku by running
heroku create --addons heroku-postgresql
from your application directory. -
Deploy your code:
git push heroku master
. -
Run db migrations:
heroku run bundle exec rake db:migrate
-
Add dummy admin user:
heroku run bundle exec rake lentil:dummy_admin_user
. Create a new admin user and delete the dummy admin as soon as possible! -
Add seed data:
heroku run bundle exec rake db:seed
-
Ensure your "dyno" is running:
heroku ps:scale web=1
Vist your app: heroku open
.
There are three harvesting tasks that should be run regularly. These can be run as heroku run <harvesting-rake-task>
and automated one of two ways:
-
Using a local cron job to execute the harvesting tasks.
-
Using the Heroku scheduler add-on.
-
PostgreSQL must be installed (using a package manager or by building from source) and running on your system:
pg_ctl -D /usr/local/var/postgres -l /usr/local/var/postgres/server.log start
-
A PostgreSQL user must be created for your application:
createuser -s -r <name_of_app>
. -
You may also need to install the pg driver. See
config/database.yml
after creating your rails app for details. -
When creating a new application for lentil, the command should be invoked using the postgresql option and lentil compatible rails version:
rails _3.2.x_ new <name_of_app> --database=postgresql
. You will not need to modify theconfig/database.yml
file when using this method. -
Before running
bundle exec rake lentil:install:migrations
locally, runbundle exec rake db:create:all
to create the postgresql database.