Deploying to Heroku
When you're ready to deploy to Heroku, it's highly recommended you use this button:
In order for this to work, you'll need to authorize Heroku to access your GitHub account.
This button leverages the configuration found in
app.json, including sensible defaults for dyno formation, third-party services, buildpack configuration, etc.
We've included the "entry-level but production-grade" service tier across the board for:
- Heroku Postgres
- Heroku Redis to support Sidekiq and Action Cable.
- Memcachier to support Rails Cache.
- HDrive to support off-server file uploads backed by AWS S3.
- Cloudinary to support off-server image uploads and ImageMagick processing.
- Heroku Scheduler for cron jobs.
- Rails Autoscale for best-of-breed reactive performance monitoring.
- Honeybadger and Sentry, both free, for redundant error tracking.
- Expedited Security's Real Email to reduce accounts created with fake and unreachable emails, which will subsequently hurt your email deliverability.
Speeding Up Asset Precompilation
Historically asset compilation could take as long as four minutes when deploying to Heroku. Through the inclusion of three custom buildpacks provided by Jan Žák, Hirotaka Ikoma, and others, we're able to reduce that part of the deploy process down to about 30 seconds.
We've forked these three buildpacks into our own GitHub organization to help mitigate the risk of a supply chain attack where your application can become compromised via the compromised repository of a third-party buildpack. To reduce this risk even further, you can also fork our copy of the following repositories and configure your Heroku application to use your forked buildpack repositories in place of ours.
Additional Required Steps
Even after using the above button, there are a few steps that need to be performed manually using the Heroku CLI:
1. Add Heroku as a Remote in Your Local Repository
heroku git:remote -a YOUR_HEROKU_APP_NAME
After this, you'll be able to deploy updates to your app like so:
git push heroku main
2. Running Database Migrations and Seeds
We've decided not to configure the application to automatically run database migrations after a deploy for the time being. For that reason, you'll need to run the migrations and seeds manually, like so:
heroku run rake db:migrate heroku run rake db:seed
3. Enabling Runtime Dyno Metadata
We include Honeybadger and Sentry (both at a free tier) for redundant error tracking by default. Sentry requires the following Heroku labs feature to be enabled:
heroku labs:enable runtime-dyno-metadata
4. Adding Your Actual Domain
The most common use case for Bullet Train applications is to be hosted at some appropriate subdomain (e.g.
app.YOURDOMAIN.COM) while a marketing site is hosted with a completely different service at the apex domain (e.g. just
www.YOURDOMAIN.COM. To accomplish this, do the following in your shell:
heroku domains:add app.YOURDOMAIN.COM
The output for this command will say something like:
Configure your app's DNS provider to point to the DNS Target SOMETHING-SOMETHING-XXX.herokudns.com.
On most DNS providers this means going into the DNS records for
YOURDOMAIN.COM and adding a CNAME record for the
app subdomain with a value of
SOMETHING-SOMETHING-XXX.herokudns.com (except using the actual value provided by the Heroku CLI) and whatever TTL refresh rate you desire. I always set this as low as possible at first to make it easier to fix any mistakes I've made.
After you've added that record, you need to update the following environment settings on the Heroku app:
heroku config:set BASE_URL=https://app.YOURDOMAIN.COM heroku config:set MARKETING_SITE_URL=https://YOURDOMAIN.COM
You'll also need to enable Heroku's Automated Certificate Management to have them handle provisioning and renewing your Let's Encrypt SSL certificates:
heroku certs:auto:enable heroku certs:auto
You should be done now and your app should be available at
https://app.YOURDOMAIN.COM/account and any hits to
https://app.YOURDOMAIN.COM (e.g. when users sign out, etc.) will be redirected to your marketing site.