working on a sane database setup

This commit is contained in:
voje 2019-03-15 00:03:10 +01:00
parent c5ab988d50
commit 49e45900c4
3 changed files with 18 additions and 6 deletions

View File

@ -6,13 +6,18 @@
.PHONY: start_db .PHONY: start_db
STACKNAME = dbstack
all: run_stack create_users all: run_stack create_users
run_stack: run_stack:
docker stack deploy --compose-file mongo-stack.yml dbstack docker stack deploy --compose-file mongodb-stack.yml $(STACKNAME)
create_users: create.js:
docker exec -it mongo-container /bin/bash echo -e 'db.auth("$(DB_ADM_USER)", "$(DB_ADM_PASS)")\n \
mongo -u root -p example use valdb\n \
use valDB db.createUser({user: "kristjan", pwd: "password", roles: ["readWrite"]})' > create.js
db.createUser({user: "kristjan", pwd: "password", roles: ["readWrite"]})
create_users: create.js
docker exec $(shell ./get_container_name.sh) mongo admin < create.js
# rm create.js

View File

@ -0,0 +1,5 @@
db.auth("testuser", "testpass")
\
use valdb
\
db.createUser({user: "kristjan", pwd: "password", roles: ["readWrite"]})

View File

@ -0,0 +1,2 @@
#!/bin/bash
docker ps | grep mongo:latest | awk '{print $1}'