How to setup your PostgreSQL database template

Our DB templates for PostgreSQL come with a build-in initialization script that allows you to seed you DB during the build process. This allows you to ‘bake’ your seed into your master DB container. Then every branch that you run in isolation will immediately start up with a DB container that is pre-seeded, taking advantage of the container image cache.

Getting Started

Produce a dump of your development database to upload to Runnable

Upload the seed file to your template configuration

  1. Bring up the template configuration modal by either clicking on the cog next to your database template in the Containers pane, or clicking on Dockerfile in the Templates pane. Select Template
  2. Select the Dockerfile tab on the top menu within the modal. Select Dockerfile
  3. Click on the [+] button above the file explorer to the left of the Dockerfile editor. Add File/Folder
  4. Select ‘Upload File’ to bring up the file selector and choose your dump file (i.e. seed.dump). File Uploaded

Enable the database seeding functionality

  1. Uncomment the ADD seed.dump /seed/dump line in the Dockerfile editor to the right. Uncomment Seed

    If you have named your seed something other than seed.dump, you should modify the first part of the add command. Make sure you leave the second seed.dump intact so the init script will work.

  2. Now click Save & Build to build your container and seed your database.

Next steps

Now that your template database container has been ‘baked’ in with your seed file, subsequent databases that are spawned per branch will immediately start up with the seeded data. If you ever want to update your seed file, just click Rebuild Without Cache on the template container to pull a newer seed and cache it into the container image.

Want to seed your database from S3? Here is how.