Today we've shipped two often-requested features for service builds:
Admittedly, this could be more elegant—database migrations should run according to whether the database is up to date, not according to whether code needs to be built. And to complicate matters further, services that deploy a prebuilt image can't customize their build command this way.
Enter the new pre-deploy command. As its name suggests, this command runs before each deploy of your service, regardless of whether Render executed a build for that deploy. This means it also runs for services that deploy a prebuilt Docker image.
You set your pre-deploy command from the Render Dashboard, alongside your build and start commands:
Pre-deploy command logs are included in each deploy…
…and if the command fails, the deploy is canceled.
Like the build command, your pre-deploy command uses pipeline minutes (formerly known as build minutes).
Give pre-deploy commands a try! You can set one for any paid web service, private service, or background worker.
- Set a pre-deploy command to run tasks just before each deploy of your service. This is perfect for performing database migrations and asset uploads—especially for services that deploy a prebuilt Docker image.
- For teams, enable the Performance build pipeline to run all of your build tasks with significantly more memory and CPU.
Pre-deploy command
Up until now, if your Render app ran new database migrations before every deploy, you probably shoehorned that migration step into your build command by running a miniature script. Here's mine from one of my own apps:npm install
db-migrate -e prod up