Created
August 14, 2019 10:21
-
-
Save natac13/3d6377e4de55df3e70bc2b51b3636112 to your computer and use it in GitHub Desktop.
MongoDB University M201 Docker setup
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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