cjvt-valency/dockerfiles/database/Makefile

35 lines
844 B
Makefile
Raw Normal View History

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')"
2019-03-14 23:03:10 +00:00
STACKNAME = dbstack
.PHONY: start_db FORCE
2019-03-17 16:25:59 +00:00
all: build_run create_users
2019-03-17 16:25:59 +00:00
build_run: build_mongo run_stack
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)
2019-03-14 18:49:01 +00:00
run_stack:
2019-04-11 05:18:51 +00:00
mkdir -p ${HOME}/mongo_container/data/
2019-03-14 23:03:10 +00:00
docker stack deploy --compose-file mongodb-stack.yml $(STACKNAME)
create_users: create.js
docker exec $(shell ./get_container_name.sh) /init_inside_container.sh
2019-03-14 23:03:10 +00:00
# rm create.js