To run development server locally, follow these steps:
- You will need to define several environment variable on your local machine:
use
export [KEY]=[VALUE]
on your terminal
register for a paypal sandbox app and input the credentials below:
PAYPAL_CLIENT_ID
PAYPAL_CLIENT_SECRET
RAILS_ENV set to 'development' on your local dev environment
REDIS_URL for sidekiq (in sidekiq.rb) is defaulted to your local host redis server.
The gmail sender credentials have been hard-coded in the dev environment, a suggested improvement is to have a dev mailing acc and change the corresponding configs in config/environments/development.rb
- Download postgres and redis server with homebrew
brew install postgresql
brew install redis
- start the postgres and redis server with homebrew
brew services start postgresql
brew services start redis
- make sure both postgresql and redis are active using this command
brew services list
- create a user on postgres
/usr/local/opt/postgres/bin/createuser -s postgres
- Run sidekiq worker server
bundle exec sidekiq
- set up database
rails db:setup
- precompile assets
rake assets:precompile
- Then on another terminal, run (you might have to export the env variables again if you run it on another terminal)
rails s
to start web server
To deploy to heroku,
Have heroku auto-build whatever is on your github repo's master branch, and You need the following addons
- Heroku Postgres
- Heroku Redis
- SendGrid
And define the following environment variables on heroku
- AWS_ACCESS_KEY_ID
- AWS_BUCKET
- AWS_REGION
- AWS_SECRET_ACCESS_KEY
- DATABASE_URL
- GMAIL_PASSWORD
- GMAIL_USERNAME
- LANG (en_US.UTF-8)
- PAYPAL_CLIENT_ID
- PAYPAL_CLIENT_SECRET
- RACK_ENV
- RAILS_ENV
- RAILS_MASTER_KEY
- REDIS_URL
- SECRET_KEY_BASE
- SENDGRID_API_KEY
- SENDGRID_PASSWORD
- SENDGRID_USERNAME
Finally, run the following commands on heroku to setup database and assets
rails db:setup
You can run the command on the heroku dashboard console or locally with the command
heroku run [COMMAND] -a [APP NAME]