From 7580501ab0190738575130011a0c7c9868b41ae5 Mon Sep 17 00:00:00 2001 From: Oliver Wilkes Date: Tue, 18 Oct 2022 14:04:53 +0100 Subject: [PATCH] build(docker): add mongo to docker compose (#33) --- .dockerignore | 5 +++++ .gitignore | 1 + docker-compose.yml | 15 +++++++++++++++ mongo_init.js | 10 ++++++++++ 4 files changed, 31 insertions(+) create mode 100644 .dockerignore create mode 100644 mongo_init.js diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..688aaf1 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,5 @@ +* +!poetry* +!pyproject.toml +!.env +!ezar diff --git a/.gitignore b/.gitignore index e4d5f8d..b44c918 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,4 @@ __pycache__ .venv .env .vscode +mongo_data/ diff --git a/docker-compose.yml b/docker-compose.yml index 65bddcb..7cab363 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -8,3 +8,18 @@ services: build: context: . dockerfile: Dockerfile + links: + - mongodb + environment: + MONGO_URI: mongodb://ezar:WhatAShame@mongodb:27017/eZaR + mongodb: + image: mongo:6.0 + environment: + MONGO_INITDB_DATABASE_USERNAME: ezar + MONGO_INITDB_DATABASE_PASSWORD: WhatAShame + MONGO_INITDB_DATABASE: eZaR + expose: + - 27017 + volumes: + - ./mongo_data:/data/db + - ./mongo_init.js:/docker-entrypoint-initdb.d/init.js:ro diff --git a/mongo_init.js b/mongo_init.js new file mode 100644 index 0000000..4c157f5 --- /dev/null +++ b/mongo_init.js @@ -0,0 +1,10 @@ +db.createUser({ + user: "ezar", + pwd: "WhatAShame", + roles: [ + { + role: "readWrite", + db: "eZaR", + }, + ], +});