-
Notifications
You must be signed in to change notification settings - Fork 14
Seed Data
Cyril Rohr edited this page May 7, 2020
·
3 revisions
To be useful, staging environments almost always require seed data to be injected into the staging database. To do this you have the following solutions:
If you can test all your features from a limited set of predefined objects, you can take advantage of the seeding capabilities offered by your application framework (e.g. Rails seed data). In that case, you can simply add the seeding process as a one-off service in your Docker Compose configuration.
Example:
# docker-compose.yml
version: '3'
networks:
- backend
- frontend
services:
db:
image: postgres
networks:
- backend
web:
build: .
command: bundle exec rails s
...
networks:
- backend
- frontend
depends_on:
- db
- seeder
seeder:
command: bundle exec rails db:seed
restart: on-failure
networks:
- backend
depends_on:
- db
Notice the restart: on-failure
restart policy for the seeder
service, ensuring it is only run once.