Skip to content

Commit

Permalink
configure docker for rabbitmq
Browse files Browse the repository at this point in the history
  • Loading branch information
cyri113 committed May 21, 2023
1 parent 02b3e64 commit 1c9f11a
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 0 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
8 changes: 8 additions & 0 deletions docker-compose.dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
9 changes: 9 additions & 0 deletions docker-compose.test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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
9 changes: 9 additions & 0 deletions src/config/env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand All @@ -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
};

0 comments on commit 1c9f11a

Please sign in to comment.