Dockerfile and render-build.sh

I can’t find clear documentation on these use of render-build.sh. I have an app on my account (hostedgpt-old) which has a render-build.sh file. I noticed that this script was running db:prepare but this is also a docker deploy and my Dockerfile launches a docker-entrypoint script which is also running db:prepare.

I’m working on ensuring my app can be deployed to multiple hosts so I’m trying to resolve this. I removed db:prepare from my docker-entrypoint since your docs suggest that render-build is what should handle it. I created a new commit with a trivial migration and I did a fresh deploy.

The deploy was successful but i don’t see anywhere in my deploy build logs that the migration was run. However, thea app successfully started and rails apps typically don’t start if there is a pending migration whcih has not been run. So I hop into console, open rails console, and check the database field I did a migration on and it has not been updated! Right now, I’m really confused.

  • Will the render-build.sh run even when I have a Dockerfile, or is that mistaken and I should remove it.
  • Any idea how my app successfully deployed the latest commit, which has a migration, and was able to successfully start up without running the migration?

Thanks for any help on this!

P.S. I have a follow-up question on another support issue that I’d love to get some eyes on: Is Render restarting my app b/c of RAM?

render-build.sh is simply a script file that has multiple commands in it. If you were deploying using our Ruby native runtime then you would typically put the path to the render-build.sh as the services build command and it would be invoked. Equally, you could also just have them all specified in the build command bundle install && rake db:migrate etc. Deploying with a Dockerfile you can do all of the Rails setup in there, the bundle, asset packaging etc and not need the render-build.sh at all.

Historically, we didn’t have a good place for post-deploy commands, so putting them in the build step was needed; nowadays we have predeployCommand (https://docs.render.com/deploys#pre-deploy-command), which can be used to migrate databases, etc. This should mean that Dockerfile’s can be platform agnostic as prior to this being added you had to do DB stuff in the Docker build step,

Regards,

1 Like