forked from kristjan/cjvt-valency
35 lines
882 B
Makefile
35 lines
882 B
Makefile
# db names: nameDB
|
|
# collection names: lower case, plural
|
|
# user names?
|
|
|
|
# mongo admin -u root -p password --eval "db.getSiblingDB('vlDB').addUser('vluser', 'password')"
|
|
|
|
STACKNAME = dbstack
|
|
|
|
.PHONY: start_db FORCE
|
|
|
|
all: build_mongo run_stack create_users
|
|
|
|
info:
|
|
echo "[*] RUN THIS A FEW TIMES (THE STACK NEEDS TIME TO CLEAN UP AND TO SPIN UP THE NODES)"
|
|
|
|
create.js: FORCE
|
|
|
|
FORCE:
|
|
echo 'db.auth("$(DB_ADM_USER)", "$(DB_ADM_PASS)")' > create.js
|
|
echo 'use valdb' >> create.js
|
|
echo 'db.createUser({user: "$(DB_USR_USER)", pwd: "$(DB_USR_PASS)", roles: ["readWrite"]})' >> create.js
|
|
|
|
build_mongo: create.js
|
|
docker build . -t my-mongo --no-cache
|
|
|
|
clean_stack:
|
|
docker stack rm $(STACKNAME)
|
|
|
|
run_stack:
|
|
docker stack deploy --compose-file mongodb-stack.yml $(STACKNAME)
|
|
|
|
create_users: create.js
|
|
docker exec $(shell ./get_container_name.sh) /init_inside_container.sh
|
|
# rm create.js
|