⬆️Heroku Deploy
We currently use Heroku for deploying to production but LightningRails works with other popular options as well. We will add a guide to other ones very soon.
To install Heroku CLI in your terminal, follow these instructions:
macOS installation
brew tap heroku/brew && brew install heroku
heroku --version # It should display heroku/x.x.x
⚠️ If you get this error:
Bad CPU type in executable
Execute this command:
softwareupdate --install-rosetta --agree-to-license
heroku --version # Now it should display heroku/x.x.x
Ubuntu installation
curl https://cli-assets.heroku.com/install.sh | sh
heroku --version # It should display heroku/x.x.x
Login
Signin from the terminal to be able to push directly from the terminal
heroku login
Create your heroku app
To create an app and automatically connect it to your current directory of code through the GitHub remotes:
heroku create myawesomeapp --region eu
Push to production
After committing your last line of code, you can now push to production with a simple command
git push heroku master
Migrate your database
Remember that your development database is only in your computer and stored locally, heroku in turn is in the cloud, which means it will have a different database, that you must migrate and seed.
heroku run rails db:migrate # Run pending migrations in production
heroku run rails db:seed # Run the seed in production
Credential variables
Along the same lines as we set our API keys in our credentials file and .env file, you must set it to your production environment
heroku config:set postmark_api=YOUR_API_KEY
# repeat for all the API keys you have setup
Stripe credentials
You will need to go to your stripe dashboard and toggle the "Live" button, to access the live api keys "developers" > API. Once done, copy the keys in your terminal with the following command to
heroku config:set STRIPE_PUBLIC_KEY=****
heroku config:set STRIPE_PRIVATE_KEY=****
You will also need to create a webhook under "Webhooks":
Click on "add an endpoint"
Add the endpoint url:
"https://example.org/pay/webhooks/stripe"
Select events: Charge + checkout
Copy the key and paste it in your terminal with the following command
heroku config:set STRIPE_SIGNING_SECRET=*****
Error Handling in Heroku
If you run into an error when opening your app in the browser with
heroku open
You will need to investigate by looking at the logs
heroku logs --tail
Last updated
Was this helpful?