From 41b8a235bfb47af04c37472526e9f1c3b050683e Mon Sep 17 00:00:00 2001 From: pablomendezroyo Date: Mon, 8 Apr 2024 16:42:08 +0200 Subject: [PATCH] Implement mongo express --- .env.example | 6 ++++++ docker-compose.yml | 30 ++++++++++++++++++++++------- mongo/Dockerfile | 5 +++++ {mongo-config => mongo}/mongod.conf | 0 ui/Dockerfile | 3 +++ 5 files changed, 37 insertions(+), 7 deletions(-) create mode 100644 .env.example create mode 100644 mongo/Dockerfile rename {mongo-config => mongo}/mongod.conf (100%) create mode 100644 ui/Dockerfile diff --git a/.env.example b/.env.example new file mode 100644 index 0000000..b15c9bb --- /dev/null +++ b/.env.example @@ -0,0 +1,6 @@ +MONGO_INITDB_ROOT_USERNAME= +MONGO_INITDB_ROOT_PASSWORD= +MONGO_DB_NAME= +MONGO_DB_API_PORT= +API_PORT= +LOG_LEVEL= diff --git a/docker-compose.yml b/docker-compose.yml index 6140eeb..0747a74 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -7,25 +7,41 @@ services: ports: - "8080:8080" environment: - MONGO_DB_URI: "mongodb://${MONGO_INITDB_ROOT_USERNAME}:${MONGO_INITDB_ROOT_PASSWORD}@mongo:27017" + MONGO_DB_URI: "mongodb://${MONGO_INITDB_ROOT_USERNAME}:${MONGO_INITDB_ROOT_PASSWORD}@mongo:${MONGO_DB_API_PORT}" MONGO_DB_NAME: "${MONGO_DB_NAME}" API_PORT: "${API_PORT}" LOG_LEVEL: "${LOG_LEVEL}" depends_on: - - mongo + - mongo + container_name: listener + + ui: + build: + context: ui + environment: + ME_CONFIG_MONGODB_URL: "mongodb://${MONGO_INITDB_ROOT_USERNAME}:${MONGO_INITDB_ROOT_PASSWORD}@mongo:${MONGO_DB_API_PORT}" + ME_CONFIG_MONGODB_SERVER: "mongo" + ME_CONFIG_MONGODB_ENABLE_ADMIN: "true" + ME_CONFIG_MONGODB_ADMINUSERNAME: "${MONGO_INITDB_ROOT_USERNAME}" + ME_CONFIG_MONGODB_ADMINPASSWORD: "${MONGO_INITDB_ROOT_PASSWORD}" + ME_CONFIG_BASICAUTH_USERNAME: "${MONGO_INITDB_ROOT_USERNAME}" + ME_CONFIG_BASICAUTH_PASSWORD: "${MONGO_INITDB_ROOT_PASSWORD}" + PORT: 8081 + depends_on: + - mongo + container_name: ui mongo: - image: "mongo:7.0.6" - ports: - - "27017:27017" + build: + context: mongo volumes: - mongo-data:/data/db - - ./mongo-config:/etc/mongo environment: MONGO_INITDB_ROOT_USERNAME: ${MONGO_INITDB_ROOT_USERNAME} MONGO_INITDB_ROOT_PASSWORD: ${MONGO_INITDB_ROOT_PASSWORD} MONGO_INITDB_DATABASE: "${MONGO_DB_NAME}" command: ["mongod", "--config", "/etc/mongo/mongod.conf"] + container_name: mongo volumes: - mongo-data: \ No newline at end of file + mongo-data: diff --git a/mongo/Dockerfile b/mongo/Dockerfile new file mode 100644 index 0000000..7efe470 --- /dev/null +++ b/mongo/Dockerfile @@ -0,0 +1,5 @@ +FROM mongo:7.0.6 + +COPY ./mongod.conf /etc/mongo/mongod.conf + +EXPOSE 27017 \ No newline at end of file diff --git a/mongo-config/mongod.conf b/mongo/mongod.conf similarity index 100% rename from mongo-config/mongod.conf rename to mongo/mongod.conf diff --git a/ui/Dockerfile b/ui/Dockerfile new file mode 100644 index 0000000..f8f5a14 --- /dev/null +++ b/ui/Dockerfile @@ -0,0 +1,3 @@ +FROM mongo-express:1.0.2 + +EXPOSE 8081 \ No newline at end of file