forked from kristjan/cjvt-valency
working on a sane database setup
This commit is contained in:
parent
c5ab988d50
commit
49e45900c4
|
@ -6,13 +6,18 @@
|
|||
|
||||
.PHONY: start_db
|
||||
|
||||
STACKNAME = dbstack
|
||||
|
||||
all: run_stack create_users
|
||||
|
||||
run_stack:
|
||||
docker stack deploy --compose-file mongo-stack.yml dbstack
|
||||
docker stack deploy --compose-file mongodb-stack.yml $(STACKNAME)
|
||||
|
||||
create_users:
|
||||
docker exec -it mongo-container /bin/bash
|
||||
mongo -u root -p example
|
||||
use valDB
|
||||
db.createUser({user: "kristjan", pwd: "password", roles: ["readWrite"]})
|
||||
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
|
||||
|
||||
create_users: create.js
|
||||
docker exec $(shell ./get_container_name.sh) mongo admin < create.js
|
||||
# rm create.js
|
||||
|
|
5
dockerfiles/database/create.js
Normal file
5
dockerfiles/database/create.js
Normal file
|
@ -0,0 +1,5 @@
|
|||
db.auth("testuser", "testpass")
|
||||
\
|
||||
use valdb
|
||||
\
|
||||
db.createUser({user: "kristjan", pwd: "password", roles: ["readWrite"]})
|
2
dockerfiles/database/get_container_name.sh
Executable file
2
dockerfiles/database/get_container_name.sh
Executable file
|
@ -0,0 +1,2 @@
|
|||
#!/bin/bash
|
||||
docker ps | grep mongo:latest | awk '{print $1}'
|
Loading…
Reference in New Issue
Block a user