When or where in a custom Heroku buildpack are config vars available in the environment?

StackOverflow https://stackoverflow.com/questions/11906791

  •  25-06-2021
  •  | 
  •  

Question

I understand that running a rake task that expects the environment to fully work requires that the DB connection can actually be stablished. Basically, that's the reason why Heroku needs asset pipeline precompilations to run before the environment can be loaded.

That's why this line is needed to deploy rails 3.X apps to the Cedar:

    config.assets.initialize_on_precompile = false

Now, I'm trying to build a custom build pack that needs a rake task to do other assets compilations to make the app work as expected. This is because I have internationalized JS asset files and use https://github.com/fnando/i18n-js

I need to run rake i18n:js:export and that requires the environment. *Is there any point in the buildpack where I can add this call and be sure that the connection to the DB of the Rails app will work? * Loading the environment is as a requirement of this task and I don't know how to work it out and it gives the typical error:

rake aborted!
could not connect to server: Connection refused
    Is the server running on host "127.0.0.1" and accepting
    TCP/IP connections on port 5432?

Naturally, I can compile locally and then deploy. But the buildpack seems like the right tool to solve this matter in an automated way. Thanks for the help!

Was it helpful?

Solution

Check out the user env Heroku labs feature: https://devcenter.heroku.com/articles/labs-user-env-compile

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top