Skip to content

Commit

Permalink
add mongodb seeding on startup for dev
Browse files Browse the repository at this point in the history
  • Loading branch information
aidengaripoli committed Nov 23, 2018
1 parent 9de17ec commit eb1996d
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
12 changes: 12 additions & 0 deletions database/seed.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
db.documents.insertMany([
// MongoDB adds the _id field with an ObjectId if _id is not present
{
name: 'Sample Document', tags: ['docker', 'containers', 'javascript']
},
{
name: 'Another sample document', tags: ['development', 'compose']
},
{
name: 'Third sample document', tags: ['swarm', 'production', 'node.js']
}
]);
2 changes: 2 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ services:
- MONGO_INITDB_ROOT_USERNAME=root
- MONGO_INITDB_ROOT_PASSWORD=example
- MONGO_INITDB_DATABASE=example-database
volumes:
- ./database/seed.js:/docker-entrypoint-initdb.d/seed.js
healthcheck:
test: echo 'db.stats().ok' | mongo localhost:27017/example-database --quiet
interval: 5s
Expand Down

0 comments on commit eb1996d

Please sign in to comment.