From af794568dfe4e1c03588246ba598a4d05d947029 Mon Sep 17 00:00:00 2001 From: Jay Rainey Date: Tue, 16 Mar 2021 11:41:10 +0000 Subject: [PATCH 1/2] Added mongo service --- instances/middleware/README.md | 35 +++++++++++++++++++++++++ instances/middleware/docker-compose.yml | 15 +++++++++++ 2 files changed, 50 insertions(+) create mode 100644 instances/middleware/README.md diff --git a/instances/middleware/README.md b/instances/middleware/README.md new file mode 100644 index 0000000..b59ac82 --- /dev/null +++ b/instances/middleware/README.md @@ -0,0 +1,35 @@ +## MongoDB Authentication + +Authentication is disabled in mongodb by default, and will need to be setup to access the db remotely. To do that: + +1. Remove `command: [--auth]` from the `docker-compose.yml`. +2. Run `docker compose up -d` to see the changes. +3. Enter the docker container: `docker exec -it mongo bash` +4. Run `mongo` from the command line and create two users as follows: + +```bash +use admin +db.createUser( + { + user: "ADMIN_USER", + pwd: "ROOT_PASSWORD", + roles:["root"] + } +); + +use dtransfer +db.createUser( + { + user: "DT_USER", + pwd: "DT_PASSWORD", + roles:[ + { + role: "readWrite", + db: "dtransfer" + } + ] + } +); +``` + +**Note**: change `user` and `pwd` with desired secrets. \ No newline at end of file diff --git a/instances/middleware/docker-compose.yml b/instances/middleware/docker-compose.yml index bb1f71a..a940122 100644 --- a/instances/middleware/docker-compose.yml +++ b/instances/middleware/docker-compose.yml @@ -3,6 +3,8 @@ version: '3.8' networks: web: external: true + database: + external: true services: consumer_live: @@ -30,3 +32,16 @@ services: - "traefik.http.routers.consumer_dev.rule=Host(`dev.api.wp3.ideafast.eu`)" - "traefik.http.routers.consumer_dev.entrypoints=websecure" - "traefik.http.routers.consumer_dev.tls.certresolver=leresolver" + + mongodb: + container_name: mongo + image: mongo:4.4.3 + command: [--auth] + networks: + - database + ports: + - 27017:27017 + volumes: + - mongodb:/data/db + labels: + - "traefik.enable=true" \ No newline at end of file From d25daa30f4fa814b53e4ea0b04d2877e080d4776 Mon Sep 17 00:00:00 2001 From: Jay Rainey Date: Tue, 16 Mar 2021 12:53:42 +0000 Subject: [PATCH 2/2] Forgot to add volume definition --- instances/middleware/docker-compose.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/instances/middleware/docker-compose.yml b/instances/middleware/docker-compose.yml index a940122..20672ae 100644 --- a/instances/middleware/docker-compose.yml +++ b/instances/middleware/docker-compose.yml @@ -44,4 +44,7 @@ services: volumes: - mongodb:/data/db labels: - - "traefik.enable=true" \ No newline at end of file + - "traefik.enable=true" + +volumes: + mongodb: \ No newline at end of file