Using Seed Data

There are multiple options for seeding data into your Preview Environments.

Custom Database Image

Depending on what data store you using, one option may be using a custom docker image preloaded with a seed data dump.

Community postgresql images will load data under /docker-entrypoint-initdb.d, and you can create a custom image as such:

FROM postgres:13.0-alpine
COPY database_name.sql /docker-entrypoint-initdb.d/

A good post regarding this method can be found here.

When building seed data into a custom docker image, you must ensure that the image is securely stored, and only pushed to private docker registries.

You will then want to specify your custom image in the postgresql chart-values file, and ensure that docker credentials are provided in order for the cluster to pull the private image.

If you are using a self-managed cluster, you can also choose to handle registry authentication at the cluster level.

Helm Chart Install Hook

If you are using an application which supports application level data seeding (such as Rails), you can add a Helm post-install hook to execute your migration, and populate your data. Preview ensures that dependencies are ready and available before the deployment of application charts in order to support this use case. Note that for larger data sets, this will likely be slower than using a pre-built database image.

If you want to limit a Helm hook to only run within Preview, you can render the hook conditionally, and provide a key to your chart in a values file.


For more complicated data seeding, or if you have more complex configuration which must be applied after environment creation, Preview can deliver a webhook after workflow completion. This hook can be used to connect in to the deployed environment, and execute additional set up, such as injecting seed data into the Preview created database services.

Last updated