We've moved discussions to Discord

Heroku postdeploy script crashes: "Don't know how to build task 'bootstrap'"

Pierre-Loïc
Hello all,

I am deploying a branch on a Review App in Heroku. FYI, this is almost the bare Jumpstart Pro template at the moment, just adding Overmind .env file (which I almost shouldn't) + updating rails from 6.1 to 6.1.3.1 to remove rails' mimemagic dependency.

The build succeeds, but the scripts, which I presume based on the app.json file, fail with this error:
rake aborted!
Don't know how to build task 'bootstrap'

I bugged on "bootstrap", which is supposed to be nowhere on the project. It actually appears in the app.json file:
{
  "name": "Jumpstart Pro",
  "description": "A Ruby on Rails template for SaaS apps and more",
  "website": "https://jumpstartrails.com",
  "scripts": {
    "postdeploy": "bundle exec rake bootstrap"
  },
  "env": {
    ...
  },
  ...
}

I don't understand why this is here, what's its purpose and why it did not fail before but does now.

Any idea?

Thanks :-)
Pierre-Loïc
After some investigations, here is what I understand so far.

  1. This app.json file is just Heroku's example, and the bundle exec rake bootstrap is just an example as well. For Review Apps, it seems that a better command would be bundle exec rake db:schema:load to initialize the database for the first time (since it creates a new PostGres instance every time you create a new Review App).
  2. Heroku recommend to always set RAILS_ENV to production, because maintaining multiple config files can be a hassle.
  3. In Rails, credentials are looked for based on the RAILS_ENV, which would mean that if you follow Heroku's recommendations, every Heroku environment is production and will look for config/credentials/production.yml.enc.

Then how could you have a RAILS_ENV=production and use the staging credentials?

I found part of the solution in this StackOverflow thread. The idea is to create a new environment variable that matches the step of your Heroku's pipeline and looks for the proper credentials in Rails, by overriding the behaviour of config.credentials.content_path.

I find this solution a bit sketchy, I will try it out and post the results here.
But if anyone here has a better experience than me in deploying Jumpstart Pro to Heroku using their Pipeline feature, I'm really interested.
Pierre-Loïc
Also, you definitely want to change the web[size] in the app.json to free:

"formation": {
  "web": {
    "quantity": 1,
    "size": "free"
  }
}

If you leave this at Standard-X1, every Review App created will be charged with the Standard pricing of $25/month, which can lead to surprises (already $2 💸 for me)

Chris Oliver I think you should set this to free by default, and let the users decide whether they want to upgrade this.
I ran into this as well when deploying my application to heroku for the first time, following the "Deploy using Heroku Deploy Button" instructions.

I overcame it by removing this line:
"postdeploy": "bundle exec rake bootstrap"

from my app.js
Chris Oliver
I think the bootstrap line was leftover from a copy paste. I replaced that with a db:migrate and also updated the size to free by default. 

For staging, you should set RAILS_ENV=staging 👍
Notifications
You’re not receiving notifications from this thread.