diff --git a/Makefile b/Makefile index 7734cb5..dafbdd0 100644 --- a/Makefile +++ b/Makefile @@ -14,6 +14,9 @@ KRES_SRL_FOLDER = "$(MAKE_ROOT)/data/kres_srl" OUTPUT = "file" OUTDIR = "/home/voje/workdir/test_out" DBADDR = "" + +DB_ADM_USER = testuser +DB_ADM_PASS = testpass export .PHONY: dev-env preflight @@ -23,7 +26,7 @@ all: # prereq (environment) dev-env: - cd dockerfiles; cd dev-env; $(MAKE) + cd dockerfiles/dev-env; $(MAKE) # run these inside dev-env container data/samples: @@ -35,3 +38,6 @@ preflight: data/samples pip3 install -e src/pkg/corpusparser/. python3 src/pkg/corpusparser/corpusparser/main.py --kres-folder $(KRES_FOLDER) \ --ssj-file $(SSJ_FILE) --kres-srl-folder $(KRES_SRL_FOLDER) --output $(OUTPUT) --outdir $(OUTDIR) --dbaddr $(DBADDR) + +database: + cd dockerfiles/database; $(MAKE) \ No newline at end of file diff --git a/dockerfiles/database/Makefile b/dockerfiles/database/Makefile new file mode 100644 index 0000000..97cc180 --- /dev/null +++ b/dockerfiles/database/Makefile @@ -0,0 +1,18 @@ +# 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 + +all: run_stack create_users + +run_stack: + docker stack deploy --compose-file mongo-stack.yml dbstack + +create_users: + docker exec -it mongo-container /bin/bash + mongo -u root -p example + use valDB + db.createUser({user: "kristjan", pwd: "password", roles: ["readWrite"]}) diff --git a/dockerfiles/database/mongodb-stack.yml b/dockerfiles/database/mongodb-stack.yml index cf63b58..4c218e6 100644 --- a/dockerfiles/database/mongodb-stack.yml +++ b/dockerfiles/database/mongodb-stack.yml @@ -1,4 +1,3 @@ -# Use root/example as user/password credentials version: '3.1' services: @@ -7,8 +6,8 @@ services: image: mongo restart: always environment: - MONGO_INITDB_ROOT_USERNAME: root - MONGO_INITDB_ROOT_PASSWORD: example + MONGO_INITDB_ROOT_USERNAME: ${DB_ADM_USER} + MONGO_INITDB_ROOT_PASSWORD: ${DB_ADM_PASS} mongo-express: image: mongo-express @@ -16,5 +15,5 @@ services: ports: - 8081:8081 environment: - ME_CONFIG_MONGODB_ADMINUSERNAME: root - ME_CONFIG_MONGODB_ADMINPASSWORD: example + ME_CONFIG_MONGODB_ADMINUSERNAME: ${DB_ADM_USER} + ME_CONFIG_MONGODB_ADMINPASSWORD: ${DB_ADM_PASS}