2019-03-14 18:49:01 +00:00
|
|
|
# db names: nameDB
|
|
|
|
# collection names: lower case, plural
|
|
|
|
# user names?
|
|
|
|
|
|
|
|
# mongo admin -u root -p password --eval "db.getSiblingDB('vlDB').addUser('vluser', 'password')"
|
|
|
|
|
|
|
|
.PHONY: start_db
|
|
|
|
|
2019-03-14 23:03:10 +00:00
|
|
|
STACKNAME = dbstack
|
|
|
|
|
2019-03-14 18:49:01 +00:00
|
|
|
all: run_stack create_users
|
|
|
|
|
|
|
|
run_stack:
|
2019-03-14 23:03:10 +00:00
|
|
|
docker stack deploy --compose-file mongodb-stack.yml $(STACKNAME)
|
|
|
|
|
|
|
|
create.js:
|
|
|
|
echo -e 'db.auth("$(DB_ADM_USER)", "$(DB_ADM_PASS)")\n \
|
|
|
|
use valdb\n \
|
|
|
|
db.createUser({user: "kristjan", pwd: "password", roles: ["readWrite"]})' > create.js
|
2019-03-14 18:49:01 +00:00
|
|
|
|
2019-03-14 23:03:10 +00:00
|
|
|
create_users: create.js
|
|
|
|
docker exec $(shell ./get_container_name.sh) mongo admin < create.js
|
|
|
|
# rm create.js
|