Building images with seeds
In most cases, using a built image with a seed script is the easiest way to seed a preview environment.Mongo example
If you’re using MongoDB, you can create aDockerfile using the mongo image as the base image, and copy the necessary seed files to the /docker-entrypoint-initdb.d path within that image. Any files within that path will be automatically executed by the image when the mongo service starts.
Assume you have the seed script below, named seed.js within a scripts folder, for example.
Dockerfile so that the JavaScript file is copied to /docker-entrypoint-initdb.d when building the image.
Dockerfile in the docker-compose.yml file used by Ergomake.
In this example, we assume the following file-tree structure:
Postgres Example
If you’re using thepostgres image, you can simply copy your seed scripts to /docker-entrypoint-initb.d. That’s because the image is configured to execute any files within that directory when the postgres service starts.
Assume you had the seed script below, named dump.sql, within a scripts folder.
seed.sh, within that same scripts folder.
Dockerfile to copy seed.sh the dump.sql to docker-entrypoint-initdb.d, as shown below.
Dockerfile in the docker-compose.yml you use for Ergomake.
In this example, we assume the following file-tree structure:

