Created
August 13, 2019 13:58
-
-
Save natac13/ca1216f6f8b8056c12d1127b66f55997 to your computer and use it in GitHub Desktop.
A quick setup for Mongodb and importing data.
This file contains hidden or 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: username | |
| MONGO_INITDB_ROOT_PASSWORD: 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 | |
| networks: | |
| - mongo | |
| volumes: | |
| dbData: | |
| networks: | |
| mongo: |
This file contains hidden or 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 username -p password --authenticationDatabase admin -d <somedb> -c <somecollection> --drop /home/people.json | |
| echo 'DATA HAS BEEN IMPORTED INTO MONGODB... EXITING!'; | |
| # exec "$@" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment