Skip to content

Commit

Permalink
Merge pull request #204 from DigiChanges/feat/rabbitmq
Browse files Browse the repository at this point in the history
feat: add rabbitmq message broker service
  • Loading branch information
Murzbul authored Feb 15, 2024
2 parents 47dfe2e + 00666c0 commit b4ee292
Show file tree
Hide file tree
Showing 38 changed files with 1,251 additions and 1,997 deletions.
6 changes: 6 additions & 0 deletions .env.dev
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,12 @@ CACHE_USER=experience
CACHE_PASSWORD=ewsua132435
CACHE_ENABLE=false

MESSAGE_BROKER_PROTOCOL=amqp
MESSAGE_BROKER_HOST=rabbitmq
MESSAGE_BROKER_PORT=5672
MESSAGE_BROKER_USER=user
MESSAGE_BROKER_PASSWORD=password

# MinIO config
MINIO_HOST=minio
MINIO_ACCESS_KEY=minio
Expand Down
6 changes: 6 additions & 0 deletions .env.test
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,12 @@ CACHE_USER=experience
CACHE_PASSWORD=ewsua132435
CACHE_ENABLE=false

MESSAGE_BROKER_PROTOCOL=amqp
MESSAGE_BROKER_HOST=rabbitmq
MESSAGE_BROKER_PORT=5672
MESSAGE_BROKER_USER=user
MESSAGE_BROKER_PASSWORD=password

# MinIO config
MINIO_HOST=minio
MINIO_ACCESS_KEY=minio
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ graph.svg
.bun
yalc.lock
.yalc
.env.old

# Diagnostic reports (https://nodejs.org/api/report.html)
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
Expand Down
10 changes: 8 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
FROM digichanges/nexp:1.2 AS dev
FROM node:20-alpine AS dev

RUN apk add dumb-init

RUN corepack enable && corepack install --global [email protected]

WORKDIR /home/node

Expand Down Expand Up @@ -32,7 +36,9 @@ RUN pnpm install --production --ignore-scripts \
&& cd node_modules/bcrypt \
&& npm rebuild bcrypt --build-from-source

FROM digichanges/nexp:1.2 AS prod
FROM node:20-alpine AS prod

RUN corepack enable && corepack install --global [email protected]

ENV NODE_ENV production

Expand Down
7 changes: 7 additions & 0 deletions config/custom-environment-variables.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,13 @@
},
"enable": "CACHE_ENABLE"
},
"messageBroker": {
"protocol": "MESSAGE_BROKER_PROTOCOL",
"hostname": "MESSAGE_BROKER_HOST",
"port": "MESSAGE_BROKER_PORT",
"username": "MESSAGE_BROKER_USER",
"password": "MESSAGE_BROKER_PASSWORD"
},
"filesystem": {
"minio": {
"endPoint": "MINIO_HOST",
Expand Down
7 changes: 7 additions & 0 deletions config/default.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,13 @@
},
"enable": true
},
"messageBroker": {
"protocol": "amqp",
"hostname": "rabbitmq",
"port": 5672,
"username": "user",
"password": "password"
},
"filesystem": {
"minio": {
"endPoint": "minio",
Expand Down
44 changes: 35 additions & 9 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,24 @@ services:
ports:
- "8089:8089"
- "9229:9229"
labels:
- traefik.http.routers.api.rule=Host(`api.domain.com`)
- traefik.http.routers.api.tls=true
- traefik.http.routers.api.tls.certresolver=lets-encrypt
- traefik.port=80
volumes:
- ./dist:/home/node/dist
- ./src:/home/node/src
- ./config:/home/node/config
- ./.env:/home/node/.env
networks:
- experiencenet

worker:
container_name: experience_worker_1
restart: always
tty: false
stdin_open: false
entrypoint: ["dumb-init", "pnpm", "worker-dev"]
build:
context: .
dockerfile: Dockerfile
target: dev
volumes:
- ./dist:/home/node/dist
- ./src:/home/node/src
Expand All @@ -34,15 +47,28 @@ services:
dockerfile: Dockerfile
ports:
- "27018:27017"
networks:
- experiencenet
environment:
MONGODB_ROOT_PASSWORD: 123456
MONGODB_USERNAME: experience
MONGODB_PASSWORD: experience
MONGODB_DATABASE: experience
volumes:
- data:/bitnami/mongodb
networks:
- experiencenet

rabbitmq:
image: rabbitmq:3.9-management-alpine
restart: always
container_name: experience_rabbitmq_1
ports:
- "15672:15672"
- "5672:5672"
environment:
RABBITMQ_DEFAULT_USER: user
RABBITMQ_DEFAULT_PASS: password
networks:
- experiencenet

mail:
container_name: experience_mail_1
Expand All @@ -59,12 +85,12 @@ services:
ulimits:
memlock: -1
container_name: experience_cache_1
ports:
- "6379:6379"
environment:
- DRAGONFLY_USER=experience
- DRAGONFLY_PASSWORD=ewsua132435
- DISABLE_COMMANDS=FLUSHDB,FLUSHALL,CONFIG
ports:
- "6379:6379"
networks:
- experiencenet
volumes:
Expand Down
1 change: 1 addition & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ module.exports = {
"!dist/src/crons.{js,ts}",
"!dist/src/command.{js,ts}",
"!dist/src/index.{js,ts}",
"!dist/src/worker.{js,ts}",
"!dist/src/closed.{js,ts}",
"!dist/src/initCommand.{js,ts}",
"!dist/src/**/I*.{js,ts}",
Expand Down
76 changes: 39 additions & 37 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,99 +19,101 @@
"lint": "eslint -c .eslintrc ./src",
"pre-commit": "lint-staged",
"pre-check": "pnpm ts-check && pnpm lint",
"prepare": "husky install",
"prepare": "husky",
"start": "node dist/src/index.js",
"test-ci": "jest --run-in-band --coverage",
"test": "jest --coverage",
"test-watch": "jest --watch --silent --coverage=false",
"tsc": "tsc",
"ts-check": "tsc -p tsconfig.json --noEmit",
"worker-dev": "node dist/src/worker.js",
"sync:db": "ts-node src/Main/Presentation/Commands/SynchronizeDbCommand.ts"
},
"keywords": [],
"author": "Nathan M. Russo",
"license": "MIT",
"dependencies": {
"@digichanges/shared-experience": "^1.4.1",
"@faker-js/faker": "^8.3.1",
"@fastify/compress": "^6.5.0",
"@fastify/cors": "^8.5.0",
"@faker-js/faker": "^8.4.0",
"@fastify/compress": "^7.0.0",
"@fastify/cors": "^9.0.1",
"@fastify/helmet": "^11.1.1",
"@godaddy/terminus": "^4.12.1",
"@mikro-orm/core": "^5.9.6",
"@mikro-orm/postgresql": "^5.9.6",
"@supabase/supabase-js": "^2.39.1",
"axios": "^1.6.2",
"@mikro-orm/core": "^6.0.7",
"@mikro-orm/postgresql": "^6.0.7",
"@supabase/supabase-js": "^2.39.3",
"amqplib": "^0.10.3",
"axios": "^1.6.7",
"bcrypt": "^5.1.1",
"commander": "^10.0.1",
"config": "^3.3.9",
"config": "^3.3.11",
"dayjs": "^1.11.10",
"dependency-cruiser": "^16.0.0",
"dotenv": "^16.3.1",
"dependency-cruiser": "^16.1.0",
"dotenv": "^16.4.1",
"envalid": "^8.0.0",
"fastify": "^4.25.2",
"fastify": "^4.26.0",
"handlebars": "^4.7.8",
"helmet": "^7.1.0",
"infisical": "^1.0.46",
"jwt-simple": "^0.5.6",
"md5": "^2.3.0",
"minio": "^7.1.3",
"mongodb": "^6.3.0",
"mongoose": "^7.6.7",
"multer": "^1.4.5-lts.1",
"mongoose": "^8.1.1",
"multer": "^2.0.0-rc.4",
"nanoid": "^3.3.7",
"node-cron": "^3.0.3",
"nodemailer": "6.9.9",
"pg-mem": "^2.7.4",
"pg-mem": "^2.8.1",
"pg-promise": "^11.5.4",
"pino": "^8.17.1",
"pino-pretty": "^10.3.0",
"pino": "^8.18.0",
"pino-pretty": "^10.3.1",
"qs": "^6.11.2",
"reflect-metadata": "^0.2.1",
"rxjs": "^7.8.1",
"shelljs": "^0.8.5",
"tedis": "^0.1.12",
"tslib": "^2.6.2",
"tsyringe": "^4.8.0",
"web-push": "^3.6.6",
"web-push": "^3.6.7",
"zod": "^3.22.4"
},
"devDependencies": {
"@commitlint/cli": "^18.4.3",
"@commitlint/config-conventional": "^18.4.3",
"@commitlint/cli": "^18.6.0",
"@commitlint/config-conventional": "^18.6.0",
"@shelf/jest-mongodb": "^4.2.0",
"@types/amqplib": "^0.10.4",
"@types/bcrypt": "^5.0.2",
"@types/config": "^0.0.41",
"@types/jest": "^29.5.6",
"@types/jest": "^29.5.12",
"@types/jwt-simple": "^0.5.36",
"@types/md5": "^2.3.5",
"@types/node": "^18.19.3",
"@types/node-cron": "^3.0.10",
"@types/nodemailer": "^6.4.13",
"@types/pg": "^8.10.7",
"@types/qs": "^6.9.9",
"@types/shelljs": "^0.8.14",
"@types/node": "^20.11.16",
"@types/node-cron": "^3.0.11",
"@types/nodemailer": "^6.4.14",
"@types/pg": "^8.11.0",
"@types/qs": "^6.9.11",
"@types/shelljs": "^0.8.15",
"@types/supertest": "^2.0.16",
"@types/web-push": "^3.6.2",
"@typescript-eslint/eslint-plugin": "^6.16.0",
"@typescript-eslint/parser": "^6.16.0",
"@types/web-push": "^3.6.3",
"@typescript-eslint/eslint-plugin": "^6.20.0",
"@typescript-eslint/parser": "^6.20.0",
"cpy": "^9.0.1",
"eslint": "^8.56.0",
"eslint-plugin-import": "^2.29.1",
"eslint-plugin-prefer-arrow": "^1.2.3",
"husky": "^8.0.3",
"husky": "^9.0.10",
"jest": "^29.7.0",
"jest-environment-jsdom": "^29.7.0",
"jest-environment-node": "^29.7.0",
"lint-staged": "^15.0.2",
"lint-staged": "^15.2.1",
"madge": "^6.1.0",
"nodemon": "^3.0.2",
"nodemon": "^3.0.3",
"rimraf": "^3.0.2",
"supertest": "^6.3.3",
"supertest": "^6.3.4",
"ts-node": "^10.9.2",
"typescript": "^5.2.2"
"typescript": "^5.3.3"
},
"engines": {
"node": ">=18.*"
"node": ">=20.*"
}
}
Loading

0 comments on commit b4ee292

Please sign in to comment.