Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
MongoDB University M201 Docker setup
version: '2.4'
services:
db:
image: mongo:4.0.10-xenial
restart: 'always'
command: --wiredTigerCacheSizeGB 1 --auth --directoryperdb
volumes:
- dbData:/data/db
environment:
NODE_ENV: development
MONGO_INITDB_ROOT_USERNAME: m201-username
MONGO_INITDB_ROOT_PASSWORD: m201-password
ports:
- '27017:27017'
networks:
- mongo
dbSetup:
image: mongo:4.0.10-xenial
restart: 'no'
entrypoint: bash /home/setupData.sh
depends_on:
- db
volumes:
- ./setupData.sh:/home/setupData.sh
- ./people.json:/home/people.json
- ./sensor_data.json:/home/sensor_data.json
networks:
- mongo
volumes:
dbData:
networks:
mongo:
#!/usr/bin/bash
# import the datasets
# mongoimport --host 'db:27017' -u m201-username -p m201-password --authenticationDatabase admin -d m201 -c restaurants --drop /home/restaurants.json
mongoimport --host 'db:27017' -u m201-username -p m201-password --authenticationDatabase admin -d m201 -c people --drop /home/people.json
mongoimport --host 'db:27017' -u m201-username -p m201-password --authenticationDatabase admin -d m201 -c sensor_data --drop /home/sensor_data.json
echo 'DATA HAS BEEN IMPORTED INTO MONGODB... EXITING!';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment