From 1c9f11a1164bafb4b33af07624c40925271d0ea7 Mon Sep 17 00:00:00 2001 From: Cyrille Derche Date: Sun, 21 May 2023 18:23:07 +0200 Subject: [PATCH 1/2] configure docker for rabbitmq --- README.md | 6 ++++++ docker-compose.dev.yml | 8 ++++++++ docker-compose.test.yml | 9 +++++++++ src/config/env.ts | 9 +++++++++ 4 files changed, 32 insertions(+) diff --git a/README.md b/README.md index ea19d2d..517bce6 100644 --- a/README.md +++ b/README.md @@ -39,3 +39,9 @@ docker compose -f docker-compose.dev.yml up - MongoDB ([mongoose](https://mongoosejs.com/)) - Redis ([BullMQ](https://bullmq.io/) and [bull-board](https://github.com/felixmosh/bull-board)) +- RabbitMQ ([RabbitMQ](https://www.rabbitmq.com/) and [RabbitMQ Management](https://www.rabbitmq.com/managment)) + +#### Local Resources + +- [Bull Board](http://localhost:3000/admin/queues) +- [RabbitMQ Management](http://localhost:15672) \ No newline at end of file diff --git a/docker-compose.dev.yml b/docker-compose.dev.yml index 96bcb16..bbb2eac 100644 --- a/docker-compose.dev.yml +++ b/docker-compose.dev.yml @@ -12,3 +12,11 @@ services: environment: - MONGO_INITDB_ROOT_USERNAME=root - MONGO_INITDB_ROOT_PASSWORD=pass + rabbitmq: + image: "rabbitmq:3-management-alpine" + ports: + - 5672:5672 + - 15672:15672 + environment: + - RABBITMQ_DEFAULT_USER=root + - RABBITMQ_DEFAULT_PASS=pass \ No newline at end of file diff --git a/docker-compose.test.yml b/docker-compose.test.yml index 50c0297..f56259d 100644 --- a/docker-compose.test.yml +++ b/docker-compose.test.yml @@ -14,6 +14,10 @@ services: - MONGODB_PASS=pass - REDIS_QUEUE_HOST=redis - REDIS_QUEUE_PORT=6379 + - RABBITMQ_HOST=localhost + - RABBITMQ_PORT=5672 + - RABBITMQ_USER=root + - RABBITMQ_PASS=pass volumes: - ./coverage:/project/coverage depends_on: @@ -26,3 +30,8 @@ services: environment: - MONGO_INITDB_ROOT_USERNAME=root - MONGO_INITDB_ROOT_PASSWORD=pass + rabbitmq: + image: "rabbitmq:3-management-alpine" + environment: + - RABBITMQ_DEFAULT_USER=root + - RABBITMQ_DEFAULT_PASS=pass \ No newline at end of file diff --git a/src/config/env.ts b/src/config/env.ts index 59219cc..54fe6d1 100644 --- a/src/config/env.ts +++ b/src/config/env.ts @@ -11,6 +11,10 @@ const schema = Joi.object() MONGODB_NAME: Joi.string().optional().example("db"), REDIS_QUEUE_HOST: Joi.string().optional().example("localhost"), REDIS_QUEUE_PORT: Joi.number().optional().example(6379), + RABBITMQ_HOST: Joi.string().required().example("localhost"), + RABBITMQ_PORT: Joi.number().required().example(5672), + RABBITMQ_USER: Joi.string().required().example("root"), + RABBITMQ_PASS: Joi.string().required().example("pass") }) .unknown(); @@ -28,7 +32,12 @@ const MONGODB_URL = `mongodb://${value.MONGODB_USER}:${value.MONGODB_PASS}@${ value.MONGODB_NAME !== undefined ? value.MONGODB_NAME : "" }`; +const RABBITMQ_URL = `amqp://${value.RABBITMQ_USER}:${value.RABBITMQ_PASS}@${ + value.RABBITMQ_HOST +}:${value.RABBITMQ_PORT}`; + export const env = { ...value, MONGODB_URL, + RABBITMQ_URL }; From f379cd41198483b65e2929774d7f64178a24e685 Mon Sep 17 00:00:00 2001 From: Cyrille Derche Date: Sun, 21 May 2023 18:27:51 +0200 Subject: [PATCH 2/2] Prettier + README update --- README.md | 15 ++++++++++++++- docker-compose.dev.yml | 2 +- docker-compose.test.yml | 2 +- src/config/env.ts | 8 +++----- 4 files changed, 19 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 517bce6..07b6c51 100644 --- a/README.md +++ b/README.md @@ -44,4 +44,17 @@ docker compose -f docker-compose.dev.yml up #### Local Resources - [Bull Board](http://localhost:3000/admin/queues) -- [RabbitMQ Management](http://localhost:15672) \ No newline at end of file +- [RabbitMQ Management](http://localhost:15672) + +## Commands + +The following commands are also available. Note that while these are made available, the `docker compose` commands are the ones called throughout the CI/CD Pipeline. + +```bash +npm run prettier +npm run lint +npm run test +npm run dev +npm run build +npm run start +``` diff --git a/docker-compose.dev.yml b/docker-compose.dev.yml index bbb2eac..489dbb3 100644 --- a/docker-compose.dev.yml +++ b/docker-compose.dev.yml @@ -19,4 +19,4 @@ services: - 15672:15672 environment: - RABBITMQ_DEFAULT_USER=root - - RABBITMQ_DEFAULT_PASS=pass \ No newline at end of file + - RABBITMQ_DEFAULT_PASS=pass diff --git a/docker-compose.test.yml b/docker-compose.test.yml index f56259d..237e9c7 100644 --- a/docker-compose.test.yml +++ b/docker-compose.test.yml @@ -34,4 +34,4 @@ services: image: "rabbitmq:3-management-alpine" environment: - RABBITMQ_DEFAULT_USER=root - - RABBITMQ_DEFAULT_PASS=pass \ No newline at end of file + - RABBITMQ_DEFAULT_PASS=pass diff --git a/src/config/env.ts b/src/config/env.ts index 54fe6d1..26a1653 100644 --- a/src/config/env.ts +++ b/src/config/env.ts @@ -14,7 +14,7 @@ const schema = Joi.object() RABBITMQ_HOST: Joi.string().required().example("localhost"), RABBITMQ_PORT: Joi.number().required().example(5672), RABBITMQ_USER: Joi.string().required().example("root"), - RABBITMQ_PASS: Joi.string().required().example("pass") + RABBITMQ_PASS: Joi.string().required().example("pass"), }) .unknown(); @@ -32,12 +32,10 @@ const MONGODB_URL = `mongodb://${value.MONGODB_USER}:${value.MONGODB_PASS}@${ value.MONGODB_NAME !== undefined ? value.MONGODB_NAME : "" }`; -const RABBITMQ_URL = `amqp://${value.RABBITMQ_USER}:${value.RABBITMQ_PASS}@${ - value.RABBITMQ_HOST -}:${value.RABBITMQ_PORT}`; +const RABBITMQ_URL = `amqp://${value.RABBITMQ_USER}:${value.RABBITMQ_PASS}@${value.RABBITMQ_HOST}:${value.RABBITMQ_PORT}`; export const env = { ...value, MONGODB_URL, - RABBITMQ_URL + RABBITMQ_URL, };