diff --git a/.suite-cli/cli/cli.js b/.suite-cli/cli/cli.js index 54170f1..8df823d 100755 --- a/.suite-cli/cli/cli.js +++ b/.suite-cli/cli/cli.js @@ -123,7 +123,12 @@ program } ]) .then(answers => { - const existing_services = getExistingComponent({ key: 'services', currentDir: cwd() }) + let existing_services = [] + try { + existing_services = getExistingComponent({ key: 'services', currentDir: cwd() }) + } catch (error) { + + } switch (answers.resource) { case 'monorepo': // Additional prompts specific to 'monorepo' resource @@ -231,7 +236,7 @@ program ]).then((answers) => actionHandlers.scaffoldNewLibrary({ answers: { ...answers, private: false } })) break case 'app': - const existing_apps = getExistingComponent({ key: 'apps', currentDir: cwd() }) + const existing_apps = getExistingComponent({ key: 'apps', currentDir: cwd() })||[] const formatServiceName = (service) => `${service.name}: ${service.port}`; prompt([ { @@ -294,14 +299,20 @@ program }) break; case 'gateway': - const all_apps = getExistingApps({ currentDir: cwd() }); + const apps = getExistingApps({ currentDir: cwd() }); + if(!apps) { + logInfo({ message: `No apps found in this project. You need to have atleast one app to generate a gateway` }) + ora().info(`Run 'suite generate' to create one...`) + process.exit(0); + + } const formatAppsName = (app) => app.name; prompt([ { type: 'checkbox', name: 'apps', message: 'Select apps', - choices: all_apps.map(app => ({ + choices: apps.map(app => ({ name: formatAppsName(app), value: app, checked: true, // Default all services to be selected @@ -344,7 +355,17 @@ program } }); }); - - + program + .command('remove') + .description('Clean remove a monorepo resource plus all the associated files. No residual files remain behind') + .option('service', 'remove service and associated files') + .option('app', 'remove app and associated files') + .option('library', 'remove library and associated files') + .option('microservice', 'remove microservice and associated files') + .option('gateway', 'remove gateway and associated files') + .action(async (options) => { + console.log({options}) + await actionHandlers.dockerPrune({ options }) + }); program.parse(process.argv); module.exports = program \ No newline at end of file diff --git a/.suite-cli/cli/package.json b/.suite-cli/cli/package.json index 01502c5..e8e4a3e 100644 --- a/.suite-cli/cli/package.json +++ b/.suite-cli/cli/package.json @@ -1,6 +1,6 @@ { "name": "@microservices-suite/cli", - "version": "3.0.0", + "version": "3.0.1", "description": "This is the CLI tool for running the microservices-suite monorepo. It contains functionalities and tools required for automation and managing the repo across supported platforms. Works on Windows,MacOS and Linux as well as support to some extend other variants like SunOS, IBM AIX, FreeBSD, OpenBSD and more", "main": "cli.js", "repository": "https://github.com/microservices-suite/node-microservices-suite.git", diff --git a/.suite-cli/cli/scripts/commands/scaffoldNewService.cmd.js b/.suite-cli/cli/scripts/commands/scaffoldNewService.cmd.js index 914e1ac..96d3122 100644 --- a/.suite-cli/cli/scripts/commands/scaffoldNewService.cmd.js +++ b/.suite-cli/cli/scripts/commands/scaffoldNewService.cmd.js @@ -3,8 +3,6 @@ const { scaffoldNewService, logError } = require('../scripts.module') module.exports = async ({ answers }) => { try { - console.log({answers}) - await scaffoldNewService({ answers }); } catch (error) { logError({ error }) diff --git a/.suite-cli/cli/scripts/scripts.module.js b/.suite-cli/cli/scripts/scripts.module.js index 2ec30e6..2aa6ec3 100644 --- a/.suite-cli/cli/scripts/scripts.module.js +++ b/.suite-cli/cli/scripts/scripts.module.js @@ -1643,7 +1643,7 @@ const scaffoldGateways = async ({ answers }) => { const { projectName } = readFileContent({ currentDir: cwd() }); let { apps } = answers; const project_root = generatRootPath({ currentDir: cwd() }); - const service_objects = getExistingComponent({ key, currentDir: cwd() }); + const service_objects = getExistingComponent({ key:'services', currentDir: cwd() }); // add port to services in each app eg ['auth']=>[{name:'auth',port:9001}] apps = apps.map((app) => { app.services.map((name, i) => { diff --git a/gateways/apps/app/docker-compose.dev.yml b/gateways/apps/app/docker-compose.dev.yml new file mode 100644 index 0000000..8f4f751 --- /dev/null +++ b/gateways/apps/app/docker-compose.dev.yml @@ -0,0 +1,367 @@ + +version: '3.8' +services: + + hd: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/hd + ports: + - "null:null" + volumes: + - /app/node_modules + - ../../../microservices/hd:/app + depends_on: + rabbitmq: + condition: service_healthy + + customer-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/customer-service + ports: + - "9000:9000" + volumes: + - /app/node_modules + - ../../../microservices/customer-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + product-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/product-service + ports: + - "9002:9002" + volumes: + - /app/node_modules + - ../../../microservices/product-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + rbac-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/rbac-service + ports: + - "9004:9004" + volumes: + - /app/node_modules + - ../../../microservices/rbac-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + payment-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/payment-service + ports: + - "9006:9006" + volumes: + - /app/node_modules + - ../../../microservices/payment-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + notification-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/notification-service + ports: + - "9007:9007" + volumes: + - /app/node_modules + - ../../../microservices/notification-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + email-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/email-service + ports: + - "9008:9008" + volumes: + - /app/node_modules + - ../../../microservices/email-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + cart-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/cart-service + ports: + - "9009:9009" + volumes: + - /app/node_modules + - ../../../microservices/cart-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + cart: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/cart + ports: + - "9010:9010" + volumes: + - /app/node_modules + - ../../../microservices/cart:/app + depends_on: + rabbitmq: + condition: service_healthy + + user: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/user + ports: + - "9011:9011" + volumes: + - /app/node_modules + - ../../../microservices/user:/app + depends_on: + rabbitmq: + condition: service_healthy + + customer: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/customer + ports: + - "9012:9012" + volumes: + - /app/node_modules + - ../../../microservices/customer:/app + depends_on: + rabbitmq: + condition: service_healthy + + email: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/email + ports: + - "9013:9013" + volumes: + - /app/node_modules + - ../../../microservices/email:/app + depends_on: + rabbitmq: + condition: service_healthy + + notification: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/notification + ports: + - "9014:9014" + volumes: + - /app/node_modules + - ../../../microservices/notification:/app + depends_on: + rabbitmq: + condition: service_healthy + + payment: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/payment + ports: + - "9015:9015" + volumes: + - /app/node_modules + - ../../../microservices/payment:/app + depends_on: + rabbitmq: + condition: service_healthy + + product: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/product + ports: + - "9016:9016" + volumes: + - /app/node_modules + - ../../../microservices/product:/app + depends_on: + rabbitmq: + condition: service_healthy + + rbac: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/rbac + ports: + - "9017:9017" + volumes: + - /app/node_modules + - ../../../microservices/rbac:/app + depends_on: + rabbitmq: + condition: service_healthy + + supplier: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/supplier + ports: + - "9018:9018" + volumes: + - /app/node_modules + - ../../../microservices/supplier:/app + depends_on: + rabbitmq: + condition: service_healthy + + upload: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/upload + ports: + - "9019:9019" + volumes: + - /app/node_modules + - ../../../microservices/upload:/app + depends_on: + rabbitmq: + condition: service_healthy + + th: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/th + ports: + - "9020:9020" + volumes: + - /app/node_modules + - ../../../microservices/th:/app + depends_on: + rabbitmq: + condition: service_healthy + + kjhgf: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/kjhgf + ports: + - "9021:9021" + volumes: + - /app/node_modules + - ../../../microservices/kjhgf:/app + depends_on: + rabbitmq: + condition: service_healthy + + hhgfdsdfghj: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/hhgfdsdfghj + ports: + - "9022:9022" + volumes: + - /app/node_modules + - ../../../microservices/hhgfdsdfghj:/app + depends_on: + rabbitmq: + condition: service_healthy + + ghjk: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/ghjk + ports: + - "9023:9023" + volumes: + - /app/node_modules + - ../../../microservices/ghjk:/app + depends_on: + rabbitmq: + condition: service_healthy + + shjksgd: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/shjksgd + ports: + - "30067:30067" + volumes: + - /app/node_modules + - ../../../microservices/shjksgd:/app + depends_on: + rabbitmq: + condition: service_healthy + + nginx: + depends_on: + - hd + - customer-service + - product-service + - rbac-service + - payment-service + - notification-service + - email-service + - cart-service + - cart + - user + - customer + - email + - notification + - payment + - product + - rbac + - supplier + - upload + - th + - kjhgf + - hhgfdsdfghj + - ghjk + - shjksgd + restart: always + build: + context: ./nginx + dockerfile: Dockerfile.dev + ports: + - '4000:80' + healthcheck: + test: ["CMD-SHELL", "curl -f http://localhost:80/health || exit 1"] + interval: 30s + timeout: 10s + retries: 3 + start_period: 40s + rabbitmq: + image: rabbitmq:3.13-management + container_name: rabbitmq + ports: + - '5672:5672' + - '15672:15672' + healthcheck: + test: ["CMD", "rabbitmq-diagnostics", "ping"] + interval: 30s + retries: 5 + mongodb: + image: mongo + ports: + - '27017:27017' + restart: always + volumes: + - type: bind + source: ./data + target: /data/db + krakend: + image: devopsfaith/krakend:2.7-watch + ports: + - '8080:8080' + - '8090:8090' + volumes: + - ./krakend/:/etc/krakend/ + command: ['run','-d','-c','/etc/krakend/krakend.json'] \ No newline at end of file diff --git a/gateways/apps/app/docker-compose.yml b/gateways/apps/app/docker-compose.yml new file mode 100644 index 0000000..97e3b67 --- /dev/null +++ b/gateways/apps/app/docker-compose.yml @@ -0,0 +1,367 @@ + +version: '3.8' +services: + + hd: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/hd + ports: + - "null:null" + volumes: + - /app/node_modules + - ../../../microservices/hd:/app + depends_on: + rabbitmq: + condition: service_healthy + + customer-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/customer-service + ports: + - "9000:9000" + volumes: + - /app/node_modules + - ../../../microservices/customer-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + product-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/product-service + ports: + - "9002:9002" + volumes: + - /app/node_modules + - ../../../microservices/product-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + rbac-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/rbac-service + ports: + - "9004:9004" + volumes: + - /app/node_modules + - ../../../microservices/rbac-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + payment-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/payment-service + ports: + - "9006:9006" + volumes: + - /app/node_modules + - ../../../microservices/payment-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + notification-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/notification-service + ports: + - "9007:9007" + volumes: + - /app/node_modules + - ../../../microservices/notification-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + email-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/email-service + ports: + - "9008:9008" + volumes: + - /app/node_modules + - ../../../microservices/email-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + cart-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/cart-service + ports: + - "9009:9009" + volumes: + - /app/node_modules + - ../../../microservices/cart-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + cart: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/cart + ports: + - "9010:9010" + volumes: + - /app/node_modules + - ../../../microservices/cart:/app + depends_on: + rabbitmq: + condition: service_healthy + + user: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/user + ports: + - "9011:9011" + volumes: + - /app/node_modules + - ../../../microservices/user:/app + depends_on: + rabbitmq: + condition: service_healthy + + customer: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/customer + ports: + - "9012:9012" + volumes: + - /app/node_modules + - ../../../microservices/customer:/app + depends_on: + rabbitmq: + condition: service_healthy + + email: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/email + ports: + - "9013:9013" + volumes: + - /app/node_modules + - ../../../microservices/email:/app + depends_on: + rabbitmq: + condition: service_healthy + + notification: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/notification + ports: + - "9014:9014" + volumes: + - /app/node_modules + - ../../../microservices/notification:/app + depends_on: + rabbitmq: + condition: service_healthy + + payment: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/payment + ports: + - "9015:9015" + volumes: + - /app/node_modules + - ../../../microservices/payment:/app + depends_on: + rabbitmq: + condition: service_healthy + + product: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/product + ports: + - "9016:9016" + volumes: + - /app/node_modules + - ../../../microservices/product:/app + depends_on: + rabbitmq: + condition: service_healthy + + rbac: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/rbac + ports: + - "9017:9017" + volumes: + - /app/node_modules + - ../../../microservices/rbac:/app + depends_on: + rabbitmq: + condition: service_healthy + + supplier: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/supplier + ports: + - "9018:9018" + volumes: + - /app/node_modules + - ../../../microservices/supplier:/app + depends_on: + rabbitmq: + condition: service_healthy + + upload: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/upload + ports: + - "9019:9019" + volumes: + - /app/node_modules + - ../../../microservices/upload:/app + depends_on: + rabbitmq: + condition: service_healthy + + th: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/th + ports: + - "9020:9020" + volumes: + - /app/node_modules + - ../../../microservices/th:/app + depends_on: + rabbitmq: + condition: service_healthy + + kjhgf: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/kjhgf + ports: + - "9021:9021" + volumes: + - /app/node_modules + - ../../../microservices/kjhgf:/app + depends_on: + rabbitmq: + condition: service_healthy + + hhgfdsdfghj: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/hhgfdsdfghj + ports: + - "9022:9022" + volumes: + - /app/node_modules + - ../../../microservices/hhgfdsdfghj:/app + depends_on: + rabbitmq: + condition: service_healthy + + ghjk: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/ghjk + ports: + - "9023:9023" + volumes: + - /app/node_modules + - ../../../microservices/ghjk:/app + depends_on: + rabbitmq: + condition: service_healthy + + shjksgd: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/shjksgd + ports: + - "30067:30067" + volumes: + - /app/node_modules + - ../../../microservices/shjksgd:/app + depends_on: + rabbitmq: + condition: service_healthy + + nginx: + depends_on: + - hd + - customer-service + - product-service + - rbac-service + - payment-service + - notification-service + - email-service + - cart-service + - cart + - user + - customer + - email + - notification + - payment + - product + - rbac + - supplier + - upload + - th + - kjhgf + - hhgfdsdfghj + - ghjk + - shjksgd + restart: always + build: + context: ./nginx + dockerfile: Dockerfile.dev + ports: + - '4000:80' + healthcheck: + test: ["CMD-SHELL", "curl -f http://localhost:80/health || exit 1"] + interval: 30s + timeout: 10s + retries: 3 + start_period: 40s + rabbitmq: + image: rabbitmq:3.13-management + container_name: rabbitmq + ports: + - '5672:5672' + - '15672:15672' + healthcheck: + test: ["CMD", "rabbitmq-diagnostics", "ping"] + interval: 30s + retries: 5 + mongodb: + image: mongo + ports: + - '27017:27017' + restart: always + volumes: + - type: bind + source: ./data + target: /data/db + krakend: + image: devopsfaith/krakend:2.7 + ports: + - '8080:8080' + - '8090:8090' + volumes: + - ./krakend/:/etc/krakend/ + command: ['run','-d','-c','/etc/krakend/krakend.json'] \ No newline at end of file diff --git a/gateways/apps/app/krakend/krakend.json b/gateways/apps/app/krakend/krakend.json new file mode 100644 index 0000000..89d801a --- /dev/null +++ b/gateways/apps/app/krakend/krakend.json @@ -0,0 +1,402 @@ + +{ + "$schema": "https://www.krakend.io/schema/v2.5/krakend.json", + "version": 3, + "name": "Microservices-suite API Gateway", + "port": 8080, + "cache_ttl": "3600s", + "timeout": "300s", + "endpoints": [ + { + "@comment": "Check the health of all your APIs", + "endpoint": "/__suite_status", + "method": "GET", + "backend": [ + { + "host": ["http://hd:null"], + "url_pattern": "/", + "mapping": { + "message": "hd" + } + }, + + { + "host": ["http://customer-service:9000"], + "url_pattern": "/", + "mapping": { + "message": "customer-service" + } + }, + + { + "host": ["http://product-service:9002"], + "url_pattern": "/", + "mapping": { + "message": "product-service" + } + }, + + { + "host": ["http://rbac-service:9004"], + "url_pattern": "/", + "mapping": { + "message": "rbac-service" + } + }, + + { + "host": ["http://payment-service:9006"], + "url_pattern": "/", + "mapping": { + "message": "payment-service" + } + }, + + { + "host": ["http://notification-service:9007"], + "url_pattern": "/", + "mapping": { + "message": "notification-service" + } + }, + + { + "host": ["http://email-service:9008"], + "url_pattern": "/", + "mapping": { + "message": "email-service" + } + }, + + { + "host": ["http://cart-service:9009"], + "url_pattern": "/", + "mapping": { + "message": "cart-service" + } + }, + + { + "host": ["http://cart:9010"], + "url_pattern": "/", + "mapping": { + "message": "cart" + } + }, + + { + "host": ["http://user:9011"], + "url_pattern": "/", + "mapping": { + "message": "user" + } + }, + + { + "host": ["http://customer:9012"], + "url_pattern": "/", + "mapping": { + "message": "customer" + } + }, + + { + "host": ["http://email:9013"], + "url_pattern": "/", + "mapping": { + "message": "email" + } + }, + + { + "host": ["http://notification:9014"], + "url_pattern": "/", + "mapping": { + "message": "notification" + } + }, + + { + "host": ["http://payment:9015"], + "url_pattern": "/", + "mapping": { + "message": "payment" + } + }, + + { + "host": ["http://product:9016"], + "url_pattern": "/", + "mapping": { + "message": "product" + } + }, + + { + "host": ["http://rbac:9017"], + "url_pattern": "/", + "mapping": { + "message": "rbac" + } + }, + + { + "host": ["http://supplier:9018"], + "url_pattern": "/", + "mapping": { + "message": "supplier" + } + }, + + { + "host": ["http://upload:9019"], + "url_pattern": "/", + "mapping": { + "message": "upload" + } + }, + + { + "host": ["http://th:9020"], + "url_pattern": "/", + "mapping": { + "message": "th" + } + }, + + { + "host": ["http://kjhgf:9021"], + "url_pattern": "/", + "mapping": { + "message": "kjhgf" + } + }, + + { + "host": ["http://hhgfdsdfghj:9022"], + "url_pattern": "/", + "mapping": { + "message": "hhgfdsdfghj" + } + }, + + { + "host": ["http://ghjk:9023"], + "url_pattern": "/", + "mapping": { + "message": "ghjk" + } + }, + + { + "host": ["http://shjksgd:30067"], + "url_pattern": "/", + "mapping": { + "message": "shjksgd" + } + }] + }, + { + "@comment": "Hit all API list endpoints simultaneously", + "endpoint": "/api/v1/", + "method": "GET", + "backend": [ + { + "host": ["http://hd:null"], + "url_pattern": "/api/v1/hds", + "mapping": { + "data": "hds" + } + }, + + { + "host": ["http://customer-service:9000"], + "url_pattern": "/api/v1/customer-services", + "mapping": { + "data": "customer-services" + } + }, + + { + "host": ["http://product-service:9002"], + "url_pattern": "/api/v1/product-services", + "mapping": { + "data": "product-services" + } + }, + + { + "host": ["http://rbac-service:9004"], + "url_pattern": "/api/v1/rbac-services", + "mapping": { + "data": "rbac-services" + } + }, + + { + "host": ["http://payment-service:9006"], + "url_pattern": "/api/v1/payment-services", + "mapping": { + "data": "payment-services" + } + }, + + { + "host": ["http://notification-service:9007"], + "url_pattern": "/api/v1/notification-services", + "mapping": { + "data": "notification-services" + } + }, + + { + "host": ["http://email-service:9008"], + "url_pattern": "/api/v1/email-services", + "mapping": { + "data": "email-services" + } + }, + + { + "host": ["http://cart-service:9009"], + "url_pattern": "/api/v1/cart-services", + "mapping": { + "data": "cart-services" + } + }, + + { + "host": ["http://cart:9010"], + "url_pattern": "/api/v1/carts", + "mapping": { + "data": "carts" + } + }, + + { + "host": ["http://user:9011"], + "url_pattern": "/api/v1/users", + "mapping": { + "data": "users" + } + }, + + { + "host": ["http://customer:9012"], + "url_pattern": "/api/v1/customers", + "mapping": { + "data": "customers" + } + }, + + { + "host": ["http://email:9013"], + "url_pattern": "/api/v1/emails", + "mapping": { + "data": "emails" + } + }, + + { + "host": ["http://notification:9014"], + "url_pattern": "/api/v1/notifications", + "mapping": { + "data": "notifications" + } + }, + + { + "host": ["http://payment:9015"], + "url_pattern": "/api/v1/payments", + "mapping": { + "data": "payments" + } + }, + + { + "host": ["http://product:9016"], + "url_pattern": "/api/v1/products", + "mapping": { + "data": "products" + } + }, + + { + "host": ["http://rbac:9017"], + "url_pattern": "/api/v1/rbacs", + "mapping": { + "data": "rbacs" + } + }, + + { + "host": ["http://supplier:9018"], + "url_pattern": "/api/v1/suppliers", + "mapping": { + "data": "suppliers" + } + }, + + { + "host": ["http://upload:9019"], + "url_pattern": "/api/v1/uploads", + "mapping": { + "data": "uploads" + } + }, + + { + "host": ["http://th:9020"], + "url_pattern": "/api/v1/ths", + "mapping": { + "data": "ths" + } + }, + + { + "host": ["http://kjhgf:9021"], + "url_pattern": "/api/v1/kjhgfs", + "mapping": { + "data": "kjhgfs" + } + }, + + { + "host": ["http://hhgfdsdfghj:9022"], + "url_pattern": "/api/v1/hhgfdsdfghjs", + "mapping": { + "data": "hhgfdsdfghjs" + } + }, + + { + "host": ["http://ghjk:9023"], + "url_pattern": "/api/v1/ghjks", + "mapping": { + "data": "ghjks" + } + }, + + { + "host": ["http://shjksgd:30067"], + "url_pattern": "/api/v1/shjksgds", + "mapping": { + "data": "shjksgds" + } + }] + }, + { + "@comment": "Fetch all data from the hd service", + "endpoint": "/api/v1/hds", + "method": "GET", + "backend": [ + { + "host": ["http://hd:null"], + "url_pattern": "/api/v1/hds", + "mapping": { + "data": "hds" + } + }] + } + ] +} \ No newline at end of file diff --git a/gateways/apps/app/nginx/Dockerfile b/gateways/apps/app/nginx/Dockerfile new file mode 100644 index 0000000..ddf7281 --- /dev/null +++ b/gateways/apps/app/nginx/Dockerfile @@ -0,0 +1,3 @@ + +FROM nginx +COPY ./default.conf /etc/nginx/conf.d/default.conf \ No newline at end of file diff --git a/gateways/apps/app/nginx/Dockerfile.dev b/gateways/apps/app/nginx/Dockerfile.dev new file mode 100644 index 0000000..ddf7281 --- /dev/null +++ b/gateways/apps/app/nginx/Dockerfile.dev @@ -0,0 +1,3 @@ + +FROM nginx +COPY ./default.conf /etc/nginx/conf.d/default.conf \ No newline at end of file diff --git a/gateways/apps/app/nginx/default.conf b/gateways/apps/app/nginx/default.conf new file mode 100644 index 0000000..d4dace0 --- /dev/null +++ b/gateways/apps/app/nginx/default.conf @@ -0,0 +1,282 @@ + + +upstream hd_upstream { + server hd:null; +} + +upstream customer-service_upstream { + server customer-service:9000; +} + +upstream product-service_upstream { + server product-service:9002; +} + +upstream rbac-service_upstream { + server rbac-service:9004; +} + +upstream payment-service_upstream { + server payment-service:9006; +} + +upstream notification-service_upstream { + server notification-service:9007; +} + +upstream email-service_upstream { + server email-service:9008; +} + +upstream cart-service_upstream { + server cart-service:9009; +} + +upstream cart_upstream { + server cart:9010; +} + +upstream user_upstream { + server user:9011; +} + +upstream customer_upstream { + server customer:9012; +} + +upstream email_upstream { + server email:9013; +} + +upstream notification_upstream { + server notification:9014; +} + +upstream payment_upstream { + server payment:9015; +} + +upstream product_upstream { + server product:9016; +} + +upstream rbac_upstream { + server rbac:9017; +} + +upstream supplier_upstream { + server supplier:9018; +} + +upstream upload_upstream { + server upload:9019; +} + +upstream th_upstream { + server th:9020; +} + +upstream kjhgf_upstream { + server kjhgf:9021; +} + +upstream hhgfdsdfghj_upstream { + server hhgfdsdfghj:9022; +} + +upstream ghjk_upstream { + server ghjk:9023; +} + +upstream shjksgd_upstream { + server shjksgd:30067; +} + +server { + listen 80; + + + location /api/v1/hds { + proxy_pass http://hd_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/customer-services { + proxy_pass http://customer-service_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/product-services { + proxy_pass http://product-service_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/rbac-services { + proxy_pass http://rbac-service_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/payment-services { + proxy_pass http://payment-service_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/notification-services { + proxy_pass http://notification-service_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/email-services { + proxy_pass http://email-service_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/cart-services { + proxy_pass http://cart-service_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/carts { + proxy_pass http://cart_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/users { + proxy_pass http://user_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/customers { + proxy_pass http://customer_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/emails { + proxy_pass http://email_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/notifications { + proxy_pass http://notification_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/payments { + proxy_pass http://payment_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/products { + proxy_pass http://product_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/rbacs { + proxy_pass http://rbac_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/suppliers { + proxy_pass http://supplier_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/uploads { + proxy_pass http://upload_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/ths { + proxy_pass http://th_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/kjhgfs { + proxy_pass http://kjhgf_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/hhgfdsdfghjs { + proxy_pass http://hhgfdsdfghj_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/ghjks { + proxy_pass http://ghjk_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/shjksgds { + proxy_pass http://shjksgd_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } +} \ No newline at end of file diff --git a/gateways/apps/dfgdf/docker-compose.dev.yml b/gateways/apps/dfgdf/docker-compose.dev.yml new file mode 100644 index 0000000..2e4556e --- /dev/null +++ b/gateways/apps/dfgdf/docker-compose.dev.yml @@ -0,0 +1,367 @@ + +version: '3.8' +services: + + hd: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/hd + ports: + - "null:null" + volumes: + - /app/node_modules + - ../../../microservices/hd:/app + depends_on: + rabbitmq: + condition: service_healthy + + customer-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/customer-service + ports: + - "9000:9000" + volumes: + - /app/node_modules + - ../../../microservices/customer-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + product-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/product-service + ports: + - "9002:9002" + volumes: + - /app/node_modules + - ../../../microservices/product-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + rbac-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/rbac-service + ports: + - "9004:9004" + volumes: + - /app/node_modules + - ../../../microservices/rbac-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + payment-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/payment-service + ports: + - "9006:9006" + volumes: + - /app/node_modules + - ../../../microservices/payment-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + notification-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/notification-service + ports: + - "9007:9007" + volumes: + - /app/node_modules + - ../../../microservices/notification-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + email-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/email-service + ports: + - "9008:9008" + volumes: + - /app/node_modules + - ../../../microservices/email-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + cart-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/cart-service + ports: + - "9009:9009" + volumes: + - /app/node_modules + - ../../../microservices/cart-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + cart: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/cart + ports: + - "9010:9010" + volumes: + - /app/node_modules + - ../../../microservices/cart:/app + depends_on: + rabbitmq: + condition: service_healthy + + user: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/user + ports: + - "9011:9011" + volumes: + - /app/node_modules + - ../../../microservices/user:/app + depends_on: + rabbitmq: + condition: service_healthy + + customer: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/customer + ports: + - "9012:9012" + volumes: + - /app/node_modules + - ../../../microservices/customer:/app + depends_on: + rabbitmq: + condition: service_healthy + + email: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/email + ports: + - "9013:9013" + volumes: + - /app/node_modules + - ../../../microservices/email:/app + depends_on: + rabbitmq: + condition: service_healthy + + notification: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/notification + ports: + - "9014:9014" + volumes: + - /app/node_modules + - ../../../microservices/notification:/app + depends_on: + rabbitmq: + condition: service_healthy + + payment: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/payment + ports: + - "9015:9015" + volumes: + - /app/node_modules + - ../../../microservices/payment:/app + depends_on: + rabbitmq: + condition: service_healthy + + product: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/product + ports: + - "9016:9016" + volumes: + - /app/node_modules + - ../../../microservices/product:/app + depends_on: + rabbitmq: + condition: service_healthy + + rbac: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/rbac + ports: + - "9017:9017" + volumes: + - /app/node_modules + - ../../../microservices/rbac:/app + depends_on: + rabbitmq: + condition: service_healthy + + supplier: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/supplier + ports: + - "9018:9018" + volumes: + - /app/node_modules + - ../../../microservices/supplier:/app + depends_on: + rabbitmq: + condition: service_healthy + + upload: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/upload + ports: + - "9019:9019" + volumes: + - /app/node_modules + - ../../../microservices/upload:/app + depends_on: + rabbitmq: + condition: service_healthy + + th: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/th + ports: + - "9020:9020" + volumes: + - /app/node_modules + - ../../../microservices/th:/app + depends_on: + rabbitmq: + condition: service_healthy + + kjhgf: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/kjhgf + ports: + - "9021:9021" + volumes: + - /app/node_modules + - ../../../microservices/kjhgf:/app + depends_on: + rabbitmq: + condition: service_healthy + + hhgfdsdfghj: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/hhgfdsdfghj + ports: + - "9022:9022" + volumes: + - /app/node_modules + - ../../../microservices/hhgfdsdfghj:/app + depends_on: + rabbitmq: + condition: service_healthy + + ghjk: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/ghjk + ports: + - "9023:9023" + volumes: + - /app/node_modules + - ../../../microservices/ghjk:/app + depends_on: + rabbitmq: + condition: service_healthy + + shjksgd: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/shjksgd + ports: + - "30067:30067" + volumes: + - /app/node_modules + - ../../../microservices/shjksgd:/app + depends_on: + rabbitmq: + condition: service_healthy + + nginx: + depends_on: + - hd + - customer-service + - product-service + - rbac-service + - payment-service + - notification-service + - email-service + - cart-service + - cart + - user + - customer + - email + - notification + - payment + - product + - rbac + - supplier + - upload + - th + - kjhgf + - hhgfdsdfghj + - ghjk + - shjksgd + restart: always + build: + context: ./nginx + dockerfile: Dockerfile.dev + ports: + - '4000:80' + healthcheck: + test: ["CMD-SHELL", "curl -f http://localhost:80/health || exit 1"] + interval: 30s + timeout: 10s + retries: 3 + start_period: 40s + rabbitmq: + image: rabbitmq:3.13-management + container_name: rabbitmq + ports: + - '5672:5672' + - '15672:15672' + healthcheck: + test: ["CMD", "rabbitmq-diagnostics", "ping"] + interval: 30s + retries: 5 + mongodb: + image: mongo + ports: + - '27017:27017' + restart: always + volumes: + - type: bind + source: ./data + target: /data/db + krakend: + image: devopsfaith/krakend:2.7-watch + ports: + - '9004:9004' + - '8090:8090' + volumes: + - ./krakend/:/etc/krakend/ + command: ['run','-d','-c','/etc/krakend/krakend.json'] \ No newline at end of file diff --git a/gateways/apps/dfgdf/docker-compose.yml b/gateways/apps/dfgdf/docker-compose.yml new file mode 100644 index 0000000..0b26c81 --- /dev/null +++ b/gateways/apps/dfgdf/docker-compose.yml @@ -0,0 +1,367 @@ + +version: '3.8' +services: + + hd: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/hd + ports: + - "null:null" + volumes: + - /app/node_modules + - ../../../microservices/hd:/app + depends_on: + rabbitmq: + condition: service_healthy + + customer-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/customer-service + ports: + - "9000:9000" + volumes: + - /app/node_modules + - ../../../microservices/customer-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + product-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/product-service + ports: + - "9002:9002" + volumes: + - /app/node_modules + - ../../../microservices/product-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + rbac-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/rbac-service + ports: + - "9004:9004" + volumes: + - /app/node_modules + - ../../../microservices/rbac-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + payment-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/payment-service + ports: + - "9006:9006" + volumes: + - /app/node_modules + - ../../../microservices/payment-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + notification-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/notification-service + ports: + - "9007:9007" + volumes: + - /app/node_modules + - ../../../microservices/notification-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + email-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/email-service + ports: + - "9008:9008" + volumes: + - /app/node_modules + - ../../../microservices/email-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + cart-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/cart-service + ports: + - "9009:9009" + volumes: + - /app/node_modules + - ../../../microservices/cart-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + cart: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/cart + ports: + - "9010:9010" + volumes: + - /app/node_modules + - ../../../microservices/cart:/app + depends_on: + rabbitmq: + condition: service_healthy + + user: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/user + ports: + - "9011:9011" + volumes: + - /app/node_modules + - ../../../microservices/user:/app + depends_on: + rabbitmq: + condition: service_healthy + + customer: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/customer + ports: + - "9012:9012" + volumes: + - /app/node_modules + - ../../../microservices/customer:/app + depends_on: + rabbitmq: + condition: service_healthy + + email: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/email + ports: + - "9013:9013" + volumes: + - /app/node_modules + - ../../../microservices/email:/app + depends_on: + rabbitmq: + condition: service_healthy + + notification: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/notification + ports: + - "9014:9014" + volumes: + - /app/node_modules + - ../../../microservices/notification:/app + depends_on: + rabbitmq: + condition: service_healthy + + payment: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/payment + ports: + - "9015:9015" + volumes: + - /app/node_modules + - ../../../microservices/payment:/app + depends_on: + rabbitmq: + condition: service_healthy + + product: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/product + ports: + - "9016:9016" + volumes: + - /app/node_modules + - ../../../microservices/product:/app + depends_on: + rabbitmq: + condition: service_healthy + + rbac: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/rbac + ports: + - "9017:9017" + volumes: + - /app/node_modules + - ../../../microservices/rbac:/app + depends_on: + rabbitmq: + condition: service_healthy + + supplier: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/supplier + ports: + - "9018:9018" + volumes: + - /app/node_modules + - ../../../microservices/supplier:/app + depends_on: + rabbitmq: + condition: service_healthy + + upload: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/upload + ports: + - "9019:9019" + volumes: + - /app/node_modules + - ../../../microservices/upload:/app + depends_on: + rabbitmq: + condition: service_healthy + + th: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/th + ports: + - "9020:9020" + volumes: + - /app/node_modules + - ../../../microservices/th:/app + depends_on: + rabbitmq: + condition: service_healthy + + kjhgf: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/kjhgf + ports: + - "9021:9021" + volumes: + - /app/node_modules + - ../../../microservices/kjhgf:/app + depends_on: + rabbitmq: + condition: service_healthy + + hhgfdsdfghj: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/hhgfdsdfghj + ports: + - "9022:9022" + volumes: + - /app/node_modules + - ../../../microservices/hhgfdsdfghj:/app + depends_on: + rabbitmq: + condition: service_healthy + + ghjk: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/ghjk + ports: + - "9023:9023" + volumes: + - /app/node_modules + - ../../../microservices/ghjk:/app + depends_on: + rabbitmq: + condition: service_healthy + + shjksgd: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/shjksgd + ports: + - "30067:30067" + volumes: + - /app/node_modules + - ../../../microservices/shjksgd:/app + depends_on: + rabbitmq: + condition: service_healthy + + nginx: + depends_on: + - hd + - customer-service + - product-service + - rbac-service + - payment-service + - notification-service + - email-service + - cart-service + - cart + - user + - customer + - email + - notification + - payment + - product + - rbac + - supplier + - upload + - th + - kjhgf + - hhgfdsdfghj + - ghjk + - shjksgd + restart: always + build: + context: ./nginx + dockerfile: Dockerfile.dev + ports: + - '4000:80' + healthcheck: + test: ["CMD-SHELL", "curl -f http://localhost:80/health || exit 1"] + interval: 30s + timeout: 10s + retries: 3 + start_period: 40s + rabbitmq: + image: rabbitmq:3.13-management + container_name: rabbitmq + ports: + - '5672:5672' + - '15672:15672' + healthcheck: + test: ["CMD", "rabbitmq-diagnostics", "ping"] + interval: 30s + retries: 5 + mongodb: + image: mongo + ports: + - '27017:27017' + restart: always + volumes: + - type: bind + source: ./data + target: /data/db + krakend: + image: devopsfaith/krakend:2.7 + ports: + - '9004:9004' + - '8090:8090' + volumes: + - ./krakend/:/etc/krakend/ + command: ['run','-d','-c','/etc/krakend/krakend.json'] \ No newline at end of file diff --git a/gateways/apps/dfgdf/krakend/krakend.json b/gateways/apps/dfgdf/krakend/krakend.json new file mode 100644 index 0000000..3ee5eab --- /dev/null +++ b/gateways/apps/dfgdf/krakend/krakend.json @@ -0,0 +1,402 @@ + +{ + "$schema": "https://www.krakend.io/schema/v2.5/krakend.json", + "version": 3, + "name": "Microservices-suite API Gateway", + "port": 9004, + "cache_ttl": "3600s", + "timeout": "300s", + "endpoints": [ + { + "@comment": "Check the health of all your APIs", + "endpoint": "/__suite_status", + "method": "GET", + "backend": [ + { + "host": ["http://hd:null"], + "url_pattern": "/", + "mapping": { + "message": "hd" + } + }, + + { + "host": ["http://customer-service:9000"], + "url_pattern": "/", + "mapping": { + "message": "customer-service" + } + }, + + { + "host": ["http://product-service:9002"], + "url_pattern": "/", + "mapping": { + "message": "product-service" + } + }, + + { + "host": ["http://rbac-service:9004"], + "url_pattern": "/", + "mapping": { + "message": "rbac-service" + } + }, + + { + "host": ["http://payment-service:9006"], + "url_pattern": "/", + "mapping": { + "message": "payment-service" + } + }, + + { + "host": ["http://notification-service:9007"], + "url_pattern": "/", + "mapping": { + "message": "notification-service" + } + }, + + { + "host": ["http://email-service:9008"], + "url_pattern": "/", + "mapping": { + "message": "email-service" + } + }, + + { + "host": ["http://cart-service:9009"], + "url_pattern": "/", + "mapping": { + "message": "cart-service" + } + }, + + { + "host": ["http://cart:9010"], + "url_pattern": "/", + "mapping": { + "message": "cart" + } + }, + + { + "host": ["http://user:9011"], + "url_pattern": "/", + "mapping": { + "message": "user" + } + }, + + { + "host": ["http://customer:9012"], + "url_pattern": "/", + "mapping": { + "message": "customer" + } + }, + + { + "host": ["http://email:9013"], + "url_pattern": "/", + "mapping": { + "message": "email" + } + }, + + { + "host": ["http://notification:9014"], + "url_pattern": "/", + "mapping": { + "message": "notification" + } + }, + + { + "host": ["http://payment:9015"], + "url_pattern": "/", + "mapping": { + "message": "payment" + } + }, + + { + "host": ["http://product:9016"], + "url_pattern": "/", + "mapping": { + "message": "product" + } + }, + + { + "host": ["http://rbac:9017"], + "url_pattern": "/", + "mapping": { + "message": "rbac" + } + }, + + { + "host": ["http://supplier:9018"], + "url_pattern": "/", + "mapping": { + "message": "supplier" + } + }, + + { + "host": ["http://upload:9019"], + "url_pattern": "/", + "mapping": { + "message": "upload" + } + }, + + { + "host": ["http://th:9020"], + "url_pattern": "/", + "mapping": { + "message": "th" + } + }, + + { + "host": ["http://kjhgf:9021"], + "url_pattern": "/", + "mapping": { + "message": "kjhgf" + } + }, + + { + "host": ["http://hhgfdsdfghj:9022"], + "url_pattern": "/", + "mapping": { + "message": "hhgfdsdfghj" + } + }, + + { + "host": ["http://ghjk:9023"], + "url_pattern": "/", + "mapping": { + "message": "ghjk" + } + }, + + { + "host": ["http://shjksgd:30067"], + "url_pattern": "/", + "mapping": { + "message": "shjksgd" + } + }] + }, + { + "@comment": "Hit all API list endpoints simultaneously", + "endpoint": "/api/v1/", + "method": "GET", + "backend": [ + { + "host": ["http://hd:null"], + "url_pattern": "/api/v1/hds", + "mapping": { + "data": "hds" + } + }, + + { + "host": ["http://customer-service:9000"], + "url_pattern": "/api/v1/customer-services", + "mapping": { + "data": "customer-services" + } + }, + + { + "host": ["http://product-service:9002"], + "url_pattern": "/api/v1/product-services", + "mapping": { + "data": "product-services" + } + }, + + { + "host": ["http://rbac-service:9004"], + "url_pattern": "/api/v1/rbac-services", + "mapping": { + "data": "rbac-services" + } + }, + + { + "host": ["http://payment-service:9006"], + "url_pattern": "/api/v1/payment-services", + "mapping": { + "data": "payment-services" + } + }, + + { + "host": ["http://notification-service:9007"], + "url_pattern": "/api/v1/notification-services", + "mapping": { + "data": "notification-services" + } + }, + + { + "host": ["http://email-service:9008"], + "url_pattern": "/api/v1/email-services", + "mapping": { + "data": "email-services" + } + }, + + { + "host": ["http://cart-service:9009"], + "url_pattern": "/api/v1/cart-services", + "mapping": { + "data": "cart-services" + } + }, + + { + "host": ["http://cart:9010"], + "url_pattern": "/api/v1/carts", + "mapping": { + "data": "carts" + } + }, + + { + "host": ["http://user:9011"], + "url_pattern": "/api/v1/users", + "mapping": { + "data": "users" + } + }, + + { + "host": ["http://customer:9012"], + "url_pattern": "/api/v1/customers", + "mapping": { + "data": "customers" + } + }, + + { + "host": ["http://email:9013"], + "url_pattern": "/api/v1/emails", + "mapping": { + "data": "emails" + } + }, + + { + "host": ["http://notification:9014"], + "url_pattern": "/api/v1/notifications", + "mapping": { + "data": "notifications" + } + }, + + { + "host": ["http://payment:9015"], + "url_pattern": "/api/v1/payments", + "mapping": { + "data": "payments" + } + }, + + { + "host": ["http://product:9016"], + "url_pattern": "/api/v1/products", + "mapping": { + "data": "products" + } + }, + + { + "host": ["http://rbac:9017"], + "url_pattern": "/api/v1/rbacs", + "mapping": { + "data": "rbacs" + } + }, + + { + "host": ["http://supplier:9018"], + "url_pattern": "/api/v1/suppliers", + "mapping": { + "data": "suppliers" + } + }, + + { + "host": ["http://upload:9019"], + "url_pattern": "/api/v1/uploads", + "mapping": { + "data": "uploads" + } + }, + + { + "host": ["http://th:9020"], + "url_pattern": "/api/v1/ths", + "mapping": { + "data": "ths" + } + }, + + { + "host": ["http://kjhgf:9021"], + "url_pattern": "/api/v1/kjhgfs", + "mapping": { + "data": "kjhgfs" + } + }, + + { + "host": ["http://hhgfdsdfghj:9022"], + "url_pattern": "/api/v1/hhgfdsdfghjs", + "mapping": { + "data": "hhgfdsdfghjs" + } + }, + + { + "host": ["http://ghjk:9023"], + "url_pattern": "/api/v1/ghjks", + "mapping": { + "data": "ghjks" + } + }, + + { + "host": ["http://shjksgd:30067"], + "url_pattern": "/api/v1/shjksgds", + "mapping": { + "data": "shjksgds" + } + }] + }, + { + "@comment": "Fetch all data from the hd service", + "endpoint": "/api/v1/hds", + "method": "GET", + "backend": [ + { + "host": ["http://hd:null"], + "url_pattern": "/api/v1/hds", + "mapping": { + "data": "hds" + } + }] + } + ] +} \ No newline at end of file diff --git a/gateways/apps/dfgdf/nginx/Dockerfile b/gateways/apps/dfgdf/nginx/Dockerfile new file mode 100644 index 0000000..ddf7281 --- /dev/null +++ b/gateways/apps/dfgdf/nginx/Dockerfile @@ -0,0 +1,3 @@ + +FROM nginx +COPY ./default.conf /etc/nginx/conf.d/default.conf \ No newline at end of file diff --git a/gateways/apps/dfgdf/nginx/Dockerfile.dev b/gateways/apps/dfgdf/nginx/Dockerfile.dev new file mode 100644 index 0000000..ddf7281 --- /dev/null +++ b/gateways/apps/dfgdf/nginx/Dockerfile.dev @@ -0,0 +1,3 @@ + +FROM nginx +COPY ./default.conf /etc/nginx/conf.d/default.conf \ No newline at end of file diff --git a/gateways/apps/dfgdf/nginx/default.conf b/gateways/apps/dfgdf/nginx/default.conf new file mode 100644 index 0000000..d4dace0 --- /dev/null +++ b/gateways/apps/dfgdf/nginx/default.conf @@ -0,0 +1,282 @@ + + +upstream hd_upstream { + server hd:null; +} + +upstream customer-service_upstream { + server customer-service:9000; +} + +upstream product-service_upstream { + server product-service:9002; +} + +upstream rbac-service_upstream { + server rbac-service:9004; +} + +upstream payment-service_upstream { + server payment-service:9006; +} + +upstream notification-service_upstream { + server notification-service:9007; +} + +upstream email-service_upstream { + server email-service:9008; +} + +upstream cart-service_upstream { + server cart-service:9009; +} + +upstream cart_upstream { + server cart:9010; +} + +upstream user_upstream { + server user:9011; +} + +upstream customer_upstream { + server customer:9012; +} + +upstream email_upstream { + server email:9013; +} + +upstream notification_upstream { + server notification:9014; +} + +upstream payment_upstream { + server payment:9015; +} + +upstream product_upstream { + server product:9016; +} + +upstream rbac_upstream { + server rbac:9017; +} + +upstream supplier_upstream { + server supplier:9018; +} + +upstream upload_upstream { + server upload:9019; +} + +upstream th_upstream { + server th:9020; +} + +upstream kjhgf_upstream { + server kjhgf:9021; +} + +upstream hhgfdsdfghj_upstream { + server hhgfdsdfghj:9022; +} + +upstream ghjk_upstream { + server ghjk:9023; +} + +upstream shjksgd_upstream { + server shjksgd:30067; +} + +server { + listen 80; + + + location /api/v1/hds { + proxy_pass http://hd_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/customer-services { + proxy_pass http://customer-service_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/product-services { + proxy_pass http://product-service_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/rbac-services { + proxy_pass http://rbac-service_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/payment-services { + proxy_pass http://payment-service_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/notification-services { + proxy_pass http://notification-service_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/email-services { + proxy_pass http://email-service_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/cart-services { + proxy_pass http://cart-service_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/carts { + proxy_pass http://cart_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/users { + proxy_pass http://user_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/customers { + proxy_pass http://customer_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/emails { + proxy_pass http://email_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/notifications { + proxy_pass http://notification_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/payments { + proxy_pass http://payment_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/products { + proxy_pass http://product_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/rbacs { + proxy_pass http://rbac_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/suppliers { + proxy_pass http://supplier_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/uploads { + proxy_pass http://upload_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/ths { + proxy_pass http://th_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/kjhgfs { + proxy_pass http://kjhgf_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/hhgfdsdfghjs { + proxy_pass http://hhgfdsdfghj_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/ghjks { + proxy_pass http://ghjk_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/shjksgds { + proxy_pass http://shjksgd_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } +} \ No newline at end of file diff --git a/gateways/apps/dfghjk/docker-compose.dev.yml b/gateways/apps/dfghjk/docker-compose.dev.yml new file mode 100644 index 0000000..03a3b30 --- /dev/null +++ b/gateways/apps/dfghjk/docker-compose.dev.yml @@ -0,0 +1,353 @@ + +version: '3.8' +services: + + hd: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/hd + ports: + - "null:null" + volumes: + - /app/node_modules + - ../../../microservices/hd:/app + depends_on: + rabbitmq: + condition: service_healthy + + customer-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/customer-service + ports: + - "9000:9000" + volumes: + - /app/node_modules + - ../../../microservices/customer-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + product-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/product-service + ports: + - "9002:9002" + volumes: + - /app/node_modules + - ../../../microservices/product-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + rbac-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/rbac-service + ports: + - "9004:9004" + volumes: + - /app/node_modules + - ../../../microservices/rbac-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + payment-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/payment-service + ports: + - "9006:9006" + volumes: + - /app/node_modules + - ../../../microservices/payment-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + notification-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/notification-service + ports: + - "9007:9007" + volumes: + - /app/node_modules + - ../../../microservices/notification-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + email-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/email-service + ports: + - "9008:9008" + volumes: + - /app/node_modules + - ../../../microservices/email-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + cart-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/cart-service + ports: + - "9009:9009" + volumes: + - /app/node_modules + - ../../../microservices/cart-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + cart: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/cart + ports: + - "9010:9010" + volumes: + - /app/node_modules + - ../../../microservices/cart:/app + depends_on: + rabbitmq: + condition: service_healthy + + user: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/user + ports: + - "9011:9011" + volumes: + - /app/node_modules + - ../../../microservices/user:/app + depends_on: + rabbitmq: + condition: service_healthy + + customer: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/customer + ports: + - "9012:9012" + volumes: + - /app/node_modules + - ../../../microservices/customer:/app + depends_on: + rabbitmq: + condition: service_healthy + + email: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/email + ports: + - "9013:9013" + volumes: + - /app/node_modules + - ../../../microservices/email:/app + depends_on: + rabbitmq: + condition: service_healthy + + notification: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/notification + ports: + - "9014:9014" + volumes: + - /app/node_modules + - ../../../microservices/notification:/app + depends_on: + rabbitmq: + condition: service_healthy + + payment: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/payment + ports: + - "9015:9015" + volumes: + - /app/node_modules + - ../../../microservices/payment:/app + depends_on: + rabbitmq: + condition: service_healthy + + product: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/product + ports: + - "9016:9016" + volumes: + - /app/node_modules + - ../../../microservices/product:/app + depends_on: + rabbitmq: + condition: service_healthy + + rbac: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/rbac + ports: + - "9017:9017" + volumes: + - /app/node_modules + - ../../../microservices/rbac:/app + depends_on: + rabbitmq: + condition: service_healthy + + supplier: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/supplier + ports: + - "9018:9018" + volumes: + - /app/node_modules + - ../../../microservices/supplier:/app + depends_on: + rabbitmq: + condition: service_healthy + + upload: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/upload + ports: + - "9019:9019" + volumes: + - /app/node_modules + - ../../../microservices/upload:/app + depends_on: + rabbitmq: + condition: service_healthy + + th: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/th + ports: + - "9020:9020" + volumes: + - /app/node_modules + - ../../../microservices/th:/app + depends_on: + rabbitmq: + condition: service_healthy + + kjhgf: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/kjhgf + ports: + - "9021:9021" + volumes: + - /app/node_modules + - ../../../microservices/kjhgf:/app + depends_on: + rabbitmq: + condition: service_healthy + + hhgfdsdfghj: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/hhgfdsdfghj + ports: + - "9022:9022" + volumes: + - /app/node_modules + - ../../../microservices/hhgfdsdfghj:/app + depends_on: + rabbitmq: + condition: service_healthy + + ghjk: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/ghjk + ports: + - "9023:9023" + volumes: + - /app/node_modules + - ../../../microservices/ghjk:/app + depends_on: + rabbitmq: + condition: service_healthy + + nginx: + depends_on: + - hd + - customer-service + - product-service + - rbac-service + - payment-service + - notification-service + - email-service + - cart-service + - cart + - user + - customer + - email + - notification + - payment + - product + - rbac + - supplier + - upload + - th + - kjhgf + - hhgfdsdfghj + - ghjk + restart: always + build: + context: ./nginx + dockerfile: Dockerfile.dev + ports: + - '4000:80' + healthcheck: + test: ["CMD-SHELL", "curl -f http://localhost:80/health || exit 1"] + interval: 30s + timeout: 10s + retries: 3 + start_period: 40s + rabbitmq: + image: rabbitmq:3.13-management + container_name: rabbitmq + ports: + - '5672:5672' + - '15672:15672' + healthcheck: + test: ["CMD", "rabbitmq-diagnostics", "ping"] + interval: 30s + retries: 5 + mongodb: + image: mongo + ports: + - '27017:27017' + restart: always + volumes: + - type: bind + source: ./data + target: /data/db + krakend: + image: devopsfaith/krakend:2.7-watch + ports: + - '9001:9001' + - '8090:8090' + volumes: + - ./krakend/:/etc/krakend/ + command: ['run','-d','-c','/etc/krakend/krakend.json'] \ No newline at end of file diff --git a/gateways/apps/dfghjk/docker-compose.yml b/gateways/apps/dfghjk/docker-compose.yml new file mode 100644 index 0000000..f11f17d --- /dev/null +++ b/gateways/apps/dfghjk/docker-compose.yml @@ -0,0 +1,353 @@ + +version: '3.8' +services: + + hd: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/hd + ports: + - "null:null" + volumes: + - /app/node_modules + - ../../../microservices/hd:/app + depends_on: + rabbitmq: + condition: service_healthy + + customer-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/customer-service + ports: + - "9000:9000" + volumes: + - /app/node_modules + - ../../../microservices/customer-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + product-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/product-service + ports: + - "9002:9002" + volumes: + - /app/node_modules + - ../../../microservices/product-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + rbac-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/rbac-service + ports: + - "9004:9004" + volumes: + - /app/node_modules + - ../../../microservices/rbac-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + payment-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/payment-service + ports: + - "9006:9006" + volumes: + - /app/node_modules + - ../../../microservices/payment-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + notification-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/notification-service + ports: + - "9007:9007" + volumes: + - /app/node_modules + - ../../../microservices/notification-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + email-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/email-service + ports: + - "9008:9008" + volumes: + - /app/node_modules + - ../../../microservices/email-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + cart-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/cart-service + ports: + - "9009:9009" + volumes: + - /app/node_modules + - ../../../microservices/cart-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + cart: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/cart + ports: + - "9010:9010" + volumes: + - /app/node_modules + - ../../../microservices/cart:/app + depends_on: + rabbitmq: + condition: service_healthy + + user: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/user + ports: + - "9011:9011" + volumes: + - /app/node_modules + - ../../../microservices/user:/app + depends_on: + rabbitmq: + condition: service_healthy + + customer: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/customer + ports: + - "9012:9012" + volumes: + - /app/node_modules + - ../../../microservices/customer:/app + depends_on: + rabbitmq: + condition: service_healthy + + email: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/email + ports: + - "9013:9013" + volumes: + - /app/node_modules + - ../../../microservices/email:/app + depends_on: + rabbitmq: + condition: service_healthy + + notification: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/notification + ports: + - "9014:9014" + volumes: + - /app/node_modules + - ../../../microservices/notification:/app + depends_on: + rabbitmq: + condition: service_healthy + + payment: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/payment + ports: + - "9015:9015" + volumes: + - /app/node_modules + - ../../../microservices/payment:/app + depends_on: + rabbitmq: + condition: service_healthy + + product: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/product + ports: + - "9016:9016" + volumes: + - /app/node_modules + - ../../../microservices/product:/app + depends_on: + rabbitmq: + condition: service_healthy + + rbac: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/rbac + ports: + - "9017:9017" + volumes: + - /app/node_modules + - ../../../microservices/rbac:/app + depends_on: + rabbitmq: + condition: service_healthy + + supplier: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/supplier + ports: + - "9018:9018" + volumes: + - /app/node_modules + - ../../../microservices/supplier:/app + depends_on: + rabbitmq: + condition: service_healthy + + upload: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/upload + ports: + - "9019:9019" + volumes: + - /app/node_modules + - ../../../microservices/upload:/app + depends_on: + rabbitmq: + condition: service_healthy + + th: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/th + ports: + - "9020:9020" + volumes: + - /app/node_modules + - ../../../microservices/th:/app + depends_on: + rabbitmq: + condition: service_healthy + + kjhgf: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/kjhgf + ports: + - "9021:9021" + volumes: + - /app/node_modules + - ../../../microservices/kjhgf:/app + depends_on: + rabbitmq: + condition: service_healthy + + hhgfdsdfghj: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/hhgfdsdfghj + ports: + - "9022:9022" + volumes: + - /app/node_modules + - ../../../microservices/hhgfdsdfghj:/app + depends_on: + rabbitmq: + condition: service_healthy + + ghjk: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/ghjk + ports: + - "9023:9023" + volumes: + - /app/node_modules + - ../../../microservices/ghjk:/app + depends_on: + rabbitmq: + condition: service_healthy + + nginx: + depends_on: + - hd + - customer-service + - product-service + - rbac-service + - payment-service + - notification-service + - email-service + - cart-service + - cart + - user + - customer + - email + - notification + - payment + - product + - rbac + - supplier + - upload + - th + - kjhgf + - hhgfdsdfghj + - ghjk + restart: always + build: + context: ./nginx + dockerfile: Dockerfile.dev + ports: + - '4000:80' + healthcheck: + test: ["CMD-SHELL", "curl -f http://localhost:80/health || exit 1"] + interval: 30s + timeout: 10s + retries: 3 + start_period: 40s + rabbitmq: + image: rabbitmq:3.13-management + container_name: rabbitmq + ports: + - '5672:5672' + - '15672:15672' + healthcheck: + test: ["CMD", "rabbitmq-diagnostics", "ping"] + interval: 30s + retries: 5 + mongodb: + image: mongo + ports: + - '27017:27017' + restart: always + volumes: + - type: bind + source: ./data + target: /data/db + krakend: + image: devopsfaith/krakend:2.7 + ports: + - '9001:9001' + - '8090:8090' + volumes: + - ./krakend/:/etc/krakend/ + command: ['run','-d','-c','/etc/krakend/krakend.json'] \ No newline at end of file diff --git a/gateways/apps/dfghjk/krakend/krakend.json b/gateways/apps/dfghjk/krakend/krakend.json new file mode 100644 index 0000000..bb3daec --- /dev/null +++ b/gateways/apps/dfghjk/krakend/krakend.json @@ -0,0 +1,386 @@ + +{ + "$schema": "https://www.krakend.io/schema/v2.5/krakend.json", + "version": 3, + "name": "Microservices-suite API Gateway", + "port": 9001, + "cache_ttl": "3600s", + "timeout": "300s", + "endpoints": [ + { + "@comment": "Check the health of all your APIs", + "endpoint": "/__suite_status", + "method": "GET", + "backend": [ + { + "host": ["http://hd:null"], + "url_pattern": "/", + "mapping": { + "message": "hd" + } + }, + + { + "host": ["http://customer-service:9000"], + "url_pattern": "/", + "mapping": { + "message": "customer-service" + } + }, + + { + "host": ["http://product-service:9002"], + "url_pattern": "/", + "mapping": { + "message": "product-service" + } + }, + + { + "host": ["http://rbac-service:9004"], + "url_pattern": "/", + "mapping": { + "message": "rbac-service" + } + }, + + { + "host": ["http://payment-service:9006"], + "url_pattern": "/", + "mapping": { + "message": "payment-service" + } + }, + + { + "host": ["http://notification-service:9007"], + "url_pattern": "/", + "mapping": { + "message": "notification-service" + } + }, + + { + "host": ["http://email-service:9008"], + "url_pattern": "/", + "mapping": { + "message": "email-service" + } + }, + + { + "host": ["http://cart-service:9009"], + "url_pattern": "/", + "mapping": { + "message": "cart-service" + } + }, + + { + "host": ["http://cart:9010"], + "url_pattern": "/", + "mapping": { + "message": "cart" + } + }, + + { + "host": ["http://user:9011"], + "url_pattern": "/", + "mapping": { + "message": "user" + } + }, + + { + "host": ["http://customer:9012"], + "url_pattern": "/", + "mapping": { + "message": "customer" + } + }, + + { + "host": ["http://email:9013"], + "url_pattern": "/", + "mapping": { + "message": "email" + } + }, + + { + "host": ["http://notification:9014"], + "url_pattern": "/", + "mapping": { + "message": "notification" + } + }, + + { + "host": ["http://payment:9015"], + "url_pattern": "/", + "mapping": { + "message": "payment" + } + }, + + { + "host": ["http://product:9016"], + "url_pattern": "/", + "mapping": { + "message": "product" + } + }, + + { + "host": ["http://rbac:9017"], + "url_pattern": "/", + "mapping": { + "message": "rbac" + } + }, + + { + "host": ["http://supplier:9018"], + "url_pattern": "/", + "mapping": { + "message": "supplier" + } + }, + + { + "host": ["http://upload:9019"], + "url_pattern": "/", + "mapping": { + "message": "upload" + } + }, + + { + "host": ["http://th:9020"], + "url_pattern": "/", + "mapping": { + "message": "th" + } + }, + + { + "host": ["http://kjhgf:9021"], + "url_pattern": "/", + "mapping": { + "message": "kjhgf" + } + }, + + { + "host": ["http://hhgfdsdfghj:9022"], + "url_pattern": "/", + "mapping": { + "message": "hhgfdsdfghj" + } + }, + + { + "host": ["http://ghjk:9023"], + "url_pattern": "/", + "mapping": { + "message": "ghjk" + } + }] + }, + { + "@comment": "Hit all API list endpoints simultaneously", + "endpoint": "/api/v1/", + "method": "GET", + "backend": [ + { + "host": ["http://hd:null"], + "url_pattern": "/api/v1/hds", + "mapping": { + "data": "hds" + } + }, + + { + "host": ["http://customer-service:9000"], + "url_pattern": "/api/v1/customer-services", + "mapping": { + "data": "customer-services" + } + }, + + { + "host": ["http://product-service:9002"], + "url_pattern": "/api/v1/product-services", + "mapping": { + "data": "product-services" + } + }, + + { + "host": ["http://rbac-service:9004"], + "url_pattern": "/api/v1/rbac-services", + "mapping": { + "data": "rbac-services" + } + }, + + { + "host": ["http://payment-service:9006"], + "url_pattern": "/api/v1/payment-services", + "mapping": { + "data": "payment-services" + } + }, + + { + "host": ["http://notification-service:9007"], + "url_pattern": "/api/v1/notification-services", + "mapping": { + "data": "notification-services" + } + }, + + { + "host": ["http://email-service:9008"], + "url_pattern": "/api/v1/email-services", + "mapping": { + "data": "email-services" + } + }, + + { + "host": ["http://cart-service:9009"], + "url_pattern": "/api/v1/cart-services", + "mapping": { + "data": "cart-services" + } + }, + + { + "host": ["http://cart:9010"], + "url_pattern": "/api/v1/carts", + "mapping": { + "data": "carts" + } + }, + + { + "host": ["http://user:9011"], + "url_pattern": "/api/v1/users", + "mapping": { + "data": "users" + } + }, + + { + "host": ["http://customer:9012"], + "url_pattern": "/api/v1/customers", + "mapping": { + "data": "customers" + } + }, + + { + "host": ["http://email:9013"], + "url_pattern": "/api/v1/emails", + "mapping": { + "data": "emails" + } + }, + + { + "host": ["http://notification:9014"], + "url_pattern": "/api/v1/notifications", + "mapping": { + "data": "notifications" + } + }, + + { + "host": ["http://payment:9015"], + "url_pattern": "/api/v1/payments", + "mapping": { + "data": "payments" + } + }, + + { + "host": ["http://product:9016"], + "url_pattern": "/api/v1/products", + "mapping": { + "data": "products" + } + }, + + { + "host": ["http://rbac:9017"], + "url_pattern": "/api/v1/rbacs", + "mapping": { + "data": "rbacs" + } + }, + + { + "host": ["http://supplier:9018"], + "url_pattern": "/api/v1/suppliers", + "mapping": { + "data": "suppliers" + } + }, + + { + "host": ["http://upload:9019"], + "url_pattern": "/api/v1/uploads", + "mapping": { + "data": "uploads" + } + }, + + { + "host": ["http://th:9020"], + "url_pattern": "/api/v1/ths", + "mapping": { + "data": "ths" + } + }, + + { + "host": ["http://kjhgf:9021"], + "url_pattern": "/api/v1/kjhgfs", + "mapping": { + "data": "kjhgfs" + } + }, + + { + "host": ["http://hhgfdsdfghj:9022"], + "url_pattern": "/api/v1/hhgfdsdfghjs", + "mapping": { + "data": "hhgfdsdfghjs" + } + }, + + { + "host": ["http://ghjk:9023"], + "url_pattern": "/api/v1/ghjks", + "mapping": { + "data": "ghjks" + } + }] + }, + { + "@comment": "Fetch all data from the hd service", + "endpoint": "/api/v1/hds", + "method": "GET", + "backend": [ + { + "host": ["http://hd:null"], + "url_pattern": "/api/v1/hds", + "mapping": { + "data": "hds" + } + }] + } + ] +} \ No newline at end of file diff --git a/gateways/apps/dfghjk/nginx/Dockerfile b/gateways/apps/dfghjk/nginx/Dockerfile new file mode 100644 index 0000000..ddf7281 --- /dev/null +++ b/gateways/apps/dfghjk/nginx/Dockerfile @@ -0,0 +1,3 @@ + +FROM nginx +COPY ./default.conf /etc/nginx/conf.d/default.conf \ No newline at end of file diff --git a/gateways/apps/dfghjk/nginx/Dockerfile.dev b/gateways/apps/dfghjk/nginx/Dockerfile.dev new file mode 100644 index 0000000..ddf7281 --- /dev/null +++ b/gateways/apps/dfghjk/nginx/Dockerfile.dev @@ -0,0 +1,3 @@ + +FROM nginx +COPY ./default.conf /etc/nginx/conf.d/default.conf \ No newline at end of file diff --git a/gateways/apps/dfghjk/nginx/default.conf b/gateways/apps/dfghjk/nginx/default.conf new file mode 100644 index 0000000..b25033b --- /dev/null +++ b/gateways/apps/dfghjk/nginx/default.conf @@ -0,0 +1,270 @@ + + +upstream hd_upstream { + server hd:null; +} + +upstream customer-service_upstream { + server customer-service:9000; +} + +upstream product-service_upstream { + server product-service:9002; +} + +upstream rbac-service_upstream { + server rbac-service:9004; +} + +upstream payment-service_upstream { + server payment-service:9006; +} + +upstream notification-service_upstream { + server notification-service:9007; +} + +upstream email-service_upstream { + server email-service:9008; +} + +upstream cart-service_upstream { + server cart-service:9009; +} + +upstream cart_upstream { + server cart:9010; +} + +upstream user_upstream { + server user:9011; +} + +upstream customer_upstream { + server customer:9012; +} + +upstream email_upstream { + server email:9013; +} + +upstream notification_upstream { + server notification:9014; +} + +upstream payment_upstream { + server payment:9015; +} + +upstream product_upstream { + server product:9016; +} + +upstream rbac_upstream { + server rbac:9017; +} + +upstream supplier_upstream { + server supplier:9018; +} + +upstream upload_upstream { + server upload:9019; +} + +upstream th_upstream { + server th:9020; +} + +upstream kjhgf_upstream { + server kjhgf:9021; +} + +upstream hhgfdsdfghj_upstream { + server hhgfdsdfghj:9022; +} + +upstream ghjk_upstream { + server ghjk:9023; +} + +server { + listen 80; + + + location /api/v1/hds { + proxy_pass http://hd_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/customer-services { + proxy_pass http://customer-service_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/product-services { + proxy_pass http://product-service_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/rbac-services { + proxy_pass http://rbac-service_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/payment-services { + proxy_pass http://payment-service_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/notification-services { + proxy_pass http://notification-service_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/email-services { + proxy_pass http://email-service_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/cart-services { + proxy_pass http://cart-service_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/carts { + proxy_pass http://cart_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/users { + proxy_pass http://user_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/customers { + proxy_pass http://customer_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/emails { + proxy_pass http://email_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/notifications { + proxy_pass http://notification_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/payments { + proxy_pass http://payment_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/products { + proxy_pass http://product_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/rbacs { + proxy_pass http://rbac_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/suppliers { + proxy_pass http://supplier_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/uploads { + proxy_pass http://upload_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/ths { + proxy_pass http://th_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/kjhgfs { + proxy_pass http://kjhgf_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/hhgfdsdfghjs { + proxy_pass http://hhgfdsdfghj_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/ghjks { + proxy_pass http://ghjk_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } +} \ No newline at end of file diff --git a/gateways/apps/dkgl/docker-compose.dev.yml b/gateways/apps/dkgl/docker-compose.dev.yml new file mode 100644 index 0000000..2e403c2 --- /dev/null +++ b/gateways/apps/dkgl/docker-compose.dev.yml @@ -0,0 +1,367 @@ + +version: '3.8' +services: + + hd: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/hd + ports: + - "null:null" + volumes: + - /app/node_modules + - ../../../microservices/hd:/app + depends_on: + rabbitmq: + condition: service_healthy + + customer-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/customer-service + ports: + - "9000:9000" + volumes: + - /app/node_modules + - ../../../microservices/customer-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + product-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/product-service + ports: + - "9002:9002" + volumes: + - /app/node_modules + - ../../../microservices/product-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + rbac-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/rbac-service + ports: + - "9004:9004" + volumes: + - /app/node_modules + - ../../../microservices/rbac-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + payment-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/payment-service + ports: + - "9006:9006" + volumes: + - /app/node_modules + - ../../../microservices/payment-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + notification-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/notification-service + ports: + - "9007:9007" + volumes: + - /app/node_modules + - ../../../microservices/notification-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + email-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/email-service + ports: + - "9008:9008" + volumes: + - /app/node_modules + - ../../../microservices/email-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + cart-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/cart-service + ports: + - "9009:9009" + volumes: + - /app/node_modules + - ../../../microservices/cart-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + cart: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/cart + ports: + - "9010:9010" + volumes: + - /app/node_modules + - ../../../microservices/cart:/app + depends_on: + rabbitmq: + condition: service_healthy + + user: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/user + ports: + - "9011:9011" + volumes: + - /app/node_modules + - ../../../microservices/user:/app + depends_on: + rabbitmq: + condition: service_healthy + + customer: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/customer + ports: + - "9012:9012" + volumes: + - /app/node_modules + - ../../../microservices/customer:/app + depends_on: + rabbitmq: + condition: service_healthy + + email: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/email + ports: + - "9013:9013" + volumes: + - /app/node_modules + - ../../../microservices/email:/app + depends_on: + rabbitmq: + condition: service_healthy + + notification: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/notification + ports: + - "9014:9014" + volumes: + - /app/node_modules + - ../../../microservices/notification:/app + depends_on: + rabbitmq: + condition: service_healthy + + payment: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/payment + ports: + - "9015:9015" + volumes: + - /app/node_modules + - ../../../microservices/payment:/app + depends_on: + rabbitmq: + condition: service_healthy + + product: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/product + ports: + - "9016:9016" + volumes: + - /app/node_modules + - ../../../microservices/product:/app + depends_on: + rabbitmq: + condition: service_healthy + + rbac: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/rbac + ports: + - "9017:9017" + volumes: + - /app/node_modules + - ../../../microservices/rbac:/app + depends_on: + rabbitmq: + condition: service_healthy + + supplier: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/supplier + ports: + - "9018:9018" + volumes: + - /app/node_modules + - ../../../microservices/supplier:/app + depends_on: + rabbitmq: + condition: service_healthy + + upload: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/upload + ports: + - "9019:9019" + volumes: + - /app/node_modules + - ../../../microservices/upload:/app + depends_on: + rabbitmq: + condition: service_healthy + + th: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/th + ports: + - "9020:9020" + volumes: + - /app/node_modules + - ../../../microservices/th:/app + depends_on: + rabbitmq: + condition: service_healthy + + kjhgf: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/kjhgf + ports: + - "9021:9021" + volumes: + - /app/node_modules + - ../../../microservices/kjhgf:/app + depends_on: + rabbitmq: + condition: service_healthy + + hhgfdsdfghj: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/hhgfdsdfghj + ports: + - "9022:9022" + volumes: + - /app/node_modules + - ../../../microservices/hhgfdsdfghj:/app + depends_on: + rabbitmq: + condition: service_healthy + + ghjk: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/ghjk + ports: + - "9023:9023" + volumes: + - /app/node_modules + - ../../../microservices/ghjk:/app + depends_on: + rabbitmq: + condition: service_healthy + + shjksgd: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/shjksgd + ports: + - "30067:30067" + volumes: + - /app/node_modules + - ../../../microservices/shjksgd:/app + depends_on: + rabbitmq: + condition: service_healthy + + nginx: + depends_on: + - hd + - customer-service + - product-service + - rbac-service + - payment-service + - notification-service + - email-service + - cart-service + - cart + - user + - customer + - email + - notification + - payment + - product + - rbac + - supplier + - upload + - th + - kjhgf + - hhgfdsdfghj + - ghjk + - shjksgd + restart: always + build: + context: ./nginx + dockerfile: Dockerfile.dev + ports: + - '4000:80' + healthcheck: + test: ["CMD-SHELL", "curl -f http://localhost:80/health || exit 1"] + interval: 30s + timeout: 10s + retries: 3 + start_period: 40s + rabbitmq: + image: rabbitmq:3.13-management + container_name: rabbitmq + ports: + - '5672:5672' + - '15672:15672' + healthcheck: + test: ["CMD", "rabbitmq-diagnostics", "ping"] + interval: 30s + retries: 5 + mongodb: + image: mongo + ports: + - '27017:27017' + restart: always + volumes: + - type: bind + source: ./data + target: /data/db + krakend: + image: devopsfaith/krakend:2.7-watch + ports: + - '9000:9000' + - '8090:8090' + volumes: + - ./krakend/:/etc/krakend/ + command: ['run','-d','-c','/etc/krakend/krakend.json'] \ No newline at end of file diff --git a/gateways/apps/dkgl/docker-compose.yml b/gateways/apps/dkgl/docker-compose.yml new file mode 100644 index 0000000..f33baeb --- /dev/null +++ b/gateways/apps/dkgl/docker-compose.yml @@ -0,0 +1,367 @@ + +version: '3.8' +services: + + hd: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/hd + ports: + - "null:null" + volumes: + - /app/node_modules + - ../../../microservices/hd:/app + depends_on: + rabbitmq: + condition: service_healthy + + customer-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/customer-service + ports: + - "9000:9000" + volumes: + - /app/node_modules + - ../../../microservices/customer-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + product-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/product-service + ports: + - "9002:9002" + volumes: + - /app/node_modules + - ../../../microservices/product-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + rbac-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/rbac-service + ports: + - "9004:9004" + volumes: + - /app/node_modules + - ../../../microservices/rbac-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + payment-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/payment-service + ports: + - "9006:9006" + volumes: + - /app/node_modules + - ../../../microservices/payment-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + notification-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/notification-service + ports: + - "9007:9007" + volumes: + - /app/node_modules + - ../../../microservices/notification-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + email-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/email-service + ports: + - "9008:9008" + volumes: + - /app/node_modules + - ../../../microservices/email-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + cart-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/cart-service + ports: + - "9009:9009" + volumes: + - /app/node_modules + - ../../../microservices/cart-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + cart: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/cart + ports: + - "9010:9010" + volumes: + - /app/node_modules + - ../../../microservices/cart:/app + depends_on: + rabbitmq: + condition: service_healthy + + user: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/user + ports: + - "9011:9011" + volumes: + - /app/node_modules + - ../../../microservices/user:/app + depends_on: + rabbitmq: + condition: service_healthy + + customer: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/customer + ports: + - "9012:9012" + volumes: + - /app/node_modules + - ../../../microservices/customer:/app + depends_on: + rabbitmq: + condition: service_healthy + + email: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/email + ports: + - "9013:9013" + volumes: + - /app/node_modules + - ../../../microservices/email:/app + depends_on: + rabbitmq: + condition: service_healthy + + notification: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/notification + ports: + - "9014:9014" + volumes: + - /app/node_modules + - ../../../microservices/notification:/app + depends_on: + rabbitmq: + condition: service_healthy + + payment: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/payment + ports: + - "9015:9015" + volumes: + - /app/node_modules + - ../../../microservices/payment:/app + depends_on: + rabbitmq: + condition: service_healthy + + product: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/product + ports: + - "9016:9016" + volumes: + - /app/node_modules + - ../../../microservices/product:/app + depends_on: + rabbitmq: + condition: service_healthy + + rbac: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/rbac + ports: + - "9017:9017" + volumes: + - /app/node_modules + - ../../../microservices/rbac:/app + depends_on: + rabbitmq: + condition: service_healthy + + supplier: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/supplier + ports: + - "9018:9018" + volumes: + - /app/node_modules + - ../../../microservices/supplier:/app + depends_on: + rabbitmq: + condition: service_healthy + + upload: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/upload + ports: + - "9019:9019" + volumes: + - /app/node_modules + - ../../../microservices/upload:/app + depends_on: + rabbitmq: + condition: service_healthy + + th: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/th + ports: + - "9020:9020" + volumes: + - /app/node_modules + - ../../../microservices/th:/app + depends_on: + rabbitmq: + condition: service_healthy + + kjhgf: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/kjhgf + ports: + - "9021:9021" + volumes: + - /app/node_modules + - ../../../microservices/kjhgf:/app + depends_on: + rabbitmq: + condition: service_healthy + + hhgfdsdfghj: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/hhgfdsdfghj + ports: + - "9022:9022" + volumes: + - /app/node_modules + - ../../../microservices/hhgfdsdfghj:/app + depends_on: + rabbitmq: + condition: service_healthy + + ghjk: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/ghjk + ports: + - "9023:9023" + volumes: + - /app/node_modules + - ../../../microservices/ghjk:/app + depends_on: + rabbitmq: + condition: service_healthy + + shjksgd: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/shjksgd + ports: + - "30067:30067" + volumes: + - /app/node_modules + - ../../../microservices/shjksgd:/app + depends_on: + rabbitmq: + condition: service_healthy + + nginx: + depends_on: + - hd + - customer-service + - product-service + - rbac-service + - payment-service + - notification-service + - email-service + - cart-service + - cart + - user + - customer + - email + - notification + - payment + - product + - rbac + - supplier + - upload + - th + - kjhgf + - hhgfdsdfghj + - ghjk + - shjksgd + restart: always + build: + context: ./nginx + dockerfile: Dockerfile.dev + ports: + - '4000:80' + healthcheck: + test: ["CMD-SHELL", "curl -f http://localhost:80/health || exit 1"] + interval: 30s + timeout: 10s + retries: 3 + start_period: 40s + rabbitmq: + image: rabbitmq:3.13-management + container_name: rabbitmq + ports: + - '5672:5672' + - '15672:15672' + healthcheck: + test: ["CMD", "rabbitmq-diagnostics", "ping"] + interval: 30s + retries: 5 + mongodb: + image: mongo + ports: + - '27017:27017' + restart: always + volumes: + - type: bind + source: ./data + target: /data/db + krakend: + image: devopsfaith/krakend:2.7 + ports: + - '9000:9000' + - '8090:8090' + volumes: + - ./krakend/:/etc/krakend/ + command: ['run','-d','-c','/etc/krakend/krakend.json'] \ No newline at end of file diff --git a/gateways/apps/dkgl/krakend/krakend.json b/gateways/apps/dkgl/krakend/krakend.json new file mode 100644 index 0000000..5e3320a --- /dev/null +++ b/gateways/apps/dkgl/krakend/krakend.json @@ -0,0 +1,402 @@ + +{ + "$schema": "https://www.krakend.io/schema/v2.5/krakend.json", + "version": 3, + "name": "Microservices-suite API Gateway", + "port": 9000, + "cache_ttl": "3600s", + "timeout": "300s", + "endpoints": [ + { + "@comment": "Check the health of all your APIs", + "endpoint": "/__suite_status", + "method": "GET", + "backend": [ + { + "host": ["http://hd:null"], + "url_pattern": "/", + "mapping": { + "message": "hd" + } + }, + + { + "host": ["http://customer-service:9000"], + "url_pattern": "/", + "mapping": { + "message": "customer-service" + } + }, + + { + "host": ["http://product-service:9002"], + "url_pattern": "/", + "mapping": { + "message": "product-service" + } + }, + + { + "host": ["http://rbac-service:9004"], + "url_pattern": "/", + "mapping": { + "message": "rbac-service" + } + }, + + { + "host": ["http://payment-service:9006"], + "url_pattern": "/", + "mapping": { + "message": "payment-service" + } + }, + + { + "host": ["http://notification-service:9007"], + "url_pattern": "/", + "mapping": { + "message": "notification-service" + } + }, + + { + "host": ["http://email-service:9008"], + "url_pattern": "/", + "mapping": { + "message": "email-service" + } + }, + + { + "host": ["http://cart-service:9009"], + "url_pattern": "/", + "mapping": { + "message": "cart-service" + } + }, + + { + "host": ["http://cart:9010"], + "url_pattern": "/", + "mapping": { + "message": "cart" + } + }, + + { + "host": ["http://user:9011"], + "url_pattern": "/", + "mapping": { + "message": "user" + } + }, + + { + "host": ["http://customer:9012"], + "url_pattern": "/", + "mapping": { + "message": "customer" + } + }, + + { + "host": ["http://email:9013"], + "url_pattern": "/", + "mapping": { + "message": "email" + } + }, + + { + "host": ["http://notification:9014"], + "url_pattern": "/", + "mapping": { + "message": "notification" + } + }, + + { + "host": ["http://payment:9015"], + "url_pattern": "/", + "mapping": { + "message": "payment" + } + }, + + { + "host": ["http://product:9016"], + "url_pattern": "/", + "mapping": { + "message": "product" + } + }, + + { + "host": ["http://rbac:9017"], + "url_pattern": "/", + "mapping": { + "message": "rbac" + } + }, + + { + "host": ["http://supplier:9018"], + "url_pattern": "/", + "mapping": { + "message": "supplier" + } + }, + + { + "host": ["http://upload:9019"], + "url_pattern": "/", + "mapping": { + "message": "upload" + } + }, + + { + "host": ["http://th:9020"], + "url_pattern": "/", + "mapping": { + "message": "th" + } + }, + + { + "host": ["http://kjhgf:9021"], + "url_pattern": "/", + "mapping": { + "message": "kjhgf" + } + }, + + { + "host": ["http://hhgfdsdfghj:9022"], + "url_pattern": "/", + "mapping": { + "message": "hhgfdsdfghj" + } + }, + + { + "host": ["http://ghjk:9023"], + "url_pattern": "/", + "mapping": { + "message": "ghjk" + } + }, + + { + "host": ["http://shjksgd:30067"], + "url_pattern": "/", + "mapping": { + "message": "shjksgd" + } + }] + }, + { + "@comment": "Hit all API list endpoints simultaneously", + "endpoint": "/api/v1/", + "method": "GET", + "backend": [ + { + "host": ["http://hd:null"], + "url_pattern": "/api/v1/hds", + "mapping": { + "data": "hds" + } + }, + + { + "host": ["http://customer-service:9000"], + "url_pattern": "/api/v1/customer-services", + "mapping": { + "data": "customer-services" + } + }, + + { + "host": ["http://product-service:9002"], + "url_pattern": "/api/v1/product-services", + "mapping": { + "data": "product-services" + } + }, + + { + "host": ["http://rbac-service:9004"], + "url_pattern": "/api/v1/rbac-services", + "mapping": { + "data": "rbac-services" + } + }, + + { + "host": ["http://payment-service:9006"], + "url_pattern": "/api/v1/payment-services", + "mapping": { + "data": "payment-services" + } + }, + + { + "host": ["http://notification-service:9007"], + "url_pattern": "/api/v1/notification-services", + "mapping": { + "data": "notification-services" + } + }, + + { + "host": ["http://email-service:9008"], + "url_pattern": "/api/v1/email-services", + "mapping": { + "data": "email-services" + } + }, + + { + "host": ["http://cart-service:9009"], + "url_pattern": "/api/v1/cart-services", + "mapping": { + "data": "cart-services" + } + }, + + { + "host": ["http://cart:9010"], + "url_pattern": "/api/v1/carts", + "mapping": { + "data": "carts" + } + }, + + { + "host": ["http://user:9011"], + "url_pattern": "/api/v1/users", + "mapping": { + "data": "users" + } + }, + + { + "host": ["http://customer:9012"], + "url_pattern": "/api/v1/customers", + "mapping": { + "data": "customers" + } + }, + + { + "host": ["http://email:9013"], + "url_pattern": "/api/v1/emails", + "mapping": { + "data": "emails" + } + }, + + { + "host": ["http://notification:9014"], + "url_pattern": "/api/v1/notifications", + "mapping": { + "data": "notifications" + } + }, + + { + "host": ["http://payment:9015"], + "url_pattern": "/api/v1/payments", + "mapping": { + "data": "payments" + } + }, + + { + "host": ["http://product:9016"], + "url_pattern": "/api/v1/products", + "mapping": { + "data": "products" + } + }, + + { + "host": ["http://rbac:9017"], + "url_pattern": "/api/v1/rbacs", + "mapping": { + "data": "rbacs" + } + }, + + { + "host": ["http://supplier:9018"], + "url_pattern": "/api/v1/suppliers", + "mapping": { + "data": "suppliers" + } + }, + + { + "host": ["http://upload:9019"], + "url_pattern": "/api/v1/uploads", + "mapping": { + "data": "uploads" + } + }, + + { + "host": ["http://th:9020"], + "url_pattern": "/api/v1/ths", + "mapping": { + "data": "ths" + } + }, + + { + "host": ["http://kjhgf:9021"], + "url_pattern": "/api/v1/kjhgfs", + "mapping": { + "data": "kjhgfs" + } + }, + + { + "host": ["http://hhgfdsdfghj:9022"], + "url_pattern": "/api/v1/hhgfdsdfghjs", + "mapping": { + "data": "hhgfdsdfghjs" + } + }, + + { + "host": ["http://ghjk:9023"], + "url_pattern": "/api/v1/ghjks", + "mapping": { + "data": "ghjks" + } + }, + + { + "host": ["http://shjksgd:30067"], + "url_pattern": "/api/v1/shjksgds", + "mapping": { + "data": "shjksgds" + } + }] + }, + { + "@comment": "Fetch all data from the hd service", + "endpoint": "/api/v1/hds", + "method": "GET", + "backend": [ + { + "host": ["http://hd:null"], + "url_pattern": "/api/v1/hds", + "mapping": { + "data": "hds" + } + }] + } + ] +} \ No newline at end of file diff --git a/gateways/apps/dkgl/nginx/Dockerfile b/gateways/apps/dkgl/nginx/Dockerfile new file mode 100644 index 0000000..ddf7281 --- /dev/null +++ b/gateways/apps/dkgl/nginx/Dockerfile @@ -0,0 +1,3 @@ + +FROM nginx +COPY ./default.conf /etc/nginx/conf.d/default.conf \ No newline at end of file diff --git a/gateways/apps/dkgl/nginx/Dockerfile.dev b/gateways/apps/dkgl/nginx/Dockerfile.dev new file mode 100644 index 0000000..ddf7281 --- /dev/null +++ b/gateways/apps/dkgl/nginx/Dockerfile.dev @@ -0,0 +1,3 @@ + +FROM nginx +COPY ./default.conf /etc/nginx/conf.d/default.conf \ No newline at end of file diff --git a/gateways/apps/dkgl/nginx/default.conf b/gateways/apps/dkgl/nginx/default.conf new file mode 100644 index 0000000..d4dace0 --- /dev/null +++ b/gateways/apps/dkgl/nginx/default.conf @@ -0,0 +1,282 @@ + + +upstream hd_upstream { + server hd:null; +} + +upstream customer-service_upstream { + server customer-service:9000; +} + +upstream product-service_upstream { + server product-service:9002; +} + +upstream rbac-service_upstream { + server rbac-service:9004; +} + +upstream payment-service_upstream { + server payment-service:9006; +} + +upstream notification-service_upstream { + server notification-service:9007; +} + +upstream email-service_upstream { + server email-service:9008; +} + +upstream cart-service_upstream { + server cart-service:9009; +} + +upstream cart_upstream { + server cart:9010; +} + +upstream user_upstream { + server user:9011; +} + +upstream customer_upstream { + server customer:9012; +} + +upstream email_upstream { + server email:9013; +} + +upstream notification_upstream { + server notification:9014; +} + +upstream payment_upstream { + server payment:9015; +} + +upstream product_upstream { + server product:9016; +} + +upstream rbac_upstream { + server rbac:9017; +} + +upstream supplier_upstream { + server supplier:9018; +} + +upstream upload_upstream { + server upload:9019; +} + +upstream th_upstream { + server th:9020; +} + +upstream kjhgf_upstream { + server kjhgf:9021; +} + +upstream hhgfdsdfghj_upstream { + server hhgfdsdfghj:9022; +} + +upstream ghjk_upstream { + server ghjk:9023; +} + +upstream shjksgd_upstream { + server shjksgd:30067; +} + +server { + listen 80; + + + location /api/v1/hds { + proxy_pass http://hd_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/customer-services { + proxy_pass http://customer-service_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/product-services { + proxy_pass http://product-service_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/rbac-services { + proxy_pass http://rbac-service_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/payment-services { + proxy_pass http://payment-service_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/notification-services { + proxy_pass http://notification-service_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/email-services { + proxy_pass http://email-service_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/cart-services { + proxy_pass http://cart-service_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/carts { + proxy_pass http://cart_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/users { + proxy_pass http://user_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/customers { + proxy_pass http://customer_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/emails { + proxy_pass http://email_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/notifications { + proxy_pass http://notification_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/payments { + proxy_pass http://payment_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/products { + proxy_pass http://product_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/rbacs { + proxy_pass http://rbac_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/suppliers { + proxy_pass http://supplier_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/uploads { + proxy_pass http://upload_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/ths { + proxy_pass http://th_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/kjhgfs { + proxy_pass http://kjhgf_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/hhgfdsdfghjs { + proxy_pass http://hhgfdsdfghj_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/ghjks { + proxy_pass http://ghjk_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/shjksgds { + proxy_pass http://shjksgd_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } +} \ No newline at end of file diff --git a/gateways/apps/dnmw/docker-compose.dev.yml b/gateways/apps/dnmw/docker-compose.dev.yml new file mode 100644 index 0000000..8f4f751 --- /dev/null +++ b/gateways/apps/dnmw/docker-compose.dev.yml @@ -0,0 +1,367 @@ + +version: '3.8' +services: + + hd: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/hd + ports: + - "null:null" + volumes: + - /app/node_modules + - ../../../microservices/hd:/app + depends_on: + rabbitmq: + condition: service_healthy + + customer-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/customer-service + ports: + - "9000:9000" + volumes: + - /app/node_modules + - ../../../microservices/customer-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + product-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/product-service + ports: + - "9002:9002" + volumes: + - /app/node_modules + - ../../../microservices/product-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + rbac-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/rbac-service + ports: + - "9004:9004" + volumes: + - /app/node_modules + - ../../../microservices/rbac-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + payment-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/payment-service + ports: + - "9006:9006" + volumes: + - /app/node_modules + - ../../../microservices/payment-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + notification-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/notification-service + ports: + - "9007:9007" + volumes: + - /app/node_modules + - ../../../microservices/notification-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + email-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/email-service + ports: + - "9008:9008" + volumes: + - /app/node_modules + - ../../../microservices/email-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + cart-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/cart-service + ports: + - "9009:9009" + volumes: + - /app/node_modules + - ../../../microservices/cart-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + cart: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/cart + ports: + - "9010:9010" + volumes: + - /app/node_modules + - ../../../microservices/cart:/app + depends_on: + rabbitmq: + condition: service_healthy + + user: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/user + ports: + - "9011:9011" + volumes: + - /app/node_modules + - ../../../microservices/user:/app + depends_on: + rabbitmq: + condition: service_healthy + + customer: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/customer + ports: + - "9012:9012" + volumes: + - /app/node_modules + - ../../../microservices/customer:/app + depends_on: + rabbitmq: + condition: service_healthy + + email: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/email + ports: + - "9013:9013" + volumes: + - /app/node_modules + - ../../../microservices/email:/app + depends_on: + rabbitmq: + condition: service_healthy + + notification: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/notification + ports: + - "9014:9014" + volumes: + - /app/node_modules + - ../../../microservices/notification:/app + depends_on: + rabbitmq: + condition: service_healthy + + payment: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/payment + ports: + - "9015:9015" + volumes: + - /app/node_modules + - ../../../microservices/payment:/app + depends_on: + rabbitmq: + condition: service_healthy + + product: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/product + ports: + - "9016:9016" + volumes: + - /app/node_modules + - ../../../microservices/product:/app + depends_on: + rabbitmq: + condition: service_healthy + + rbac: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/rbac + ports: + - "9017:9017" + volumes: + - /app/node_modules + - ../../../microservices/rbac:/app + depends_on: + rabbitmq: + condition: service_healthy + + supplier: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/supplier + ports: + - "9018:9018" + volumes: + - /app/node_modules + - ../../../microservices/supplier:/app + depends_on: + rabbitmq: + condition: service_healthy + + upload: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/upload + ports: + - "9019:9019" + volumes: + - /app/node_modules + - ../../../microservices/upload:/app + depends_on: + rabbitmq: + condition: service_healthy + + th: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/th + ports: + - "9020:9020" + volumes: + - /app/node_modules + - ../../../microservices/th:/app + depends_on: + rabbitmq: + condition: service_healthy + + kjhgf: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/kjhgf + ports: + - "9021:9021" + volumes: + - /app/node_modules + - ../../../microservices/kjhgf:/app + depends_on: + rabbitmq: + condition: service_healthy + + hhgfdsdfghj: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/hhgfdsdfghj + ports: + - "9022:9022" + volumes: + - /app/node_modules + - ../../../microservices/hhgfdsdfghj:/app + depends_on: + rabbitmq: + condition: service_healthy + + ghjk: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/ghjk + ports: + - "9023:9023" + volumes: + - /app/node_modules + - ../../../microservices/ghjk:/app + depends_on: + rabbitmq: + condition: service_healthy + + shjksgd: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/shjksgd + ports: + - "30067:30067" + volumes: + - /app/node_modules + - ../../../microservices/shjksgd:/app + depends_on: + rabbitmq: + condition: service_healthy + + nginx: + depends_on: + - hd + - customer-service + - product-service + - rbac-service + - payment-service + - notification-service + - email-service + - cart-service + - cart + - user + - customer + - email + - notification + - payment + - product + - rbac + - supplier + - upload + - th + - kjhgf + - hhgfdsdfghj + - ghjk + - shjksgd + restart: always + build: + context: ./nginx + dockerfile: Dockerfile.dev + ports: + - '4000:80' + healthcheck: + test: ["CMD-SHELL", "curl -f http://localhost:80/health || exit 1"] + interval: 30s + timeout: 10s + retries: 3 + start_period: 40s + rabbitmq: + image: rabbitmq:3.13-management + container_name: rabbitmq + ports: + - '5672:5672' + - '15672:15672' + healthcheck: + test: ["CMD", "rabbitmq-diagnostics", "ping"] + interval: 30s + retries: 5 + mongodb: + image: mongo + ports: + - '27017:27017' + restart: always + volumes: + - type: bind + source: ./data + target: /data/db + krakend: + image: devopsfaith/krakend:2.7-watch + ports: + - '8080:8080' + - '8090:8090' + volumes: + - ./krakend/:/etc/krakend/ + command: ['run','-d','-c','/etc/krakend/krakend.json'] \ No newline at end of file diff --git a/gateways/apps/dnmw/docker-compose.yml b/gateways/apps/dnmw/docker-compose.yml new file mode 100644 index 0000000..97e3b67 --- /dev/null +++ b/gateways/apps/dnmw/docker-compose.yml @@ -0,0 +1,367 @@ + +version: '3.8' +services: + + hd: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/hd + ports: + - "null:null" + volumes: + - /app/node_modules + - ../../../microservices/hd:/app + depends_on: + rabbitmq: + condition: service_healthy + + customer-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/customer-service + ports: + - "9000:9000" + volumes: + - /app/node_modules + - ../../../microservices/customer-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + product-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/product-service + ports: + - "9002:9002" + volumes: + - /app/node_modules + - ../../../microservices/product-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + rbac-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/rbac-service + ports: + - "9004:9004" + volumes: + - /app/node_modules + - ../../../microservices/rbac-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + payment-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/payment-service + ports: + - "9006:9006" + volumes: + - /app/node_modules + - ../../../microservices/payment-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + notification-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/notification-service + ports: + - "9007:9007" + volumes: + - /app/node_modules + - ../../../microservices/notification-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + email-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/email-service + ports: + - "9008:9008" + volumes: + - /app/node_modules + - ../../../microservices/email-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + cart-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/cart-service + ports: + - "9009:9009" + volumes: + - /app/node_modules + - ../../../microservices/cart-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + cart: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/cart + ports: + - "9010:9010" + volumes: + - /app/node_modules + - ../../../microservices/cart:/app + depends_on: + rabbitmq: + condition: service_healthy + + user: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/user + ports: + - "9011:9011" + volumes: + - /app/node_modules + - ../../../microservices/user:/app + depends_on: + rabbitmq: + condition: service_healthy + + customer: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/customer + ports: + - "9012:9012" + volumes: + - /app/node_modules + - ../../../microservices/customer:/app + depends_on: + rabbitmq: + condition: service_healthy + + email: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/email + ports: + - "9013:9013" + volumes: + - /app/node_modules + - ../../../microservices/email:/app + depends_on: + rabbitmq: + condition: service_healthy + + notification: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/notification + ports: + - "9014:9014" + volumes: + - /app/node_modules + - ../../../microservices/notification:/app + depends_on: + rabbitmq: + condition: service_healthy + + payment: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/payment + ports: + - "9015:9015" + volumes: + - /app/node_modules + - ../../../microservices/payment:/app + depends_on: + rabbitmq: + condition: service_healthy + + product: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/product + ports: + - "9016:9016" + volumes: + - /app/node_modules + - ../../../microservices/product:/app + depends_on: + rabbitmq: + condition: service_healthy + + rbac: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/rbac + ports: + - "9017:9017" + volumes: + - /app/node_modules + - ../../../microservices/rbac:/app + depends_on: + rabbitmq: + condition: service_healthy + + supplier: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/supplier + ports: + - "9018:9018" + volumes: + - /app/node_modules + - ../../../microservices/supplier:/app + depends_on: + rabbitmq: + condition: service_healthy + + upload: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/upload + ports: + - "9019:9019" + volumes: + - /app/node_modules + - ../../../microservices/upload:/app + depends_on: + rabbitmq: + condition: service_healthy + + th: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/th + ports: + - "9020:9020" + volumes: + - /app/node_modules + - ../../../microservices/th:/app + depends_on: + rabbitmq: + condition: service_healthy + + kjhgf: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/kjhgf + ports: + - "9021:9021" + volumes: + - /app/node_modules + - ../../../microservices/kjhgf:/app + depends_on: + rabbitmq: + condition: service_healthy + + hhgfdsdfghj: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/hhgfdsdfghj + ports: + - "9022:9022" + volumes: + - /app/node_modules + - ../../../microservices/hhgfdsdfghj:/app + depends_on: + rabbitmq: + condition: service_healthy + + ghjk: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/ghjk + ports: + - "9023:9023" + volumes: + - /app/node_modules + - ../../../microservices/ghjk:/app + depends_on: + rabbitmq: + condition: service_healthy + + shjksgd: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/shjksgd + ports: + - "30067:30067" + volumes: + - /app/node_modules + - ../../../microservices/shjksgd:/app + depends_on: + rabbitmq: + condition: service_healthy + + nginx: + depends_on: + - hd + - customer-service + - product-service + - rbac-service + - payment-service + - notification-service + - email-service + - cart-service + - cart + - user + - customer + - email + - notification + - payment + - product + - rbac + - supplier + - upload + - th + - kjhgf + - hhgfdsdfghj + - ghjk + - shjksgd + restart: always + build: + context: ./nginx + dockerfile: Dockerfile.dev + ports: + - '4000:80' + healthcheck: + test: ["CMD-SHELL", "curl -f http://localhost:80/health || exit 1"] + interval: 30s + timeout: 10s + retries: 3 + start_period: 40s + rabbitmq: + image: rabbitmq:3.13-management + container_name: rabbitmq + ports: + - '5672:5672' + - '15672:15672' + healthcheck: + test: ["CMD", "rabbitmq-diagnostics", "ping"] + interval: 30s + retries: 5 + mongodb: + image: mongo + ports: + - '27017:27017' + restart: always + volumes: + - type: bind + source: ./data + target: /data/db + krakend: + image: devopsfaith/krakend:2.7 + ports: + - '8080:8080' + - '8090:8090' + volumes: + - ./krakend/:/etc/krakend/ + command: ['run','-d','-c','/etc/krakend/krakend.json'] \ No newline at end of file diff --git a/gateways/apps/dnmw/krakend/krakend.json b/gateways/apps/dnmw/krakend/krakend.json new file mode 100644 index 0000000..89d801a --- /dev/null +++ b/gateways/apps/dnmw/krakend/krakend.json @@ -0,0 +1,402 @@ + +{ + "$schema": "https://www.krakend.io/schema/v2.5/krakend.json", + "version": 3, + "name": "Microservices-suite API Gateway", + "port": 8080, + "cache_ttl": "3600s", + "timeout": "300s", + "endpoints": [ + { + "@comment": "Check the health of all your APIs", + "endpoint": "/__suite_status", + "method": "GET", + "backend": [ + { + "host": ["http://hd:null"], + "url_pattern": "/", + "mapping": { + "message": "hd" + } + }, + + { + "host": ["http://customer-service:9000"], + "url_pattern": "/", + "mapping": { + "message": "customer-service" + } + }, + + { + "host": ["http://product-service:9002"], + "url_pattern": "/", + "mapping": { + "message": "product-service" + } + }, + + { + "host": ["http://rbac-service:9004"], + "url_pattern": "/", + "mapping": { + "message": "rbac-service" + } + }, + + { + "host": ["http://payment-service:9006"], + "url_pattern": "/", + "mapping": { + "message": "payment-service" + } + }, + + { + "host": ["http://notification-service:9007"], + "url_pattern": "/", + "mapping": { + "message": "notification-service" + } + }, + + { + "host": ["http://email-service:9008"], + "url_pattern": "/", + "mapping": { + "message": "email-service" + } + }, + + { + "host": ["http://cart-service:9009"], + "url_pattern": "/", + "mapping": { + "message": "cart-service" + } + }, + + { + "host": ["http://cart:9010"], + "url_pattern": "/", + "mapping": { + "message": "cart" + } + }, + + { + "host": ["http://user:9011"], + "url_pattern": "/", + "mapping": { + "message": "user" + } + }, + + { + "host": ["http://customer:9012"], + "url_pattern": "/", + "mapping": { + "message": "customer" + } + }, + + { + "host": ["http://email:9013"], + "url_pattern": "/", + "mapping": { + "message": "email" + } + }, + + { + "host": ["http://notification:9014"], + "url_pattern": "/", + "mapping": { + "message": "notification" + } + }, + + { + "host": ["http://payment:9015"], + "url_pattern": "/", + "mapping": { + "message": "payment" + } + }, + + { + "host": ["http://product:9016"], + "url_pattern": "/", + "mapping": { + "message": "product" + } + }, + + { + "host": ["http://rbac:9017"], + "url_pattern": "/", + "mapping": { + "message": "rbac" + } + }, + + { + "host": ["http://supplier:9018"], + "url_pattern": "/", + "mapping": { + "message": "supplier" + } + }, + + { + "host": ["http://upload:9019"], + "url_pattern": "/", + "mapping": { + "message": "upload" + } + }, + + { + "host": ["http://th:9020"], + "url_pattern": "/", + "mapping": { + "message": "th" + } + }, + + { + "host": ["http://kjhgf:9021"], + "url_pattern": "/", + "mapping": { + "message": "kjhgf" + } + }, + + { + "host": ["http://hhgfdsdfghj:9022"], + "url_pattern": "/", + "mapping": { + "message": "hhgfdsdfghj" + } + }, + + { + "host": ["http://ghjk:9023"], + "url_pattern": "/", + "mapping": { + "message": "ghjk" + } + }, + + { + "host": ["http://shjksgd:30067"], + "url_pattern": "/", + "mapping": { + "message": "shjksgd" + } + }] + }, + { + "@comment": "Hit all API list endpoints simultaneously", + "endpoint": "/api/v1/", + "method": "GET", + "backend": [ + { + "host": ["http://hd:null"], + "url_pattern": "/api/v1/hds", + "mapping": { + "data": "hds" + } + }, + + { + "host": ["http://customer-service:9000"], + "url_pattern": "/api/v1/customer-services", + "mapping": { + "data": "customer-services" + } + }, + + { + "host": ["http://product-service:9002"], + "url_pattern": "/api/v1/product-services", + "mapping": { + "data": "product-services" + } + }, + + { + "host": ["http://rbac-service:9004"], + "url_pattern": "/api/v1/rbac-services", + "mapping": { + "data": "rbac-services" + } + }, + + { + "host": ["http://payment-service:9006"], + "url_pattern": "/api/v1/payment-services", + "mapping": { + "data": "payment-services" + } + }, + + { + "host": ["http://notification-service:9007"], + "url_pattern": "/api/v1/notification-services", + "mapping": { + "data": "notification-services" + } + }, + + { + "host": ["http://email-service:9008"], + "url_pattern": "/api/v1/email-services", + "mapping": { + "data": "email-services" + } + }, + + { + "host": ["http://cart-service:9009"], + "url_pattern": "/api/v1/cart-services", + "mapping": { + "data": "cart-services" + } + }, + + { + "host": ["http://cart:9010"], + "url_pattern": "/api/v1/carts", + "mapping": { + "data": "carts" + } + }, + + { + "host": ["http://user:9011"], + "url_pattern": "/api/v1/users", + "mapping": { + "data": "users" + } + }, + + { + "host": ["http://customer:9012"], + "url_pattern": "/api/v1/customers", + "mapping": { + "data": "customers" + } + }, + + { + "host": ["http://email:9013"], + "url_pattern": "/api/v1/emails", + "mapping": { + "data": "emails" + } + }, + + { + "host": ["http://notification:9014"], + "url_pattern": "/api/v1/notifications", + "mapping": { + "data": "notifications" + } + }, + + { + "host": ["http://payment:9015"], + "url_pattern": "/api/v1/payments", + "mapping": { + "data": "payments" + } + }, + + { + "host": ["http://product:9016"], + "url_pattern": "/api/v1/products", + "mapping": { + "data": "products" + } + }, + + { + "host": ["http://rbac:9017"], + "url_pattern": "/api/v1/rbacs", + "mapping": { + "data": "rbacs" + } + }, + + { + "host": ["http://supplier:9018"], + "url_pattern": "/api/v1/suppliers", + "mapping": { + "data": "suppliers" + } + }, + + { + "host": ["http://upload:9019"], + "url_pattern": "/api/v1/uploads", + "mapping": { + "data": "uploads" + } + }, + + { + "host": ["http://th:9020"], + "url_pattern": "/api/v1/ths", + "mapping": { + "data": "ths" + } + }, + + { + "host": ["http://kjhgf:9021"], + "url_pattern": "/api/v1/kjhgfs", + "mapping": { + "data": "kjhgfs" + } + }, + + { + "host": ["http://hhgfdsdfghj:9022"], + "url_pattern": "/api/v1/hhgfdsdfghjs", + "mapping": { + "data": "hhgfdsdfghjs" + } + }, + + { + "host": ["http://ghjk:9023"], + "url_pattern": "/api/v1/ghjks", + "mapping": { + "data": "ghjks" + } + }, + + { + "host": ["http://shjksgd:30067"], + "url_pattern": "/api/v1/shjksgds", + "mapping": { + "data": "shjksgds" + } + }] + }, + { + "@comment": "Fetch all data from the hd service", + "endpoint": "/api/v1/hds", + "method": "GET", + "backend": [ + { + "host": ["http://hd:null"], + "url_pattern": "/api/v1/hds", + "mapping": { + "data": "hds" + } + }] + } + ] +} \ No newline at end of file diff --git a/gateways/apps/dnmw/nginx/Dockerfile b/gateways/apps/dnmw/nginx/Dockerfile new file mode 100644 index 0000000..ddf7281 --- /dev/null +++ b/gateways/apps/dnmw/nginx/Dockerfile @@ -0,0 +1,3 @@ + +FROM nginx +COPY ./default.conf /etc/nginx/conf.d/default.conf \ No newline at end of file diff --git a/gateways/apps/dnmw/nginx/Dockerfile.dev b/gateways/apps/dnmw/nginx/Dockerfile.dev new file mode 100644 index 0000000..ddf7281 --- /dev/null +++ b/gateways/apps/dnmw/nginx/Dockerfile.dev @@ -0,0 +1,3 @@ + +FROM nginx +COPY ./default.conf /etc/nginx/conf.d/default.conf \ No newline at end of file diff --git a/gateways/apps/dnmw/nginx/default.conf b/gateways/apps/dnmw/nginx/default.conf new file mode 100644 index 0000000..d4dace0 --- /dev/null +++ b/gateways/apps/dnmw/nginx/default.conf @@ -0,0 +1,282 @@ + + +upstream hd_upstream { + server hd:null; +} + +upstream customer-service_upstream { + server customer-service:9000; +} + +upstream product-service_upstream { + server product-service:9002; +} + +upstream rbac-service_upstream { + server rbac-service:9004; +} + +upstream payment-service_upstream { + server payment-service:9006; +} + +upstream notification-service_upstream { + server notification-service:9007; +} + +upstream email-service_upstream { + server email-service:9008; +} + +upstream cart-service_upstream { + server cart-service:9009; +} + +upstream cart_upstream { + server cart:9010; +} + +upstream user_upstream { + server user:9011; +} + +upstream customer_upstream { + server customer:9012; +} + +upstream email_upstream { + server email:9013; +} + +upstream notification_upstream { + server notification:9014; +} + +upstream payment_upstream { + server payment:9015; +} + +upstream product_upstream { + server product:9016; +} + +upstream rbac_upstream { + server rbac:9017; +} + +upstream supplier_upstream { + server supplier:9018; +} + +upstream upload_upstream { + server upload:9019; +} + +upstream th_upstream { + server th:9020; +} + +upstream kjhgf_upstream { + server kjhgf:9021; +} + +upstream hhgfdsdfghj_upstream { + server hhgfdsdfghj:9022; +} + +upstream ghjk_upstream { + server ghjk:9023; +} + +upstream shjksgd_upstream { + server shjksgd:30067; +} + +server { + listen 80; + + + location /api/v1/hds { + proxy_pass http://hd_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/customer-services { + proxy_pass http://customer-service_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/product-services { + proxy_pass http://product-service_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/rbac-services { + proxy_pass http://rbac-service_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/payment-services { + proxy_pass http://payment-service_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/notification-services { + proxy_pass http://notification-service_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/email-services { + proxy_pass http://email-service_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/cart-services { + proxy_pass http://cart-service_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/carts { + proxy_pass http://cart_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/users { + proxy_pass http://user_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/customers { + proxy_pass http://customer_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/emails { + proxy_pass http://email_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/notifications { + proxy_pass http://notification_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/payments { + proxy_pass http://payment_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/products { + proxy_pass http://product_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/rbacs { + proxy_pass http://rbac_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/suppliers { + proxy_pass http://supplier_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/uploads { + proxy_pass http://upload_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/ths { + proxy_pass http://th_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/kjhgfs { + proxy_pass http://kjhgf_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/hhgfdsdfghjs { + proxy_pass http://hhgfdsdfghj_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/ghjks { + proxy_pass http://ghjk_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/shjksgds { + proxy_pass http://shjksgd_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } +} \ No newline at end of file diff --git a/gateways/apps/gghjk/docker-compose.dev.yml b/gateways/apps/gghjk/docker-compose.dev.yml new file mode 100644 index 0000000..f172983 --- /dev/null +++ b/gateways/apps/gghjk/docker-compose.dev.yml @@ -0,0 +1,353 @@ + +version: '3.8' +services: + + hd: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/hd + ports: + - "null:null" + volumes: + - /app/node_modules + - ../../../microservices/hd:/app + depends_on: + rabbitmq: + condition: service_healthy + + customer-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/customer-service + ports: + - "9000:9000" + volumes: + - /app/node_modules + - ../../../microservices/customer-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + product-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/product-service + ports: + - "9002:9002" + volumes: + - /app/node_modules + - ../../../microservices/product-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + rbac-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/rbac-service + ports: + - "9004:9004" + volumes: + - /app/node_modules + - ../../../microservices/rbac-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + payment-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/payment-service + ports: + - "9006:9006" + volumes: + - /app/node_modules + - ../../../microservices/payment-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + notification-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/notification-service + ports: + - "9007:9007" + volumes: + - /app/node_modules + - ../../../microservices/notification-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + email-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/email-service + ports: + - "9008:9008" + volumes: + - /app/node_modules + - ../../../microservices/email-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + cart-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/cart-service + ports: + - "9009:9009" + volumes: + - /app/node_modules + - ../../../microservices/cart-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + cart: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/cart + ports: + - "9010:9010" + volumes: + - /app/node_modules + - ../../../microservices/cart:/app + depends_on: + rabbitmq: + condition: service_healthy + + user: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/user + ports: + - "9011:9011" + volumes: + - /app/node_modules + - ../../../microservices/user:/app + depends_on: + rabbitmq: + condition: service_healthy + + customer: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/customer + ports: + - "9012:9012" + volumes: + - /app/node_modules + - ../../../microservices/customer:/app + depends_on: + rabbitmq: + condition: service_healthy + + email: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/email + ports: + - "9013:9013" + volumes: + - /app/node_modules + - ../../../microservices/email:/app + depends_on: + rabbitmq: + condition: service_healthy + + notification: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/notification + ports: + - "9014:9014" + volumes: + - /app/node_modules + - ../../../microservices/notification:/app + depends_on: + rabbitmq: + condition: service_healthy + + payment: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/payment + ports: + - "9015:9015" + volumes: + - /app/node_modules + - ../../../microservices/payment:/app + depends_on: + rabbitmq: + condition: service_healthy + + product: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/product + ports: + - "9016:9016" + volumes: + - /app/node_modules + - ../../../microservices/product:/app + depends_on: + rabbitmq: + condition: service_healthy + + rbac: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/rbac + ports: + - "9017:9017" + volumes: + - /app/node_modules + - ../../../microservices/rbac:/app + depends_on: + rabbitmq: + condition: service_healthy + + supplier: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/supplier + ports: + - "9018:9018" + volumes: + - /app/node_modules + - ../../../microservices/supplier:/app + depends_on: + rabbitmq: + condition: service_healthy + + upload: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/upload + ports: + - "9019:9019" + volumes: + - /app/node_modules + - ../../../microservices/upload:/app + depends_on: + rabbitmq: + condition: service_healthy + + th: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/th + ports: + - "9020:9020" + volumes: + - /app/node_modules + - ../../../microservices/th:/app + depends_on: + rabbitmq: + condition: service_healthy + + kjhgf: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/kjhgf + ports: + - "9021:9021" + volumes: + - /app/node_modules + - ../../../microservices/kjhgf:/app + depends_on: + rabbitmq: + condition: service_healthy + + hhgfdsdfghj: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/hhgfdsdfghj + ports: + - "9022:9022" + volumes: + - /app/node_modules + - ../../../microservices/hhgfdsdfghj:/app + depends_on: + rabbitmq: + condition: service_healthy + + ghjk: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/ghjk + ports: + - "9023:9023" + volumes: + - /app/node_modules + - ../../../microservices/ghjk:/app + depends_on: + rabbitmq: + condition: service_healthy + + nginx: + depends_on: + - hd + - customer-service + - product-service + - rbac-service + - payment-service + - notification-service + - email-service + - cart-service + - cart + - user + - customer + - email + - notification + - payment + - product + - rbac + - supplier + - upload + - th + - kjhgf + - hhgfdsdfghj + - ghjk + restart: always + build: + context: ./nginx + dockerfile: Dockerfile.dev + ports: + - '4000:80' + healthcheck: + test: ["CMD-SHELL", "curl -f http://localhost:80/health || exit 1"] + interval: 30s + timeout: 10s + retries: 3 + start_period: 40s + rabbitmq: + image: rabbitmq:3.13-management + container_name: rabbitmq + ports: + - '5672:5672' + - '15672:15672' + healthcheck: + test: ["CMD", "rabbitmq-diagnostics", "ping"] + interval: 30s + retries: 5 + mongodb: + image: mongo + ports: + - '27017:27017' + restart: always + volumes: + - type: bind + source: ./data + target: /data/db + krakend: + image: devopsfaith/krakend:2.7-watch + ports: + - '9003:9003' + - '8090:8090' + volumes: + - ./krakend/:/etc/krakend/ + command: ['run','-d','-c','/etc/krakend/krakend.json'] \ No newline at end of file diff --git a/gateways/apps/gghjk/docker-compose.yml b/gateways/apps/gghjk/docker-compose.yml new file mode 100644 index 0000000..c60db9b --- /dev/null +++ b/gateways/apps/gghjk/docker-compose.yml @@ -0,0 +1,353 @@ + +version: '3.8' +services: + + hd: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/hd + ports: + - "null:null" + volumes: + - /app/node_modules + - ../../../microservices/hd:/app + depends_on: + rabbitmq: + condition: service_healthy + + customer-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/customer-service + ports: + - "9000:9000" + volumes: + - /app/node_modules + - ../../../microservices/customer-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + product-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/product-service + ports: + - "9002:9002" + volumes: + - /app/node_modules + - ../../../microservices/product-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + rbac-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/rbac-service + ports: + - "9004:9004" + volumes: + - /app/node_modules + - ../../../microservices/rbac-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + payment-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/payment-service + ports: + - "9006:9006" + volumes: + - /app/node_modules + - ../../../microservices/payment-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + notification-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/notification-service + ports: + - "9007:9007" + volumes: + - /app/node_modules + - ../../../microservices/notification-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + email-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/email-service + ports: + - "9008:9008" + volumes: + - /app/node_modules + - ../../../microservices/email-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + cart-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/cart-service + ports: + - "9009:9009" + volumes: + - /app/node_modules + - ../../../microservices/cart-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + cart: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/cart + ports: + - "9010:9010" + volumes: + - /app/node_modules + - ../../../microservices/cart:/app + depends_on: + rabbitmq: + condition: service_healthy + + user: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/user + ports: + - "9011:9011" + volumes: + - /app/node_modules + - ../../../microservices/user:/app + depends_on: + rabbitmq: + condition: service_healthy + + customer: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/customer + ports: + - "9012:9012" + volumes: + - /app/node_modules + - ../../../microservices/customer:/app + depends_on: + rabbitmq: + condition: service_healthy + + email: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/email + ports: + - "9013:9013" + volumes: + - /app/node_modules + - ../../../microservices/email:/app + depends_on: + rabbitmq: + condition: service_healthy + + notification: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/notification + ports: + - "9014:9014" + volumes: + - /app/node_modules + - ../../../microservices/notification:/app + depends_on: + rabbitmq: + condition: service_healthy + + payment: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/payment + ports: + - "9015:9015" + volumes: + - /app/node_modules + - ../../../microservices/payment:/app + depends_on: + rabbitmq: + condition: service_healthy + + product: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/product + ports: + - "9016:9016" + volumes: + - /app/node_modules + - ../../../microservices/product:/app + depends_on: + rabbitmq: + condition: service_healthy + + rbac: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/rbac + ports: + - "9017:9017" + volumes: + - /app/node_modules + - ../../../microservices/rbac:/app + depends_on: + rabbitmq: + condition: service_healthy + + supplier: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/supplier + ports: + - "9018:9018" + volumes: + - /app/node_modules + - ../../../microservices/supplier:/app + depends_on: + rabbitmq: + condition: service_healthy + + upload: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/upload + ports: + - "9019:9019" + volumes: + - /app/node_modules + - ../../../microservices/upload:/app + depends_on: + rabbitmq: + condition: service_healthy + + th: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/th + ports: + - "9020:9020" + volumes: + - /app/node_modules + - ../../../microservices/th:/app + depends_on: + rabbitmq: + condition: service_healthy + + kjhgf: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/kjhgf + ports: + - "9021:9021" + volumes: + - /app/node_modules + - ../../../microservices/kjhgf:/app + depends_on: + rabbitmq: + condition: service_healthy + + hhgfdsdfghj: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/hhgfdsdfghj + ports: + - "9022:9022" + volumes: + - /app/node_modules + - ../../../microservices/hhgfdsdfghj:/app + depends_on: + rabbitmq: + condition: service_healthy + + ghjk: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/ghjk + ports: + - "9023:9023" + volumes: + - /app/node_modules + - ../../../microservices/ghjk:/app + depends_on: + rabbitmq: + condition: service_healthy + + nginx: + depends_on: + - hd + - customer-service + - product-service + - rbac-service + - payment-service + - notification-service + - email-service + - cart-service + - cart + - user + - customer + - email + - notification + - payment + - product + - rbac + - supplier + - upload + - th + - kjhgf + - hhgfdsdfghj + - ghjk + restart: always + build: + context: ./nginx + dockerfile: Dockerfile.dev + ports: + - '4000:80' + healthcheck: + test: ["CMD-SHELL", "curl -f http://localhost:80/health || exit 1"] + interval: 30s + timeout: 10s + retries: 3 + start_period: 40s + rabbitmq: + image: rabbitmq:3.13-management + container_name: rabbitmq + ports: + - '5672:5672' + - '15672:15672' + healthcheck: + test: ["CMD", "rabbitmq-diagnostics", "ping"] + interval: 30s + retries: 5 + mongodb: + image: mongo + ports: + - '27017:27017' + restart: always + volumes: + - type: bind + source: ./data + target: /data/db + krakend: + image: devopsfaith/krakend:2.7 + ports: + - '9003:9003' + - '8090:8090' + volumes: + - ./krakend/:/etc/krakend/ + command: ['run','-d','-c','/etc/krakend/krakend.json'] \ No newline at end of file diff --git a/gateways/apps/gghjk/krakend/krakend.json b/gateways/apps/gghjk/krakend/krakend.json new file mode 100644 index 0000000..7d7ac91 --- /dev/null +++ b/gateways/apps/gghjk/krakend/krakend.json @@ -0,0 +1,386 @@ + +{ + "$schema": "https://www.krakend.io/schema/v2.5/krakend.json", + "version": 3, + "name": "Microservices-suite API Gateway", + "port": 9003, + "cache_ttl": "3600s", + "timeout": "300s", + "endpoints": [ + { + "@comment": "Check the health of all your APIs", + "endpoint": "/__suite_status", + "method": "GET", + "backend": [ + { + "host": ["http://hd:null"], + "url_pattern": "/", + "mapping": { + "message": "hd" + } + }, + + { + "host": ["http://customer-service:9000"], + "url_pattern": "/", + "mapping": { + "message": "customer-service" + } + }, + + { + "host": ["http://product-service:9002"], + "url_pattern": "/", + "mapping": { + "message": "product-service" + } + }, + + { + "host": ["http://rbac-service:9004"], + "url_pattern": "/", + "mapping": { + "message": "rbac-service" + } + }, + + { + "host": ["http://payment-service:9006"], + "url_pattern": "/", + "mapping": { + "message": "payment-service" + } + }, + + { + "host": ["http://notification-service:9007"], + "url_pattern": "/", + "mapping": { + "message": "notification-service" + } + }, + + { + "host": ["http://email-service:9008"], + "url_pattern": "/", + "mapping": { + "message": "email-service" + } + }, + + { + "host": ["http://cart-service:9009"], + "url_pattern": "/", + "mapping": { + "message": "cart-service" + } + }, + + { + "host": ["http://cart:9010"], + "url_pattern": "/", + "mapping": { + "message": "cart" + } + }, + + { + "host": ["http://user:9011"], + "url_pattern": "/", + "mapping": { + "message": "user" + } + }, + + { + "host": ["http://customer:9012"], + "url_pattern": "/", + "mapping": { + "message": "customer" + } + }, + + { + "host": ["http://email:9013"], + "url_pattern": "/", + "mapping": { + "message": "email" + } + }, + + { + "host": ["http://notification:9014"], + "url_pattern": "/", + "mapping": { + "message": "notification" + } + }, + + { + "host": ["http://payment:9015"], + "url_pattern": "/", + "mapping": { + "message": "payment" + } + }, + + { + "host": ["http://product:9016"], + "url_pattern": "/", + "mapping": { + "message": "product" + } + }, + + { + "host": ["http://rbac:9017"], + "url_pattern": "/", + "mapping": { + "message": "rbac" + } + }, + + { + "host": ["http://supplier:9018"], + "url_pattern": "/", + "mapping": { + "message": "supplier" + } + }, + + { + "host": ["http://upload:9019"], + "url_pattern": "/", + "mapping": { + "message": "upload" + } + }, + + { + "host": ["http://th:9020"], + "url_pattern": "/", + "mapping": { + "message": "th" + } + }, + + { + "host": ["http://kjhgf:9021"], + "url_pattern": "/", + "mapping": { + "message": "kjhgf" + } + }, + + { + "host": ["http://hhgfdsdfghj:9022"], + "url_pattern": "/", + "mapping": { + "message": "hhgfdsdfghj" + } + }, + + { + "host": ["http://ghjk:9023"], + "url_pattern": "/", + "mapping": { + "message": "ghjk" + } + }] + }, + { + "@comment": "Hit all API list endpoints simultaneously", + "endpoint": "/api/v1/", + "method": "GET", + "backend": [ + { + "host": ["http://hd:null"], + "url_pattern": "/api/v1/hds", + "mapping": { + "data": "hds" + } + }, + + { + "host": ["http://customer-service:9000"], + "url_pattern": "/api/v1/customer-services", + "mapping": { + "data": "customer-services" + } + }, + + { + "host": ["http://product-service:9002"], + "url_pattern": "/api/v1/product-services", + "mapping": { + "data": "product-services" + } + }, + + { + "host": ["http://rbac-service:9004"], + "url_pattern": "/api/v1/rbac-services", + "mapping": { + "data": "rbac-services" + } + }, + + { + "host": ["http://payment-service:9006"], + "url_pattern": "/api/v1/payment-services", + "mapping": { + "data": "payment-services" + } + }, + + { + "host": ["http://notification-service:9007"], + "url_pattern": "/api/v1/notification-services", + "mapping": { + "data": "notification-services" + } + }, + + { + "host": ["http://email-service:9008"], + "url_pattern": "/api/v1/email-services", + "mapping": { + "data": "email-services" + } + }, + + { + "host": ["http://cart-service:9009"], + "url_pattern": "/api/v1/cart-services", + "mapping": { + "data": "cart-services" + } + }, + + { + "host": ["http://cart:9010"], + "url_pattern": "/api/v1/carts", + "mapping": { + "data": "carts" + } + }, + + { + "host": ["http://user:9011"], + "url_pattern": "/api/v1/users", + "mapping": { + "data": "users" + } + }, + + { + "host": ["http://customer:9012"], + "url_pattern": "/api/v1/customers", + "mapping": { + "data": "customers" + } + }, + + { + "host": ["http://email:9013"], + "url_pattern": "/api/v1/emails", + "mapping": { + "data": "emails" + } + }, + + { + "host": ["http://notification:9014"], + "url_pattern": "/api/v1/notifications", + "mapping": { + "data": "notifications" + } + }, + + { + "host": ["http://payment:9015"], + "url_pattern": "/api/v1/payments", + "mapping": { + "data": "payments" + } + }, + + { + "host": ["http://product:9016"], + "url_pattern": "/api/v1/products", + "mapping": { + "data": "products" + } + }, + + { + "host": ["http://rbac:9017"], + "url_pattern": "/api/v1/rbacs", + "mapping": { + "data": "rbacs" + } + }, + + { + "host": ["http://supplier:9018"], + "url_pattern": "/api/v1/suppliers", + "mapping": { + "data": "suppliers" + } + }, + + { + "host": ["http://upload:9019"], + "url_pattern": "/api/v1/uploads", + "mapping": { + "data": "uploads" + } + }, + + { + "host": ["http://th:9020"], + "url_pattern": "/api/v1/ths", + "mapping": { + "data": "ths" + } + }, + + { + "host": ["http://kjhgf:9021"], + "url_pattern": "/api/v1/kjhgfs", + "mapping": { + "data": "kjhgfs" + } + }, + + { + "host": ["http://hhgfdsdfghj:9022"], + "url_pattern": "/api/v1/hhgfdsdfghjs", + "mapping": { + "data": "hhgfdsdfghjs" + } + }, + + { + "host": ["http://ghjk:9023"], + "url_pattern": "/api/v1/ghjks", + "mapping": { + "data": "ghjks" + } + }] + }, + { + "@comment": "Fetch all data from the hd service", + "endpoint": "/api/v1/hds", + "method": "GET", + "backend": [ + { + "host": ["http://hd:null"], + "url_pattern": "/api/v1/hds", + "mapping": { + "data": "hds" + } + }] + } + ] +} \ No newline at end of file diff --git a/gateways/apps/gghjk/nginx/Dockerfile b/gateways/apps/gghjk/nginx/Dockerfile new file mode 100644 index 0000000..ddf7281 --- /dev/null +++ b/gateways/apps/gghjk/nginx/Dockerfile @@ -0,0 +1,3 @@ + +FROM nginx +COPY ./default.conf /etc/nginx/conf.d/default.conf \ No newline at end of file diff --git a/gateways/apps/gghjk/nginx/Dockerfile.dev b/gateways/apps/gghjk/nginx/Dockerfile.dev new file mode 100644 index 0000000..ddf7281 --- /dev/null +++ b/gateways/apps/gghjk/nginx/Dockerfile.dev @@ -0,0 +1,3 @@ + +FROM nginx +COPY ./default.conf /etc/nginx/conf.d/default.conf \ No newline at end of file diff --git a/gateways/apps/gghjk/nginx/default.conf b/gateways/apps/gghjk/nginx/default.conf new file mode 100644 index 0000000..b25033b --- /dev/null +++ b/gateways/apps/gghjk/nginx/default.conf @@ -0,0 +1,270 @@ + + +upstream hd_upstream { + server hd:null; +} + +upstream customer-service_upstream { + server customer-service:9000; +} + +upstream product-service_upstream { + server product-service:9002; +} + +upstream rbac-service_upstream { + server rbac-service:9004; +} + +upstream payment-service_upstream { + server payment-service:9006; +} + +upstream notification-service_upstream { + server notification-service:9007; +} + +upstream email-service_upstream { + server email-service:9008; +} + +upstream cart-service_upstream { + server cart-service:9009; +} + +upstream cart_upstream { + server cart:9010; +} + +upstream user_upstream { + server user:9011; +} + +upstream customer_upstream { + server customer:9012; +} + +upstream email_upstream { + server email:9013; +} + +upstream notification_upstream { + server notification:9014; +} + +upstream payment_upstream { + server payment:9015; +} + +upstream product_upstream { + server product:9016; +} + +upstream rbac_upstream { + server rbac:9017; +} + +upstream supplier_upstream { + server supplier:9018; +} + +upstream upload_upstream { + server upload:9019; +} + +upstream th_upstream { + server th:9020; +} + +upstream kjhgf_upstream { + server kjhgf:9021; +} + +upstream hhgfdsdfghj_upstream { + server hhgfdsdfghj:9022; +} + +upstream ghjk_upstream { + server ghjk:9023; +} + +server { + listen 80; + + + location /api/v1/hds { + proxy_pass http://hd_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/customer-services { + proxy_pass http://customer-service_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/product-services { + proxy_pass http://product-service_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/rbac-services { + proxy_pass http://rbac-service_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/payment-services { + proxy_pass http://payment-service_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/notification-services { + proxy_pass http://notification-service_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/email-services { + proxy_pass http://email-service_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/cart-services { + proxy_pass http://cart-service_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/carts { + proxy_pass http://cart_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/users { + proxy_pass http://user_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/customers { + proxy_pass http://customer_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/emails { + proxy_pass http://email_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/notifications { + proxy_pass http://notification_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/payments { + proxy_pass http://payment_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/products { + proxy_pass http://product_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/rbacs { + proxy_pass http://rbac_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/suppliers { + proxy_pass http://supplier_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/uploads { + proxy_pass http://upload_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/ths { + proxy_pass http://th_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/kjhgfs { + proxy_pass http://kjhgf_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/hhgfdsdfghjs { + proxy_pass http://hhgfdsdfghj_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/ghjks { + proxy_pass http://ghjk_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } +} \ No newline at end of file diff --git a/gateways/apps/ghjklhg/docker-compose.dev.yml b/gateways/apps/ghjklhg/docker-compose.dev.yml new file mode 100644 index 0000000..55aece1 --- /dev/null +++ b/gateways/apps/ghjklhg/docker-compose.dev.yml @@ -0,0 +1,353 @@ + +version: '3.8' +services: + + hd: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/hd + ports: + - "null:null" + volumes: + - /app/node_modules + - ../../../microservices/hd:/app + depends_on: + rabbitmq: + condition: service_healthy + + customer-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/customer-service + ports: + - "9000:9000" + volumes: + - /app/node_modules + - ../../../microservices/customer-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + product-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/product-service + ports: + - "9002:9002" + volumes: + - /app/node_modules + - ../../../microservices/product-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + rbac-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/rbac-service + ports: + - "9004:9004" + volumes: + - /app/node_modules + - ../../../microservices/rbac-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + payment-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/payment-service + ports: + - "9006:9006" + volumes: + - /app/node_modules + - ../../../microservices/payment-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + notification-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/notification-service + ports: + - "9007:9007" + volumes: + - /app/node_modules + - ../../../microservices/notification-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + email-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/email-service + ports: + - "9008:9008" + volumes: + - /app/node_modules + - ../../../microservices/email-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + cart-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/cart-service + ports: + - "9009:9009" + volumes: + - /app/node_modules + - ../../../microservices/cart-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + cart: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/cart + ports: + - "9010:9010" + volumes: + - /app/node_modules + - ../../../microservices/cart:/app + depends_on: + rabbitmq: + condition: service_healthy + + user: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/user + ports: + - "9011:9011" + volumes: + - /app/node_modules + - ../../../microservices/user:/app + depends_on: + rabbitmq: + condition: service_healthy + + customer: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/customer + ports: + - "9012:9012" + volumes: + - /app/node_modules + - ../../../microservices/customer:/app + depends_on: + rabbitmq: + condition: service_healthy + + email: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/email + ports: + - "9013:9013" + volumes: + - /app/node_modules + - ../../../microservices/email:/app + depends_on: + rabbitmq: + condition: service_healthy + + notification: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/notification + ports: + - "9014:9014" + volumes: + - /app/node_modules + - ../../../microservices/notification:/app + depends_on: + rabbitmq: + condition: service_healthy + + payment: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/payment + ports: + - "9015:9015" + volumes: + - /app/node_modules + - ../../../microservices/payment:/app + depends_on: + rabbitmq: + condition: service_healthy + + product: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/product + ports: + - "9016:9016" + volumes: + - /app/node_modules + - ../../../microservices/product:/app + depends_on: + rabbitmq: + condition: service_healthy + + rbac: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/rbac + ports: + - "9017:9017" + volumes: + - /app/node_modules + - ../../../microservices/rbac:/app + depends_on: + rabbitmq: + condition: service_healthy + + supplier: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/supplier + ports: + - "9018:9018" + volumes: + - /app/node_modules + - ../../../microservices/supplier:/app + depends_on: + rabbitmq: + condition: service_healthy + + upload: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/upload + ports: + - "9019:9019" + volumes: + - /app/node_modules + - ../../../microservices/upload:/app + depends_on: + rabbitmq: + condition: service_healthy + + th: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/th + ports: + - "9020:9020" + volumes: + - /app/node_modules + - ../../../microservices/th:/app + depends_on: + rabbitmq: + condition: service_healthy + + kjhgf: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/kjhgf + ports: + - "9021:9021" + volumes: + - /app/node_modules + - ../../../microservices/kjhgf:/app + depends_on: + rabbitmq: + condition: service_healthy + + hhgfdsdfghj: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/hhgfdsdfghj + ports: + - "9022:9022" + volumes: + - /app/node_modules + - ../../../microservices/hhgfdsdfghj:/app + depends_on: + rabbitmq: + condition: service_healthy + + ghjk: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/ghjk + ports: + - "9023:9023" + volumes: + - /app/node_modules + - ../../../microservices/ghjk:/app + depends_on: + rabbitmq: + condition: service_healthy + + nginx: + depends_on: + - hd + - customer-service + - product-service + - rbac-service + - payment-service + - notification-service + - email-service + - cart-service + - cart + - user + - customer + - email + - notification + - payment + - product + - rbac + - supplier + - upload + - th + - kjhgf + - hhgfdsdfghj + - ghjk + restart: always + build: + context: ./nginx + dockerfile: Dockerfile.dev + ports: + - '4000:80' + healthcheck: + test: ["CMD-SHELL", "curl -f http://localhost:80/health || exit 1"] + interval: 30s + timeout: 10s + retries: 3 + start_period: 40s + rabbitmq: + image: rabbitmq:3.13-management + container_name: rabbitmq + ports: + - '5672:5672' + - '15672:15672' + healthcheck: + test: ["CMD", "rabbitmq-diagnostics", "ping"] + interval: 30s + retries: 5 + mongodb: + image: mongo + ports: + - '27017:27017' + restart: always + volumes: + - type: bind + source: ./data + target: /data/db + krakend: + image: devopsfaith/krakend:2.7-watch + ports: + - '9002:9002' + - '8090:8090' + volumes: + - ./krakend/:/etc/krakend/ + command: ['run','-d','-c','/etc/krakend/krakend.json'] \ No newline at end of file diff --git a/gateways/apps/ghjklhg/docker-compose.yml b/gateways/apps/ghjklhg/docker-compose.yml new file mode 100644 index 0000000..2565dec --- /dev/null +++ b/gateways/apps/ghjklhg/docker-compose.yml @@ -0,0 +1,353 @@ + +version: '3.8' +services: + + hd: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/hd + ports: + - "null:null" + volumes: + - /app/node_modules + - ../../../microservices/hd:/app + depends_on: + rabbitmq: + condition: service_healthy + + customer-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/customer-service + ports: + - "9000:9000" + volumes: + - /app/node_modules + - ../../../microservices/customer-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + product-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/product-service + ports: + - "9002:9002" + volumes: + - /app/node_modules + - ../../../microservices/product-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + rbac-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/rbac-service + ports: + - "9004:9004" + volumes: + - /app/node_modules + - ../../../microservices/rbac-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + payment-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/payment-service + ports: + - "9006:9006" + volumes: + - /app/node_modules + - ../../../microservices/payment-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + notification-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/notification-service + ports: + - "9007:9007" + volumes: + - /app/node_modules + - ../../../microservices/notification-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + email-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/email-service + ports: + - "9008:9008" + volumes: + - /app/node_modules + - ../../../microservices/email-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + cart-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/cart-service + ports: + - "9009:9009" + volumes: + - /app/node_modules + - ../../../microservices/cart-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + cart: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/cart + ports: + - "9010:9010" + volumes: + - /app/node_modules + - ../../../microservices/cart:/app + depends_on: + rabbitmq: + condition: service_healthy + + user: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/user + ports: + - "9011:9011" + volumes: + - /app/node_modules + - ../../../microservices/user:/app + depends_on: + rabbitmq: + condition: service_healthy + + customer: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/customer + ports: + - "9012:9012" + volumes: + - /app/node_modules + - ../../../microservices/customer:/app + depends_on: + rabbitmq: + condition: service_healthy + + email: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/email + ports: + - "9013:9013" + volumes: + - /app/node_modules + - ../../../microservices/email:/app + depends_on: + rabbitmq: + condition: service_healthy + + notification: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/notification + ports: + - "9014:9014" + volumes: + - /app/node_modules + - ../../../microservices/notification:/app + depends_on: + rabbitmq: + condition: service_healthy + + payment: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/payment + ports: + - "9015:9015" + volumes: + - /app/node_modules + - ../../../microservices/payment:/app + depends_on: + rabbitmq: + condition: service_healthy + + product: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/product + ports: + - "9016:9016" + volumes: + - /app/node_modules + - ../../../microservices/product:/app + depends_on: + rabbitmq: + condition: service_healthy + + rbac: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/rbac + ports: + - "9017:9017" + volumes: + - /app/node_modules + - ../../../microservices/rbac:/app + depends_on: + rabbitmq: + condition: service_healthy + + supplier: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/supplier + ports: + - "9018:9018" + volumes: + - /app/node_modules + - ../../../microservices/supplier:/app + depends_on: + rabbitmq: + condition: service_healthy + + upload: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/upload + ports: + - "9019:9019" + volumes: + - /app/node_modules + - ../../../microservices/upload:/app + depends_on: + rabbitmq: + condition: service_healthy + + th: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/th + ports: + - "9020:9020" + volumes: + - /app/node_modules + - ../../../microservices/th:/app + depends_on: + rabbitmq: + condition: service_healthy + + kjhgf: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/kjhgf + ports: + - "9021:9021" + volumes: + - /app/node_modules + - ../../../microservices/kjhgf:/app + depends_on: + rabbitmq: + condition: service_healthy + + hhgfdsdfghj: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/hhgfdsdfghj + ports: + - "9022:9022" + volumes: + - /app/node_modules + - ../../../microservices/hhgfdsdfghj:/app + depends_on: + rabbitmq: + condition: service_healthy + + ghjk: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/ghjk + ports: + - "9023:9023" + volumes: + - /app/node_modules + - ../../../microservices/ghjk:/app + depends_on: + rabbitmq: + condition: service_healthy + + nginx: + depends_on: + - hd + - customer-service + - product-service + - rbac-service + - payment-service + - notification-service + - email-service + - cart-service + - cart + - user + - customer + - email + - notification + - payment + - product + - rbac + - supplier + - upload + - th + - kjhgf + - hhgfdsdfghj + - ghjk + restart: always + build: + context: ./nginx + dockerfile: Dockerfile.dev + ports: + - '4000:80' + healthcheck: + test: ["CMD-SHELL", "curl -f http://localhost:80/health || exit 1"] + interval: 30s + timeout: 10s + retries: 3 + start_period: 40s + rabbitmq: + image: rabbitmq:3.13-management + container_name: rabbitmq + ports: + - '5672:5672' + - '15672:15672' + healthcheck: + test: ["CMD", "rabbitmq-diagnostics", "ping"] + interval: 30s + retries: 5 + mongodb: + image: mongo + ports: + - '27017:27017' + restart: always + volumes: + - type: bind + source: ./data + target: /data/db + krakend: + image: devopsfaith/krakend:2.7 + ports: + - '9002:9002' + - '8090:8090' + volumes: + - ./krakend/:/etc/krakend/ + command: ['run','-d','-c','/etc/krakend/krakend.json'] \ No newline at end of file diff --git a/gateways/apps/ghjklhg/krakend/krakend.json b/gateways/apps/ghjklhg/krakend/krakend.json new file mode 100644 index 0000000..295170e --- /dev/null +++ b/gateways/apps/ghjklhg/krakend/krakend.json @@ -0,0 +1,386 @@ + +{ + "$schema": "https://www.krakend.io/schema/v2.5/krakend.json", + "version": 3, + "name": "Microservices-suite API Gateway", + "port": 9002, + "cache_ttl": "3600s", + "timeout": "300s", + "endpoints": [ + { + "@comment": "Check the health of all your APIs", + "endpoint": "/__suite_status", + "method": "GET", + "backend": [ + { + "host": ["http://hd:null"], + "url_pattern": "/", + "mapping": { + "message": "hd" + } + }, + + { + "host": ["http://customer-service:9000"], + "url_pattern": "/", + "mapping": { + "message": "customer-service" + } + }, + + { + "host": ["http://product-service:9002"], + "url_pattern": "/", + "mapping": { + "message": "product-service" + } + }, + + { + "host": ["http://rbac-service:9004"], + "url_pattern": "/", + "mapping": { + "message": "rbac-service" + } + }, + + { + "host": ["http://payment-service:9006"], + "url_pattern": "/", + "mapping": { + "message": "payment-service" + } + }, + + { + "host": ["http://notification-service:9007"], + "url_pattern": "/", + "mapping": { + "message": "notification-service" + } + }, + + { + "host": ["http://email-service:9008"], + "url_pattern": "/", + "mapping": { + "message": "email-service" + } + }, + + { + "host": ["http://cart-service:9009"], + "url_pattern": "/", + "mapping": { + "message": "cart-service" + } + }, + + { + "host": ["http://cart:9010"], + "url_pattern": "/", + "mapping": { + "message": "cart" + } + }, + + { + "host": ["http://user:9011"], + "url_pattern": "/", + "mapping": { + "message": "user" + } + }, + + { + "host": ["http://customer:9012"], + "url_pattern": "/", + "mapping": { + "message": "customer" + } + }, + + { + "host": ["http://email:9013"], + "url_pattern": "/", + "mapping": { + "message": "email" + } + }, + + { + "host": ["http://notification:9014"], + "url_pattern": "/", + "mapping": { + "message": "notification" + } + }, + + { + "host": ["http://payment:9015"], + "url_pattern": "/", + "mapping": { + "message": "payment" + } + }, + + { + "host": ["http://product:9016"], + "url_pattern": "/", + "mapping": { + "message": "product" + } + }, + + { + "host": ["http://rbac:9017"], + "url_pattern": "/", + "mapping": { + "message": "rbac" + } + }, + + { + "host": ["http://supplier:9018"], + "url_pattern": "/", + "mapping": { + "message": "supplier" + } + }, + + { + "host": ["http://upload:9019"], + "url_pattern": "/", + "mapping": { + "message": "upload" + } + }, + + { + "host": ["http://th:9020"], + "url_pattern": "/", + "mapping": { + "message": "th" + } + }, + + { + "host": ["http://kjhgf:9021"], + "url_pattern": "/", + "mapping": { + "message": "kjhgf" + } + }, + + { + "host": ["http://hhgfdsdfghj:9022"], + "url_pattern": "/", + "mapping": { + "message": "hhgfdsdfghj" + } + }, + + { + "host": ["http://ghjk:9023"], + "url_pattern": "/", + "mapping": { + "message": "ghjk" + } + }] + }, + { + "@comment": "Hit all API list endpoints simultaneously", + "endpoint": "/api/v1/", + "method": "GET", + "backend": [ + { + "host": ["http://hd:null"], + "url_pattern": "/api/v1/hds", + "mapping": { + "data": "hds" + } + }, + + { + "host": ["http://customer-service:9000"], + "url_pattern": "/api/v1/customer-services", + "mapping": { + "data": "customer-services" + } + }, + + { + "host": ["http://product-service:9002"], + "url_pattern": "/api/v1/product-services", + "mapping": { + "data": "product-services" + } + }, + + { + "host": ["http://rbac-service:9004"], + "url_pattern": "/api/v1/rbac-services", + "mapping": { + "data": "rbac-services" + } + }, + + { + "host": ["http://payment-service:9006"], + "url_pattern": "/api/v1/payment-services", + "mapping": { + "data": "payment-services" + } + }, + + { + "host": ["http://notification-service:9007"], + "url_pattern": "/api/v1/notification-services", + "mapping": { + "data": "notification-services" + } + }, + + { + "host": ["http://email-service:9008"], + "url_pattern": "/api/v1/email-services", + "mapping": { + "data": "email-services" + } + }, + + { + "host": ["http://cart-service:9009"], + "url_pattern": "/api/v1/cart-services", + "mapping": { + "data": "cart-services" + } + }, + + { + "host": ["http://cart:9010"], + "url_pattern": "/api/v1/carts", + "mapping": { + "data": "carts" + } + }, + + { + "host": ["http://user:9011"], + "url_pattern": "/api/v1/users", + "mapping": { + "data": "users" + } + }, + + { + "host": ["http://customer:9012"], + "url_pattern": "/api/v1/customers", + "mapping": { + "data": "customers" + } + }, + + { + "host": ["http://email:9013"], + "url_pattern": "/api/v1/emails", + "mapping": { + "data": "emails" + } + }, + + { + "host": ["http://notification:9014"], + "url_pattern": "/api/v1/notifications", + "mapping": { + "data": "notifications" + } + }, + + { + "host": ["http://payment:9015"], + "url_pattern": "/api/v1/payments", + "mapping": { + "data": "payments" + } + }, + + { + "host": ["http://product:9016"], + "url_pattern": "/api/v1/products", + "mapping": { + "data": "products" + } + }, + + { + "host": ["http://rbac:9017"], + "url_pattern": "/api/v1/rbacs", + "mapping": { + "data": "rbacs" + } + }, + + { + "host": ["http://supplier:9018"], + "url_pattern": "/api/v1/suppliers", + "mapping": { + "data": "suppliers" + } + }, + + { + "host": ["http://upload:9019"], + "url_pattern": "/api/v1/uploads", + "mapping": { + "data": "uploads" + } + }, + + { + "host": ["http://th:9020"], + "url_pattern": "/api/v1/ths", + "mapping": { + "data": "ths" + } + }, + + { + "host": ["http://kjhgf:9021"], + "url_pattern": "/api/v1/kjhgfs", + "mapping": { + "data": "kjhgfs" + } + }, + + { + "host": ["http://hhgfdsdfghj:9022"], + "url_pattern": "/api/v1/hhgfdsdfghjs", + "mapping": { + "data": "hhgfdsdfghjs" + } + }, + + { + "host": ["http://ghjk:9023"], + "url_pattern": "/api/v1/ghjks", + "mapping": { + "data": "ghjks" + } + }] + }, + { + "@comment": "Fetch all data from the hd service", + "endpoint": "/api/v1/hds", + "method": "GET", + "backend": [ + { + "host": ["http://hd:null"], + "url_pattern": "/api/v1/hds", + "mapping": { + "data": "hds" + } + }] + } + ] +} \ No newline at end of file diff --git a/gateways/apps/ghjklhg/nginx/Dockerfile b/gateways/apps/ghjklhg/nginx/Dockerfile new file mode 100644 index 0000000..ddf7281 --- /dev/null +++ b/gateways/apps/ghjklhg/nginx/Dockerfile @@ -0,0 +1,3 @@ + +FROM nginx +COPY ./default.conf /etc/nginx/conf.d/default.conf \ No newline at end of file diff --git a/gateways/apps/ghjklhg/nginx/Dockerfile.dev b/gateways/apps/ghjklhg/nginx/Dockerfile.dev new file mode 100644 index 0000000..ddf7281 --- /dev/null +++ b/gateways/apps/ghjklhg/nginx/Dockerfile.dev @@ -0,0 +1,3 @@ + +FROM nginx +COPY ./default.conf /etc/nginx/conf.d/default.conf \ No newline at end of file diff --git a/gateways/apps/ghjklhg/nginx/default.conf b/gateways/apps/ghjklhg/nginx/default.conf new file mode 100644 index 0000000..b25033b --- /dev/null +++ b/gateways/apps/ghjklhg/nginx/default.conf @@ -0,0 +1,270 @@ + + +upstream hd_upstream { + server hd:null; +} + +upstream customer-service_upstream { + server customer-service:9000; +} + +upstream product-service_upstream { + server product-service:9002; +} + +upstream rbac-service_upstream { + server rbac-service:9004; +} + +upstream payment-service_upstream { + server payment-service:9006; +} + +upstream notification-service_upstream { + server notification-service:9007; +} + +upstream email-service_upstream { + server email-service:9008; +} + +upstream cart-service_upstream { + server cart-service:9009; +} + +upstream cart_upstream { + server cart:9010; +} + +upstream user_upstream { + server user:9011; +} + +upstream customer_upstream { + server customer:9012; +} + +upstream email_upstream { + server email:9013; +} + +upstream notification_upstream { + server notification:9014; +} + +upstream payment_upstream { + server payment:9015; +} + +upstream product_upstream { + server product:9016; +} + +upstream rbac_upstream { + server rbac:9017; +} + +upstream supplier_upstream { + server supplier:9018; +} + +upstream upload_upstream { + server upload:9019; +} + +upstream th_upstream { + server th:9020; +} + +upstream kjhgf_upstream { + server kjhgf:9021; +} + +upstream hhgfdsdfghj_upstream { + server hhgfdsdfghj:9022; +} + +upstream ghjk_upstream { + server ghjk:9023; +} + +server { + listen 80; + + + location /api/v1/hds { + proxy_pass http://hd_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/customer-services { + proxy_pass http://customer-service_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/product-services { + proxy_pass http://product-service_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/rbac-services { + proxy_pass http://rbac-service_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/payment-services { + proxy_pass http://payment-service_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/notification-services { + proxy_pass http://notification-service_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/email-services { + proxy_pass http://email-service_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/cart-services { + proxy_pass http://cart-service_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/carts { + proxy_pass http://cart_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/users { + proxy_pass http://user_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/customers { + proxy_pass http://customer_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/emails { + proxy_pass http://email_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/notifications { + proxy_pass http://notification_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/payments { + proxy_pass http://payment_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/products { + proxy_pass http://product_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/rbacs { + proxy_pass http://rbac_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/suppliers { + proxy_pass http://supplier_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/uploads { + proxy_pass http://upload_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/ths { + proxy_pass http://th_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/kjhgfs { + proxy_pass http://kjhgf_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/hhgfdsdfghjs { + proxy_pass http://hhgfdsdfghj_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/ghjks { + proxy_pass http://ghjk_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } +} \ No newline at end of file diff --git a/gateways/apps/gldg/docker-compose.dev.yml b/gateways/apps/gldg/docker-compose.dev.yml new file mode 100644 index 0000000..2e403c2 --- /dev/null +++ b/gateways/apps/gldg/docker-compose.dev.yml @@ -0,0 +1,367 @@ + +version: '3.8' +services: + + hd: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/hd + ports: + - "null:null" + volumes: + - /app/node_modules + - ../../../microservices/hd:/app + depends_on: + rabbitmq: + condition: service_healthy + + customer-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/customer-service + ports: + - "9000:9000" + volumes: + - /app/node_modules + - ../../../microservices/customer-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + product-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/product-service + ports: + - "9002:9002" + volumes: + - /app/node_modules + - ../../../microservices/product-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + rbac-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/rbac-service + ports: + - "9004:9004" + volumes: + - /app/node_modules + - ../../../microservices/rbac-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + payment-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/payment-service + ports: + - "9006:9006" + volumes: + - /app/node_modules + - ../../../microservices/payment-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + notification-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/notification-service + ports: + - "9007:9007" + volumes: + - /app/node_modules + - ../../../microservices/notification-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + email-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/email-service + ports: + - "9008:9008" + volumes: + - /app/node_modules + - ../../../microservices/email-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + cart-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/cart-service + ports: + - "9009:9009" + volumes: + - /app/node_modules + - ../../../microservices/cart-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + cart: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/cart + ports: + - "9010:9010" + volumes: + - /app/node_modules + - ../../../microservices/cart:/app + depends_on: + rabbitmq: + condition: service_healthy + + user: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/user + ports: + - "9011:9011" + volumes: + - /app/node_modules + - ../../../microservices/user:/app + depends_on: + rabbitmq: + condition: service_healthy + + customer: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/customer + ports: + - "9012:9012" + volumes: + - /app/node_modules + - ../../../microservices/customer:/app + depends_on: + rabbitmq: + condition: service_healthy + + email: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/email + ports: + - "9013:9013" + volumes: + - /app/node_modules + - ../../../microservices/email:/app + depends_on: + rabbitmq: + condition: service_healthy + + notification: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/notification + ports: + - "9014:9014" + volumes: + - /app/node_modules + - ../../../microservices/notification:/app + depends_on: + rabbitmq: + condition: service_healthy + + payment: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/payment + ports: + - "9015:9015" + volumes: + - /app/node_modules + - ../../../microservices/payment:/app + depends_on: + rabbitmq: + condition: service_healthy + + product: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/product + ports: + - "9016:9016" + volumes: + - /app/node_modules + - ../../../microservices/product:/app + depends_on: + rabbitmq: + condition: service_healthy + + rbac: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/rbac + ports: + - "9017:9017" + volumes: + - /app/node_modules + - ../../../microservices/rbac:/app + depends_on: + rabbitmq: + condition: service_healthy + + supplier: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/supplier + ports: + - "9018:9018" + volumes: + - /app/node_modules + - ../../../microservices/supplier:/app + depends_on: + rabbitmq: + condition: service_healthy + + upload: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/upload + ports: + - "9019:9019" + volumes: + - /app/node_modules + - ../../../microservices/upload:/app + depends_on: + rabbitmq: + condition: service_healthy + + th: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/th + ports: + - "9020:9020" + volumes: + - /app/node_modules + - ../../../microservices/th:/app + depends_on: + rabbitmq: + condition: service_healthy + + kjhgf: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/kjhgf + ports: + - "9021:9021" + volumes: + - /app/node_modules + - ../../../microservices/kjhgf:/app + depends_on: + rabbitmq: + condition: service_healthy + + hhgfdsdfghj: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/hhgfdsdfghj + ports: + - "9022:9022" + volumes: + - /app/node_modules + - ../../../microservices/hhgfdsdfghj:/app + depends_on: + rabbitmq: + condition: service_healthy + + ghjk: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/ghjk + ports: + - "9023:9023" + volumes: + - /app/node_modules + - ../../../microservices/ghjk:/app + depends_on: + rabbitmq: + condition: service_healthy + + shjksgd: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/shjksgd + ports: + - "30067:30067" + volumes: + - /app/node_modules + - ../../../microservices/shjksgd:/app + depends_on: + rabbitmq: + condition: service_healthy + + nginx: + depends_on: + - hd + - customer-service + - product-service + - rbac-service + - payment-service + - notification-service + - email-service + - cart-service + - cart + - user + - customer + - email + - notification + - payment + - product + - rbac + - supplier + - upload + - th + - kjhgf + - hhgfdsdfghj + - ghjk + - shjksgd + restart: always + build: + context: ./nginx + dockerfile: Dockerfile.dev + ports: + - '4000:80' + healthcheck: + test: ["CMD-SHELL", "curl -f http://localhost:80/health || exit 1"] + interval: 30s + timeout: 10s + retries: 3 + start_period: 40s + rabbitmq: + image: rabbitmq:3.13-management + container_name: rabbitmq + ports: + - '5672:5672' + - '15672:15672' + healthcheck: + test: ["CMD", "rabbitmq-diagnostics", "ping"] + interval: 30s + retries: 5 + mongodb: + image: mongo + ports: + - '27017:27017' + restart: always + volumes: + - type: bind + source: ./data + target: /data/db + krakend: + image: devopsfaith/krakend:2.7-watch + ports: + - '9000:9000' + - '8090:8090' + volumes: + - ./krakend/:/etc/krakend/ + command: ['run','-d','-c','/etc/krakend/krakend.json'] \ No newline at end of file diff --git a/gateways/apps/gldg/docker-compose.yml b/gateways/apps/gldg/docker-compose.yml new file mode 100644 index 0000000..f33baeb --- /dev/null +++ b/gateways/apps/gldg/docker-compose.yml @@ -0,0 +1,367 @@ + +version: '3.8' +services: + + hd: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/hd + ports: + - "null:null" + volumes: + - /app/node_modules + - ../../../microservices/hd:/app + depends_on: + rabbitmq: + condition: service_healthy + + customer-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/customer-service + ports: + - "9000:9000" + volumes: + - /app/node_modules + - ../../../microservices/customer-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + product-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/product-service + ports: + - "9002:9002" + volumes: + - /app/node_modules + - ../../../microservices/product-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + rbac-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/rbac-service + ports: + - "9004:9004" + volumes: + - /app/node_modules + - ../../../microservices/rbac-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + payment-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/payment-service + ports: + - "9006:9006" + volumes: + - /app/node_modules + - ../../../microservices/payment-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + notification-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/notification-service + ports: + - "9007:9007" + volumes: + - /app/node_modules + - ../../../microservices/notification-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + email-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/email-service + ports: + - "9008:9008" + volumes: + - /app/node_modules + - ../../../microservices/email-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + cart-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/cart-service + ports: + - "9009:9009" + volumes: + - /app/node_modules + - ../../../microservices/cart-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + cart: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/cart + ports: + - "9010:9010" + volumes: + - /app/node_modules + - ../../../microservices/cart:/app + depends_on: + rabbitmq: + condition: service_healthy + + user: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/user + ports: + - "9011:9011" + volumes: + - /app/node_modules + - ../../../microservices/user:/app + depends_on: + rabbitmq: + condition: service_healthy + + customer: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/customer + ports: + - "9012:9012" + volumes: + - /app/node_modules + - ../../../microservices/customer:/app + depends_on: + rabbitmq: + condition: service_healthy + + email: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/email + ports: + - "9013:9013" + volumes: + - /app/node_modules + - ../../../microservices/email:/app + depends_on: + rabbitmq: + condition: service_healthy + + notification: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/notification + ports: + - "9014:9014" + volumes: + - /app/node_modules + - ../../../microservices/notification:/app + depends_on: + rabbitmq: + condition: service_healthy + + payment: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/payment + ports: + - "9015:9015" + volumes: + - /app/node_modules + - ../../../microservices/payment:/app + depends_on: + rabbitmq: + condition: service_healthy + + product: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/product + ports: + - "9016:9016" + volumes: + - /app/node_modules + - ../../../microservices/product:/app + depends_on: + rabbitmq: + condition: service_healthy + + rbac: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/rbac + ports: + - "9017:9017" + volumes: + - /app/node_modules + - ../../../microservices/rbac:/app + depends_on: + rabbitmq: + condition: service_healthy + + supplier: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/supplier + ports: + - "9018:9018" + volumes: + - /app/node_modules + - ../../../microservices/supplier:/app + depends_on: + rabbitmq: + condition: service_healthy + + upload: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/upload + ports: + - "9019:9019" + volumes: + - /app/node_modules + - ../../../microservices/upload:/app + depends_on: + rabbitmq: + condition: service_healthy + + th: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/th + ports: + - "9020:9020" + volumes: + - /app/node_modules + - ../../../microservices/th:/app + depends_on: + rabbitmq: + condition: service_healthy + + kjhgf: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/kjhgf + ports: + - "9021:9021" + volumes: + - /app/node_modules + - ../../../microservices/kjhgf:/app + depends_on: + rabbitmq: + condition: service_healthy + + hhgfdsdfghj: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/hhgfdsdfghj + ports: + - "9022:9022" + volumes: + - /app/node_modules + - ../../../microservices/hhgfdsdfghj:/app + depends_on: + rabbitmq: + condition: service_healthy + + ghjk: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/ghjk + ports: + - "9023:9023" + volumes: + - /app/node_modules + - ../../../microservices/ghjk:/app + depends_on: + rabbitmq: + condition: service_healthy + + shjksgd: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/shjksgd + ports: + - "30067:30067" + volumes: + - /app/node_modules + - ../../../microservices/shjksgd:/app + depends_on: + rabbitmq: + condition: service_healthy + + nginx: + depends_on: + - hd + - customer-service + - product-service + - rbac-service + - payment-service + - notification-service + - email-service + - cart-service + - cart + - user + - customer + - email + - notification + - payment + - product + - rbac + - supplier + - upload + - th + - kjhgf + - hhgfdsdfghj + - ghjk + - shjksgd + restart: always + build: + context: ./nginx + dockerfile: Dockerfile.dev + ports: + - '4000:80' + healthcheck: + test: ["CMD-SHELL", "curl -f http://localhost:80/health || exit 1"] + interval: 30s + timeout: 10s + retries: 3 + start_period: 40s + rabbitmq: + image: rabbitmq:3.13-management + container_name: rabbitmq + ports: + - '5672:5672' + - '15672:15672' + healthcheck: + test: ["CMD", "rabbitmq-diagnostics", "ping"] + interval: 30s + retries: 5 + mongodb: + image: mongo + ports: + - '27017:27017' + restart: always + volumes: + - type: bind + source: ./data + target: /data/db + krakend: + image: devopsfaith/krakend:2.7 + ports: + - '9000:9000' + - '8090:8090' + volumes: + - ./krakend/:/etc/krakend/ + command: ['run','-d','-c','/etc/krakend/krakend.json'] \ No newline at end of file diff --git a/gateways/apps/gldg/krakend/krakend.json b/gateways/apps/gldg/krakend/krakend.json new file mode 100644 index 0000000..5e3320a --- /dev/null +++ b/gateways/apps/gldg/krakend/krakend.json @@ -0,0 +1,402 @@ + +{ + "$schema": "https://www.krakend.io/schema/v2.5/krakend.json", + "version": 3, + "name": "Microservices-suite API Gateway", + "port": 9000, + "cache_ttl": "3600s", + "timeout": "300s", + "endpoints": [ + { + "@comment": "Check the health of all your APIs", + "endpoint": "/__suite_status", + "method": "GET", + "backend": [ + { + "host": ["http://hd:null"], + "url_pattern": "/", + "mapping": { + "message": "hd" + } + }, + + { + "host": ["http://customer-service:9000"], + "url_pattern": "/", + "mapping": { + "message": "customer-service" + } + }, + + { + "host": ["http://product-service:9002"], + "url_pattern": "/", + "mapping": { + "message": "product-service" + } + }, + + { + "host": ["http://rbac-service:9004"], + "url_pattern": "/", + "mapping": { + "message": "rbac-service" + } + }, + + { + "host": ["http://payment-service:9006"], + "url_pattern": "/", + "mapping": { + "message": "payment-service" + } + }, + + { + "host": ["http://notification-service:9007"], + "url_pattern": "/", + "mapping": { + "message": "notification-service" + } + }, + + { + "host": ["http://email-service:9008"], + "url_pattern": "/", + "mapping": { + "message": "email-service" + } + }, + + { + "host": ["http://cart-service:9009"], + "url_pattern": "/", + "mapping": { + "message": "cart-service" + } + }, + + { + "host": ["http://cart:9010"], + "url_pattern": "/", + "mapping": { + "message": "cart" + } + }, + + { + "host": ["http://user:9011"], + "url_pattern": "/", + "mapping": { + "message": "user" + } + }, + + { + "host": ["http://customer:9012"], + "url_pattern": "/", + "mapping": { + "message": "customer" + } + }, + + { + "host": ["http://email:9013"], + "url_pattern": "/", + "mapping": { + "message": "email" + } + }, + + { + "host": ["http://notification:9014"], + "url_pattern": "/", + "mapping": { + "message": "notification" + } + }, + + { + "host": ["http://payment:9015"], + "url_pattern": "/", + "mapping": { + "message": "payment" + } + }, + + { + "host": ["http://product:9016"], + "url_pattern": "/", + "mapping": { + "message": "product" + } + }, + + { + "host": ["http://rbac:9017"], + "url_pattern": "/", + "mapping": { + "message": "rbac" + } + }, + + { + "host": ["http://supplier:9018"], + "url_pattern": "/", + "mapping": { + "message": "supplier" + } + }, + + { + "host": ["http://upload:9019"], + "url_pattern": "/", + "mapping": { + "message": "upload" + } + }, + + { + "host": ["http://th:9020"], + "url_pattern": "/", + "mapping": { + "message": "th" + } + }, + + { + "host": ["http://kjhgf:9021"], + "url_pattern": "/", + "mapping": { + "message": "kjhgf" + } + }, + + { + "host": ["http://hhgfdsdfghj:9022"], + "url_pattern": "/", + "mapping": { + "message": "hhgfdsdfghj" + } + }, + + { + "host": ["http://ghjk:9023"], + "url_pattern": "/", + "mapping": { + "message": "ghjk" + } + }, + + { + "host": ["http://shjksgd:30067"], + "url_pattern": "/", + "mapping": { + "message": "shjksgd" + } + }] + }, + { + "@comment": "Hit all API list endpoints simultaneously", + "endpoint": "/api/v1/", + "method": "GET", + "backend": [ + { + "host": ["http://hd:null"], + "url_pattern": "/api/v1/hds", + "mapping": { + "data": "hds" + } + }, + + { + "host": ["http://customer-service:9000"], + "url_pattern": "/api/v1/customer-services", + "mapping": { + "data": "customer-services" + } + }, + + { + "host": ["http://product-service:9002"], + "url_pattern": "/api/v1/product-services", + "mapping": { + "data": "product-services" + } + }, + + { + "host": ["http://rbac-service:9004"], + "url_pattern": "/api/v1/rbac-services", + "mapping": { + "data": "rbac-services" + } + }, + + { + "host": ["http://payment-service:9006"], + "url_pattern": "/api/v1/payment-services", + "mapping": { + "data": "payment-services" + } + }, + + { + "host": ["http://notification-service:9007"], + "url_pattern": "/api/v1/notification-services", + "mapping": { + "data": "notification-services" + } + }, + + { + "host": ["http://email-service:9008"], + "url_pattern": "/api/v1/email-services", + "mapping": { + "data": "email-services" + } + }, + + { + "host": ["http://cart-service:9009"], + "url_pattern": "/api/v1/cart-services", + "mapping": { + "data": "cart-services" + } + }, + + { + "host": ["http://cart:9010"], + "url_pattern": "/api/v1/carts", + "mapping": { + "data": "carts" + } + }, + + { + "host": ["http://user:9011"], + "url_pattern": "/api/v1/users", + "mapping": { + "data": "users" + } + }, + + { + "host": ["http://customer:9012"], + "url_pattern": "/api/v1/customers", + "mapping": { + "data": "customers" + } + }, + + { + "host": ["http://email:9013"], + "url_pattern": "/api/v1/emails", + "mapping": { + "data": "emails" + } + }, + + { + "host": ["http://notification:9014"], + "url_pattern": "/api/v1/notifications", + "mapping": { + "data": "notifications" + } + }, + + { + "host": ["http://payment:9015"], + "url_pattern": "/api/v1/payments", + "mapping": { + "data": "payments" + } + }, + + { + "host": ["http://product:9016"], + "url_pattern": "/api/v1/products", + "mapping": { + "data": "products" + } + }, + + { + "host": ["http://rbac:9017"], + "url_pattern": "/api/v1/rbacs", + "mapping": { + "data": "rbacs" + } + }, + + { + "host": ["http://supplier:9018"], + "url_pattern": "/api/v1/suppliers", + "mapping": { + "data": "suppliers" + } + }, + + { + "host": ["http://upload:9019"], + "url_pattern": "/api/v1/uploads", + "mapping": { + "data": "uploads" + } + }, + + { + "host": ["http://th:9020"], + "url_pattern": "/api/v1/ths", + "mapping": { + "data": "ths" + } + }, + + { + "host": ["http://kjhgf:9021"], + "url_pattern": "/api/v1/kjhgfs", + "mapping": { + "data": "kjhgfs" + } + }, + + { + "host": ["http://hhgfdsdfghj:9022"], + "url_pattern": "/api/v1/hhgfdsdfghjs", + "mapping": { + "data": "hhgfdsdfghjs" + } + }, + + { + "host": ["http://ghjk:9023"], + "url_pattern": "/api/v1/ghjks", + "mapping": { + "data": "ghjks" + } + }, + + { + "host": ["http://shjksgd:30067"], + "url_pattern": "/api/v1/shjksgds", + "mapping": { + "data": "shjksgds" + } + }] + }, + { + "@comment": "Fetch all data from the hd service", + "endpoint": "/api/v1/hds", + "method": "GET", + "backend": [ + { + "host": ["http://hd:null"], + "url_pattern": "/api/v1/hds", + "mapping": { + "data": "hds" + } + }] + } + ] +} \ No newline at end of file diff --git a/gateways/apps/gldg/nginx/Dockerfile b/gateways/apps/gldg/nginx/Dockerfile new file mode 100644 index 0000000..ddf7281 --- /dev/null +++ b/gateways/apps/gldg/nginx/Dockerfile @@ -0,0 +1,3 @@ + +FROM nginx +COPY ./default.conf /etc/nginx/conf.d/default.conf \ No newline at end of file diff --git a/gateways/apps/gldg/nginx/Dockerfile.dev b/gateways/apps/gldg/nginx/Dockerfile.dev new file mode 100644 index 0000000..ddf7281 --- /dev/null +++ b/gateways/apps/gldg/nginx/Dockerfile.dev @@ -0,0 +1,3 @@ + +FROM nginx +COPY ./default.conf /etc/nginx/conf.d/default.conf \ No newline at end of file diff --git a/gateways/apps/gldg/nginx/default.conf b/gateways/apps/gldg/nginx/default.conf new file mode 100644 index 0000000..d4dace0 --- /dev/null +++ b/gateways/apps/gldg/nginx/default.conf @@ -0,0 +1,282 @@ + + +upstream hd_upstream { + server hd:null; +} + +upstream customer-service_upstream { + server customer-service:9000; +} + +upstream product-service_upstream { + server product-service:9002; +} + +upstream rbac-service_upstream { + server rbac-service:9004; +} + +upstream payment-service_upstream { + server payment-service:9006; +} + +upstream notification-service_upstream { + server notification-service:9007; +} + +upstream email-service_upstream { + server email-service:9008; +} + +upstream cart-service_upstream { + server cart-service:9009; +} + +upstream cart_upstream { + server cart:9010; +} + +upstream user_upstream { + server user:9011; +} + +upstream customer_upstream { + server customer:9012; +} + +upstream email_upstream { + server email:9013; +} + +upstream notification_upstream { + server notification:9014; +} + +upstream payment_upstream { + server payment:9015; +} + +upstream product_upstream { + server product:9016; +} + +upstream rbac_upstream { + server rbac:9017; +} + +upstream supplier_upstream { + server supplier:9018; +} + +upstream upload_upstream { + server upload:9019; +} + +upstream th_upstream { + server th:9020; +} + +upstream kjhgf_upstream { + server kjhgf:9021; +} + +upstream hhgfdsdfghj_upstream { + server hhgfdsdfghj:9022; +} + +upstream ghjk_upstream { + server ghjk:9023; +} + +upstream shjksgd_upstream { + server shjksgd:30067; +} + +server { + listen 80; + + + location /api/v1/hds { + proxy_pass http://hd_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/customer-services { + proxy_pass http://customer-service_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/product-services { + proxy_pass http://product-service_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/rbac-services { + proxy_pass http://rbac-service_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/payment-services { + proxy_pass http://payment-service_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/notification-services { + proxy_pass http://notification-service_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/email-services { + proxy_pass http://email-service_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/cart-services { + proxy_pass http://cart-service_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/carts { + proxy_pass http://cart_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/users { + proxy_pass http://user_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/customers { + proxy_pass http://customer_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/emails { + proxy_pass http://email_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/notifications { + proxy_pass http://notification_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/payments { + proxy_pass http://payment_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/products { + proxy_pass http://product_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/rbacs { + proxy_pass http://rbac_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/suppliers { + proxy_pass http://supplier_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/uploads { + proxy_pass http://upload_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/ths { + proxy_pass http://th_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/kjhgfs { + proxy_pass http://kjhgf_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/hhgfdsdfghjs { + proxy_pass http://hhgfdsdfghj_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/ghjks { + proxy_pass http://ghjk_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/shjksgds { + proxy_pass http://shjksgd_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } +} \ No newline at end of file diff --git a/gateways/apps/hghjgfh/docker-compose.dev.yml b/gateways/apps/hghjgfh/docker-compose.dev.yml new file mode 100644 index 0000000..03a3b30 --- /dev/null +++ b/gateways/apps/hghjgfh/docker-compose.dev.yml @@ -0,0 +1,353 @@ + +version: '3.8' +services: + + hd: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/hd + ports: + - "null:null" + volumes: + - /app/node_modules + - ../../../microservices/hd:/app + depends_on: + rabbitmq: + condition: service_healthy + + customer-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/customer-service + ports: + - "9000:9000" + volumes: + - /app/node_modules + - ../../../microservices/customer-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + product-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/product-service + ports: + - "9002:9002" + volumes: + - /app/node_modules + - ../../../microservices/product-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + rbac-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/rbac-service + ports: + - "9004:9004" + volumes: + - /app/node_modules + - ../../../microservices/rbac-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + payment-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/payment-service + ports: + - "9006:9006" + volumes: + - /app/node_modules + - ../../../microservices/payment-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + notification-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/notification-service + ports: + - "9007:9007" + volumes: + - /app/node_modules + - ../../../microservices/notification-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + email-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/email-service + ports: + - "9008:9008" + volumes: + - /app/node_modules + - ../../../microservices/email-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + cart-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/cart-service + ports: + - "9009:9009" + volumes: + - /app/node_modules + - ../../../microservices/cart-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + cart: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/cart + ports: + - "9010:9010" + volumes: + - /app/node_modules + - ../../../microservices/cart:/app + depends_on: + rabbitmq: + condition: service_healthy + + user: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/user + ports: + - "9011:9011" + volumes: + - /app/node_modules + - ../../../microservices/user:/app + depends_on: + rabbitmq: + condition: service_healthy + + customer: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/customer + ports: + - "9012:9012" + volumes: + - /app/node_modules + - ../../../microservices/customer:/app + depends_on: + rabbitmq: + condition: service_healthy + + email: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/email + ports: + - "9013:9013" + volumes: + - /app/node_modules + - ../../../microservices/email:/app + depends_on: + rabbitmq: + condition: service_healthy + + notification: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/notification + ports: + - "9014:9014" + volumes: + - /app/node_modules + - ../../../microservices/notification:/app + depends_on: + rabbitmq: + condition: service_healthy + + payment: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/payment + ports: + - "9015:9015" + volumes: + - /app/node_modules + - ../../../microservices/payment:/app + depends_on: + rabbitmq: + condition: service_healthy + + product: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/product + ports: + - "9016:9016" + volumes: + - /app/node_modules + - ../../../microservices/product:/app + depends_on: + rabbitmq: + condition: service_healthy + + rbac: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/rbac + ports: + - "9017:9017" + volumes: + - /app/node_modules + - ../../../microservices/rbac:/app + depends_on: + rabbitmq: + condition: service_healthy + + supplier: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/supplier + ports: + - "9018:9018" + volumes: + - /app/node_modules + - ../../../microservices/supplier:/app + depends_on: + rabbitmq: + condition: service_healthy + + upload: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/upload + ports: + - "9019:9019" + volumes: + - /app/node_modules + - ../../../microservices/upload:/app + depends_on: + rabbitmq: + condition: service_healthy + + th: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/th + ports: + - "9020:9020" + volumes: + - /app/node_modules + - ../../../microservices/th:/app + depends_on: + rabbitmq: + condition: service_healthy + + kjhgf: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/kjhgf + ports: + - "9021:9021" + volumes: + - /app/node_modules + - ../../../microservices/kjhgf:/app + depends_on: + rabbitmq: + condition: service_healthy + + hhgfdsdfghj: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/hhgfdsdfghj + ports: + - "9022:9022" + volumes: + - /app/node_modules + - ../../../microservices/hhgfdsdfghj:/app + depends_on: + rabbitmq: + condition: service_healthy + + ghjk: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/ghjk + ports: + - "9023:9023" + volumes: + - /app/node_modules + - ../../../microservices/ghjk:/app + depends_on: + rabbitmq: + condition: service_healthy + + nginx: + depends_on: + - hd + - customer-service + - product-service + - rbac-service + - payment-service + - notification-service + - email-service + - cart-service + - cart + - user + - customer + - email + - notification + - payment + - product + - rbac + - supplier + - upload + - th + - kjhgf + - hhgfdsdfghj + - ghjk + restart: always + build: + context: ./nginx + dockerfile: Dockerfile.dev + ports: + - '4000:80' + healthcheck: + test: ["CMD-SHELL", "curl -f http://localhost:80/health || exit 1"] + interval: 30s + timeout: 10s + retries: 3 + start_period: 40s + rabbitmq: + image: rabbitmq:3.13-management + container_name: rabbitmq + ports: + - '5672:5672' + - '15672:15672' + healthcheck: + test: ["CMD", "rabbitmq-diagnostics", "ping"] + interval: 30s + retries: 5 + mongodb: + image: mongo + ports: + - '27017:27017' + restart: always + volumes: + - type: bind + source: ./data + target: /data/db + krakend: + image: devopsfaith/krakend:2.7-watch + ports: + - '9001:9001' + - '8090:8090' + volumes: + - ./krakend/:/etc/krakend/ + command: ['run','-d','-c','/etc/krakend/krakend.json'] \ No newline at end of file diff --git a/gateways/apps/hghjgfh/docker-compose.yml b/gateways/apps/hghjgfh/docker-compose.yml new file mode 100644 index 0000000..f11f17d --- /dev/null +++ b/gateways/apps/hghjgfh/docker-compose.yml @@ -0,0 +1,353 @@ + +version: '3.8' +services: + + hd: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/hd + ports: + - "null:null" + volumes: + - /app/node_modules + - ../../../microservices/hd:/app + depends_on: + rabbitmq: + condition: service_healthy + + customer-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/customer-service + ports: + - "9000:9000" + volumes: + - /app/node_modules + - ../../../microservices/customer-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + product-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/product-service + ports: + - "9002:9002" + volumes: + - /app/node_modules + - ../../../microservices/product-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + rbac-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/rbac-service + ports: + - "9004:9004" + volumes: + - /app/node_modules + - ../../../microservices/rbac-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + payment-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/payment-service + ports: + - "9006:9006" + volumes: + - /app/node_modules + - ../../../microservices/payment-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + notification-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/notification-service + ports: + - "9007:9007" + volumes: + - /app/node_modules + - ../../../microservices/notification-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + email-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/email-service + ports: + - "9008:9008" + volumes: + - /app/node_modules + - ../../../microservices/email-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + cart-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/cart-service + ports: + - "9009:9009" + volumes: + - /app/node_modules + - ../../../microservices/cart-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + cart: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/cart + ports: + - "9010:9010" + volumes: + - /app/node_modules + - ../../../microservices/cart:/app + depends_on: + rabbitmq: + condition: service_healthy + + user: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/user + ports: + - "9011:9011" + volumes: + - /app/node_modules + - ../../../microservices/user:/app + depends_on: + rabbitmq: + condition: service_healthy + + customer: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/customer + ports: + - "9012:9012" + volumes: + - /app/node_modules + - ../../../microservices/customer:/app + depends_on: + rabbitmq: + condition: service_healthy + + email: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/email + ports: + - "9013:9013" + volumes: + - /app/node_modules + - ../../../microservices/email:/app + depends_on: + rabbitmq: + condition: service_healthy + + notification: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/notification + ports: + - "9014:9014" + volumes: + - /app/node_modules + - ../../../microservices/notification:/app + depends_on: + rabbitmq: + condition: service_healthy + + payment: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/payment + ports: + - "9015:9015" + volumes: + - /app/node_modules + - ../../../microservices/payment:/app + depends_on: + rabbitmq: + condition: service_healthy + + product: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/product + ports: + - "9016:9016" + volumes: + - /app/node_modules + - ../../../microservices/product:/app + depends_on: + rabbitmq: + condition: service_healthy + + rbac: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/rbac + ports: + - "9017:9017" + volumes: + - /app/node_modules + - ../../../microservices/rbac:/app + depends_on: + rabbitmq: + condition: service_healthy + + supplier: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/supplier + ports: + - "9018:9018" + volumes: + - /app/node_modules + - ../../../microservices/supplier:/app + depends_on: + rabbitmq: + condition: service_healthy + + upload: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/upload + ports: + - "9019:9019" + volumes: + - /app/node_modules + - ../../../microservices/upload:/app + depends_on: + rabbitmq: + condition: service_healthy + + th: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/th + ports: + - "9020:9020" + volumes: + - /app/node_modules + - ../../../microservices/th:/app + depends_on: + rabbitmq: + condition: service_healthy + + kjhgf: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/kjhgf + ports: + - "9021:9021" + volumes: + - /app/node_modules + - ../../../microservices/kjhgf:/app + depends_on: + rabbitmq: + condition: service_healthy + + hhgfdsdfghj: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/hhgfdsdfghj + ports: + - "9022:9022" + volumes: + - /app/node_modules + - ../../../microservices/hhgfdsdfghj:/app + depends_on: + rabbitmq: + condition: service_healthy + + ghjk: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/ghjk + ports: + - "9023:9023" + volumes: + - /app/node_modules + - ../../../microservices/ghjk:/app + depends_on: + rabbitmq: + condition: service_healthy + + nginx: + depends_on: + - hd + - customer-service + - product-service + - rbac-service + - payment-service + - notification-service + - email-service + - cart-service + - cart + - user + - customer + - email + - notification + - payment + - product + - rbac + - supplier + - upload + - th + - kjhgf + - hhgfdsdfghj + - ghjk + restart: always + build: + context: ./nginx + dockerfile: Dockerfile.dev + ports: + - '4000:80' + healthcheck: + test: ["CMD-SHELL", "curl -f http://localhost:80/health || exit 1"] + interval: 30s + timeout: 10s + retries: 3 + start_period: 40s + rabbitmq: + image: rabbitmq:3.13-management + container_name: rabbitmq + ports: + - '5672:5672' + - '15672:15672' + healthcheck: + test: ["CMD", "rabbitmq-diagnostics", "ping"] + interval: 30s + retries: 5 + mongodb: + image: mongo + ports: + - '27017:27017' + restart: always + volumes: + - type: bind + source: ./data + target: /data/db + krakend: + image: devopsfaith/krakend:2.7 + ports: + - '9001:9001' + - '8090:8090' + volumes: + - ./krakend/:/etc/krakend/ + command: ['run','-d','-c','/etc/krakend/krakend.json'] \ No newline at end of file diff --git a/gateways/apps/hghjgfh/krakend/krakend.json b/gateways/apps/hghjgfh/krakend/krakend.json new file mode 100644 index 0000000..bb3daec --- /dev/null +++ b/gateways/apps/hghjgfh/krakend/krakend.json @@ -0,0 +1,386 @@ + +{ + "$schema": "https://www.krakend.io/schema/v2.5/krakend.json", + "version": 3, + "name": "Microservices-suite API Gateway", + "port": 9001, + "cache_ttl": "3600s", + "timeout": "300s", + "endpoints": [ + { + "@comment": "Check the health of all your APIs", + "endpoint": "/__suite_status", + "method": "GET", + "backend": [ + { + "host": ["http://hd:null"], + "url_pattern": "/", + "mapping": { + "message": "hd" + } + }, + + { + "host": ["http://customer-service:9000"], + "url_pattern": "/", + "mapping": { + "message": "customer-service" + } + }, + + { + "host": ["http://product-service:9002"], + "url_pattern": "/", + "mapping": { + "message": "product-service" + } + }, + + { + "host": ["http://rbac-service:9004"], + "url_pattern": "/", + "mapping": { + "message": "rbac-service" + } + }, + + { + "host": ["http://payment-service:9006"], + "url_pattern": "/", + "mapping": { + "message": "payment-service" + } + }, + + { + "host": ["http://notification-service:9007"], + "url_pattern": "/", + "mapping": { + "message": "notification-service" + } + }, + + { + "host": ["http://email-service:9008"], + "url_pattern": "/", + "mapping": { + "message": "email-service" + } + }, + + { + "host": ["http://cart-service:9009"], + "url_pattern": "/", + "mapping": { + "message": "cart-service" + } + }, + + { + "host": ["http://cart:9010"], + "url_pattern": "/", + "mapping": { + "message": "cart" + } + }, + + { + "host": ["http://user:9011"], + "url_pattern": "/", + "mapping": { + "message": "user" + } + }, + + { + "host": ["http://customer:9012"], + "url_pattern": "/", + "mapping": { + "message": "customer" + } + }, + + { + "host": ["http://email:9013"], + "url_pattern": "/", + "mapping": { + "message": "email" + } + }, + + { + "host": ["http://notification:9014"], + "url_pattern": "/", + "mapping": { + "message": "notification" + } + }, + + { + "host": ["http://payment:9015"], + "url_pattern": "/", + "mapping": { + "message": "payment" + } + }, + + { + "host": ["http://product:9016"], + "url_pattern": "/", + "mapping": { + "message": "product" + } + }, + + { + "host": ["http://rbac:9017"], + "url_pattern": "/", + "mapping": { + "message": "rbac" + } + }, + + { + "host": ["http://supplier:9018"], + "url_pattern": "/", + "mapping": { + "message": "supplier" + } + }, + + { + "host": ["http://upload:9019"], + "url_pattern": "/", + "mapping": { + "message": "upload" + } + }, + + { + "host": ["http://th:9020"], + "url_pattern": "/", + "mapping": { + "message": "th" + } + }, + + { + "host": ["http://kjhgf:9021"], + "url_pattern": "/", + "mapping": { + "message": "kjhgf" + } + }, + + { + "host": ["http://hhgfdsdfghj:9022"], + "url_pattern": "/", + "mapping": { + "message": "hhgfdsdfghj" + } + }, + + { + "host": ["http://ghjk:9023"], + "url_pattern": "/", + "mapping": { + "message": "ghjk" + } + }] + }, + { + "@comment": "Hit all API list endpoints simultaneously", + "endpoint": "/api/v1/", + "method": "GET", + "backend": [ + { + "host": ["http://hd:null"], + "url_pattern": "/api/v1/hds", + "mapping": { + "data": "hds" + } + }, + + { + "host": ["http://customer-service:9000"], + "url_pattern": "/api/v1/customer-services", + "mapping": { + "data": "customer-services" + } + }, + + { + "host": ["http://product-service:9002"], + "url_pattern": "/api/v1/product-services", + "mapping": { + "data": "product-services" + } + }, + + { + "host": ["http://rbac-service:9004"], + "url_pattern": "/api/v1/rbac-services", + "mapping": { + "data": "rbac-services" + } + }, + + { + "host": ["http://payment-service:9006"], + "url_pattern": "/api/v1/payment-services", + "mapping": { + "data": "payment-services" + } + }, + + { + "host": ["http://notification-service:9007"], + "url_pattern": "/api/v1/notification-services", + "mapping": { + "data": "notification-services" + } + }, + + { + "host": ["http://email-service:9008"], + "url_pattern": "/api/v1/email-services", + "mapping": { + "data": "email-services" + } + }, + + { + "host": ["http://cart-service:9009"], + "url_pattern": "/api/v1/cart-services", + "mapping": { + "data": "cart-services" + } + }, + + { + "host": ["http://cart:9010"], + "url_pattern": "/api/v1/carts", + "mapping": { + "data": "carts" + } + }, + + { + "host": ["http://user:9011"], + "url_pattern": "/api/v1/users", + "mapping": { + "data": "users" + } + }, + + { + "host": ["http://customer:9012"], + "url_pattern": "/api/v1/customers", + "mapping": { + "data": "customers" + } + }, + + { + "host": ["http://email:9013"], + "url_pattern": "/api/v1/emails", + "mapping": { + "data": "emails" + } + }, + + { + "host": ["http://notification:9014"], + "url_pattern": "/api/v1/notifications", + "mapping": { + "data": "notifications" + } + }, + + { + "host": ["http://payment:9015"], + "url_pattern": "/api/v1/payments", + "mapping": { + "data": "payments" + } + }, + + { + "host": ["http://product:9016"], + "url_pattern": "/api/v1/products", + "mapping": { + "data": "products" + } + }, + + { + "host": ["http://rbac:9017"], + "url_pattern": "/api/v1/rbacs", + "mapping": { + "data": "rbacs" + } + }, + + { + "host": ["http://supplier:9018"], + "url_pattern": "/api/v1/suppliers", + "mapping": { + "data": "suppliers" + } + }, + + { + "host": ["http://upload:9019"], + "url_pattern": "/api/v1/uploads", + "mapping": { + "data": "uploads" + } + }, + + { + "host": ["http://th:9020"], + "url_pattern": "/api/v1/ths", + "mapping": { + "data": "ths" + } + }, + + { + "host": ["http://kjhgf:9021"], + "url_pattern": "/api/v1/kjhgfs", + "mapping": { + "data": "kjhgfs" + } + }, + + { + "host": ["http://hhgfdsdfghj:9022"], + "url_pattern": "/api/v1/hhgfdsdfghjs", + "mapping": { + "data": "hhgfdsdfghjs" + } + }, + + { + "host": ["http://ghjk:9023"], + "url_pattern": "/api/v1/ghjks", + "mapping": { + "data": "ghjks" + } + }] + }, + { + "@comment": "Fetch all data from the hd service", + "endpoint": "/api/v1/hds", + "method": "GET", + "backend": [ + { + "host": ["http://hd:null"], + "url_pattern": "/api/v1/hds", + "mapping": { + "data": "hds" + } + }] + } + ] +} \ No newline at end of file diff --git a/gateways/apps/hghjgfh/nginx/Dockerfile b/gateways/apps/hghjgfh/nginx/Dockerfile new file mode 100644 index 0000000..ddf7281 --- /dev/null +++ b/gateways/apps/hghjgfh/nginx/Dockerfile @@ -0,0 +1,3 @@ + +FROM nginx +COPY ./default.conf /etc/nginx/conf.d/default.conf \ No newline at end of file diff --git a/gateways/apps/hghjgfh/nginx/Dockerfile.dev b/gateways/apps/hghjgfh/nginx/Dockerfile.dev new file mode 100644 index 0000000..ddf7281 --- /dev/null +++ b/gateways/apps/hghjgfh/nginx/Dockerfile.dev @@ -0,0 +1,3 @@ + +FROM nginx +COPY ./default.conf /etc/nginx/conf.d/default.conf \ No newline at end of file diff --git a/gateways/apps/hghjgfh/nginx/default.conf b/gateways/apps/hghjgfh/nginx/default.conf new file mode 100644 index 0000000..b25033b --- /dev/null +++ b/gateways/apps/hghjgfh/nginx/default.conf @@ -0,0 +1,270 @@ + + +upstream hd_upstream { + server hd:null; +} + +upstream customer-service_upstream { + server customer-service:9000; +} + +upstream product-service_upstream { + server product-service:9002; +} + +upstream rbac-service_upstream { + server rbac-service:9004; +} + +upstream payment-service_upstream { + server payment-service:9006; +} + +upstream notification-service_upstream { + server notification-service:9007; +} + +upstream email-service_upstream { + server email-service:9008; +} + +upstream cart-service_upstream { + server cart-service:9009; +} + +upstream cart_upstream { + server cart:9010; +} + +upstream user_upstream { + server user:9011; +} + +upstream customer_upstream { + server customer:9012; +} + +upstream email_upstream { + server email:9013; +} + +upstream notification_upstream { + server notification:9014; +} + +upstream payment_upstream { + server payment:9015; +} + +upstream product_upstream { + server product:9016; +} + +upstream rbac_upstream { + server rbac:9017; +} + +upstream supplier_upstream { + server supplier:9018; +} + +upstream upload_upstream { + server upload:9019; +} + +upstream th_upstream { + server th:9020; +} + +upstream kjhgf_upstream { + server kjhgf:9021; +} + +upstream hhgfdsdfghj_upstream { + server hhgfdsdfghj:9022; +} + +upstream ghjk_upstream { + server ghjk:9023; +} + +server { + listen 80; + + + location /api/v1/hds { + proxy_pass http://hd_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/customer-services { + proxy_pass http://customer-service_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/product-services { + proxy_pass http://product-service_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/rbac-services { + proxy_pass http://rbac-service_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/payment-services { + proxy_pass http://payment-service_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/notification-services { + proxy_pass http://notification-service_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/email-services { + proxy_pass http://email-service_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/cart-services { + proxy_pass http://cart-service_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/carts { + proxy_pass http://cart_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/users { + proxy_pass http://user_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/customers { + proxy_pass http://customer_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/emails { + proxy_pass http://email_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/notifications { + proxy_pass http://notification_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/payments { + proxy_pass http://payment_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/products { + proxy_pass http://product_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/rbacs { + proxy_pass http://rbac_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/suppliers { + proxy_pass http://supplier_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/uploads { + proxy_pass http://upload_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/ths { + proxy_pass http://th_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/kjhgfs { + proxy_pass http://kjhgf_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/hhgfdsdfghjs { + proxy_pass http://hhgfdsdfghj_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/ghjks { + proxy_pass http://ghjk_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } +} \ No newline at end of file diff --git a/gateways/apps/hkd/docker-compose.dev.yml b/gateways/apps/hkd/docker-compose.dev.yml new file mode 100644 index 0000000..8f4f751 --- /dev/null +++ b/gateways/apps/hkd/docker-compose.dev.yml @@ -0,0 +1,367 @@ + +version: '3.8' +services: + + hd: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/hd + ports: + - "null:null" + volumes: + - /app/node_modules + - ../../../microservices/hd:/app + depends_on: + rabbitmq: + condition: service_healthy + + customer-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/customer-service + ports: + - "9000:9000" + volumes: + - /app/node_modules + - ../../../microservices/customer-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + product-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/product-service + ports: + - "9002:9002" + volumes: + - /app/node_modules + - ../../../microservices/product-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + rbac-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/rbac-service + ports: + - "9004:9004" + volumes: + - /app/node_modules + - ../../../microservices/rbac-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + payment-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/payment-service + ports: + - "9006:9006" + volumes: + - /app/node_modules + - ../../../microservices/payment-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + notification-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/notification-service + ports: + - "9007:9007" + volumes: + - /app/node_modules + - ../../../microservices/notification-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + email-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/email-service + ports: + - "9008:9008" + volumes: + - /app/node_modules + - ../../../microservices/email-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + cart-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/cart-service + ports: + - "9009:9009" + volumes: + - /app/node_modules + - ../../../microservices/cart-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + cart: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/cart + ports: + - "9010:9010" + volumes: + - /app/node_modules + - ../../../microservices/cart:/app + depends_on: + rabbitmq: + condition: service_healthy + + user: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/user + ports: + - "9011:9011" + volumes: + - /app/node_modules + - ../../../microservices/user:/app + depends_on: + rabbitmq: + condition: service_healthy + + customer: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/customer + ports: + - "9012:9012" + volumes: + - /app/node_modules + - ../../../microservices/customer:/app + depends_on: + rabbitmq: + condition: service_healthy + + email: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/email + ports: + - "9013:9013" + volumes: + - /app/node_modules + - ../../../microservices/email:/app + depends_on: + rabbitmq: + condition: service_healthy + + notification: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/notification + ports: + - "9014:9014" + volumes: + - /app/node_modules + - ../../../microservices/notification:/app + depends_on: + rabbitmq: + condition: service_healthy + + payment: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/payment + ports: + - "9015:9015" + volumes: + - /app/node_modules + - ../../../microservices/payment:/app + depends_on: + rabbitmq: + condition: service_healthy + + product: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/product + ports: + - "9016:9016" + volumes: + - /app/node_modules + - ../../../microservices/product:/app + depends_on: + rabbitmq: + condition: service_healthy + + rbac: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/rbac + ports: + - "9017:9017" + volumes: + - /app/node_modules + - ../../../microservices/rbac:/app + depends_on: + rabbitmq: + condition: service_healthy + + supplier: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/supplier + ports: + - "9018:9018" + volumes: + - /app/node_modules + - ../../../microservices/supplier:/app + depends_on: + rabbitmq: + condition: service_healthy + + upload: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/upload + ports: + - "9019:9019" + volumes: + - /app/node_modules + - ../../../microservices/upload:/app + depends_on: + rabbitmq: + condition: service_healthy + + th: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/th + ports: + - "9020:9020" + volumes: + - /app/node_modules + - ../../../microservices/th:/app + depends_on: + rabbitmq: + condition: service_healthy + + kjhgf: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/kjhgf + ports: + - "9021:9021" + volumes: + - /app/node_modules + - ../../../microservices/kjhgf:/app + depends_on: + rabbitmq: + condition: service_healthy + + hhgfdsdfghj: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/hhgfdsdfghj + ports: + - "9022:9022" + volumes: + - /app/node_modules + - ../../../microservices/hhgfdsdfghj:/app + depends_on: + rabbitmq: + condition: service_healthy + + ghjk: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/ghjk + ports: + - "9023:9023" + volumes: + - /app/node_modules + - ../../../microservices/ghjk:/app + depends_on: + rabbitmq: + condition: service_healthy + + shjksgd: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/shjksgd + ports: + - "30067:30067" + volumes: + - /app/node_modules + - ../../../microservices/shjksgd:/app + depends_on: + rabbitmq: + condition: service_healthy + + nginx: + depends_on: + - hd + - customer-service + - product-service + - rbac-service + - payment-service + - notification-service + - email-service + - cart-service + - cart + - user + - customer + - email + - notification + - payment + - product + - rbac + - supplier + - upload + - th + - kjhgf + - hhgfdsdfghj + - ghjk + - shjksgd + restart: always + build: + context: ./nginx + dockerfile: Dockerfile.dev + ports: + - '4000:80' + healthcheck: + test: ["CMD-SHELL", "curl -f http://localhost:80/health || exit 1"] + interval: 30s + timeout: 10s + retries: 3 + start_period: 40s + rabbitmq: + image: rabbitmq:3.13-management + container_name: rabbitmq + ports: + - '5672:5672' + - '15672:15672' + healthcheck: + test: ["CMD", "rabbitmq-diagnostics", "ping"] + interval: 30s + retries: 5 + mongodb: + image: mongo + ports: + - '27017:27017' + restart: always + volumes: + - type: bind + source: ./data + target: /data/db + krakend: + image: devopsfaith/krakend:2.7-watch + ports: + - '8080:8080' + - '8090:8090' + volumes: + - ./krakend/:/etc/krakend/ + command: ['run','-d','-c','/etc/krakend/krakend.json'] \ No newline at end of file diff --git a/gateways/apps/hkd/docker-compose.yml b/gateways/apps/hkd/docker-compose.yml new file mode 100644 index 0000000..97e3b67 --- /dev/null +++ b/gateways/apps/hkd/docker-compose.yml @@ -0,0 +1,367 @@ + +version: '3.8' +services: + + hd: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/hd + ports: + - "null:null" + volumes: + - /app/node_modules + - ../../../microservices/hd:/app + depends_on: + rabbitmq: + condition: service_healthy + + customer-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/customer-service + ports: + - "9000:9000" + volumes: + - /app/node_modules + - ../../../microservices/customer-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + product-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/product-service + ports: + - "9002:9002" + volumes: + - /app/node_modules + - ../../../microservices/product-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + rbac-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/rbac-service + ports: + - "9004:9004" + volumes: + - /app/node_modules + - ../../../microservices/rbac-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + payment-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/payment-service + ports: + - "9006:9006" + volumes: + - /app/node_modules + - ../../../microservices/payment-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + notification-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/notification-service + ports: + - "9007:9007" + volumes: + - /app/node_modules + - ../../../microservices/notification-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + email-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/email-service + ports: + - "9008:9008" + volumes: + - /app/node_modules + - ../../../microservices/email-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + cart-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/cart-service + ports: + - "9009:9009" + volumes: + - /app/node_modules + - ../../../microservices/cart-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + cart: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/cart + ports: + - "9010:9010" + volumes: + - /app/node_modules + - ../../../microservices/cart:/app + depends_on: + rabbitmq: + condition: service_healthy + + user: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/user + ports: + - "9011:9011" + volumes: + - /app/node_modules + - ../../../microservices/user:/app + depends_on: + rabbitmq: + condition: service_healthy + + customer: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/customer + ports: + - "9012:9012" + volumes: + - /app/node_modules + - ../../../microservices/customer:/app + depends_on: + rabbitmq: + condition: service_healthy + + email: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/email + ports: + - "9013:9013" + volumes: + - /app/node_modules + - ../../../microservices/email:/app + depends_on: + rabbitmq: + condition: service_healthy + + notification: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/notification + ports: + - "9014:9014" + volumes: + - /app/node_modules + - ../../../microservices/notification:/app + depends_on: + rabbitmq: + condition: service_healthy + + payment: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/payment + ports: + - "9015:9015" + volumes: + - /app/node_modules + - ../../../microservices/payment:/app + depends_on: + rabbitmq: + condition: service_healthy + + product: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/product + ports: + - "9016:9016" + volumes: + - /app/node_modules + - ../../../microservices/product:/app + depends_on: + rabbitmq: + condition: service_healthy + + rbac: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/rbac + ports: + - "9017:9017" + volumes: + - /app/node_modules + - ../../../microservices/rbac:/app + depends_on: + rabbitmq: + condition: service_healthy + + supplier: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/supplier + ports: + - "9018:9018" + volumes: + - /app/node_modules + - ../../../microservices/supplier:/app + depends_on: + rabbitmq: + condition: service_healthy + + upload: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/upload + ports: + - "9019:9019" + volumes: + - /app/node_modules + - ../../../microservices/upload:/app + depends_on: + rabbitmq: + condition: service_healthy + + th: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/th + ports: + - "9020:9020" + volumes: + - /app/node_modules + - ../../../microservices/th:/app + depends_on: + rabbitmq: + condition: service_healthy + + kjhgf: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/kjhgf + ports: + - "9021:9021" + volumes: + - /app/node_modules + - ../../../microservices/kjhgf:/app + depends_on: + rabbitmq: + condition: service_healthy + + hhgfdsdfghj: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/hhgfdsdfghj + ports: + - "9022:9022" + volumes: + - /app/node_modules + - ../../../microservices/hhgfdsdfghj:/app + depends_on: + rabbitmq: + condition: service_healthy + + ghjk: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/ghjk + ports: + - "9023:9023" + volumes: + - /app/node_modules + - ../../../microservices/ghjk:/app + depends_on: + rabbitmq: + condition: service_healthy + + shjksgd: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/shjksgd + ports: + - "30067:30067" + volumes: + - /app/node_modules + - ../../../microservices/shjksgd:/app + depends_on: + rabbitmq: + condition: service_healthy + + nginx: + depends_on: + - hd + - customer-service + - product-service + - rbac-service + - payment-service + - notification-service + - email-service + - cart-service + - cart + - user + - customer + - email + - notification + - payment + - product + - rbac + - supplier + - upload + - th + - kjhgf + - hhgfdsdfghj + - ghjk + - shjksgd + restart: always + build: + context: ./nginx + dockerfile: Dockerfile.dev + ports: + - '4000:80' + healthcheck: + test: ["CMD-SHELL", "curl -f http://localhost:80/health || exit 1"] + interval: 30s + timeout: 10s + retries: 3 + start_period: 40s + rabbitmq: + image: rabbitmq:3.13-management + container_name: rabbitmq + ports: + - '5672:5672' + - '15672:15672' + healthcheck: + test: ["CMD", "rabbitmq-diagnostics", "ping"] + interval: 30s + retries: 5 + mongodb: + image: mongo + ports: + - '27017:27017' + restart: always + volumes: + - type: bind + source: ./data + target: /data/db + krakend: + image: devopsfaith/krakend:2.7 + ports: + - '8080:8080' + - '8090:8090' + volumes: + - ./krakend/:/etc/krakend/ + command: ['run','-d','-c','/etc/krakend/krakend.json'] \ No newline at end of file diff --git a/gateways/apps/hkd/krakend/krakend.json b/gateways/apps/hkd/krakend/krakend.json new file mode 100644 index 0000000..89d801a --- /dev/null +++ b/gateways/apps/hkd/krakend/krakend.json @@ -0,0 +1,402 @@ + +{ + "$schema": "https://www.krakend.io/schema/v2.5/krakend.json", + "version": 3, + "name": "Microservices-suite API Gateway", + "port": 8080, + "cache_ttl": "3600s", + "timeout": "300s", + "endpoints": [ + { + "@comment": "Check the health of all your APIs", + "endpoint": "/__suite_status", + "method": "GET", + "backend": [ + { + "host": ["http://hd:null"], + "url_pattern": "/", + "mapping": { + "message": "hd" + } + }, + + { + "host": ["http://customer-service:9000"], + "url_pattern": "/", + "mapping": { + "message": "customer-service" + } + }, + + { + "host": ["http://product-service:9002"], + "url_pattern": "/", + "mapping": { + "message": "product-service" + } + }, + + { + "host": ["http://rbac-service:9004"], + "url_pattern": "/", + "mapping": { + "message": "rbac-service" + } + }, + + { + "host": ["http://payment-service:9006"], + "url_pattern": "/", + "mapping": { + "message": "payment-service" + } + }, + + { + "host": ["http://notification-service:9007"], + "url_pattern": "/", + "mapping": { + "message": "notification-service" + } + }, + + { + "host": ["http://email-service:9008"], + "url_pattern": "/", + "mapping": { + "message": "email-service" + } + }, + + { + "host": ["http://cart-service:9009"], + "url_pattern": "/", + "mapping": { + "message": "cart-service" + } + }, + + { + "host": ["http://cart:9010"], + "url_pattern": "/", + "mapping": { + "message": "cart" + } + }, + + { + "host": ["http://user:9011"], + "url_pattern": "/", + "mapping": { + "message": "user" + } + }, + + { + "host": ["http://customer:9012"], + "url_pattern": "/", + "mapping": { + "message": "customer" + } + }, + + { + "host": ["http://email:9013"], + "url_pattern": "/", + "mapping": { + "message": "email" + } + }, + + { + "host": ["http://notification:9014"], + "url_pattern": "/", + "mapping": { + "message": "notification" + } + }, + + { + "host": ["http://payment:9015"], + "url_pattern": "/", + "mapping": { + "message": "payment" + } + }, + + { + "host": ["http://product:9016"], + "url_pattern": "/", + "mapping": { + "message": "product" + } + }, + + { + "host": ["http://rbac:9017"], + "url_pattern": "/", + "mapping": { + "message": "rbac" + } + }, + + { + "host": ["http://supplier:9018"], + "url_pattern": "/", + "mapping": { + "message": "supplier" + } + }, + + { + "host": ["http://upload:9019"], + "url_pattern": "/", + "mapping": { + "message": "upload" + } + }, + + { + "host": ["http://th:9020"], + "url_pattern": "/", + "mapping": { + "message": "th" + } + }, + + { + "host": ["http://kjhgf:9021"], + "url_pattern": "/", + "mapping": { + "message": "kjhgf" + } + }, + + { + "host": ["http://hhgfdsdfghj:9022"], + "url_pattern": "/", + "mapping": { + "message": "hhgfdsdfghj" + } + }, + + { + "host": ["http://ghjk:9023"], + "url_pattern": "/", + "mapping": { + "message": "ghjk" + } + }, + + { + "host": ["http://shjksgd:30067"], + "url_pattern": "/", + "mapping": { + "message": "shjksgd" + } + }] + }, + { + "@comment": "Hit all API list endpoints simultaneously", + "endpoint": "/api/v1/", + "method": "GET", + "backend": [ + { + "host": ["http://hd:null"], + "url_pattern": "/api/v1/hds", + "mapping": { + "data": "hds" + } + }, + + { + "host": ["http://customer-service:9000"], + "url_pattern": "/api/v1/customer-services", + "mapping": { + "data": "customer-services" + } + }, + + { + "host": ["http://product-service:9002"], + "url_pattern": "/api/v1/product-services", + "mapping": { + "data": "product-services" + } + }, + + { + "host": ["http://rbac-service:9004"], + "url_pattern": "/api/v1/rbac-services", + "mapping": { + "data": "rbac-services" + } + }, + + { + "host": ["http://payment-service:9006"], + "url_pattern": "/api/v1/payment-services", + "mapping": { + "data": "payment-services" + } + }, + + { + "host": ["http://notification-service:9007"], + "url_pattern": "/api/v1/notification-services", + "mapping": { + "data": "notification-services" + } + }, + + { + "host": ["http://email-service:9008"], + "url_pattern": "/api/v1/email-services", + "mapping": { + "data": "email-services" + } + }, + + { + "host": ["http://cart-service:9009"], + "url_pattern": "/api/v1/cart-services", + "mapping": { + "data": "cart-services" + } + }, + + { + "host": ["http://cart:9010"], + "url_pattern": "/api/v1/carts", + "mapping": { + "data": "carts" + } + }, + + { + "host": ["http://user:9011"], + "url_pattern": "/api/v1/users", + "mapping": { + "data": "users" + } + }, + + { + "host": ["http://customer:9012"], + "url_pattern": "/api/v1/customers", + "mapping": { + "data": "customers" + } + }, + + { + "host": ["http://email:9013"], + "url_pattern": "/api/v1/emails", + "mapping": { + "data": "emails" + } + }, + + { + "host": ["http://notification:9014"], + "url_pattern": "/api/v1/notifications", + "mapping": { + "data": "notifications" + } + }, + + { + "host": ["http://payment:9015"], + "url_pattern": "/api/v1/payments", + "mapping": { + "data": "payments" + } + }, + + { + "host": ["http://product:9016"], + "url_pattern": "/api/v1/products", + "mapping": { + "data": "products" + } + }, + + { + "host": ["http://rbac:9017"], + "url_pattern": "/api/v1/rbacs", + "mapping": { + "data": "rbacs" + } + }, + + { + "host": ["http://supplier:9018"], + "url_pattern": "/api/v1/suppliers", + "mapping": { + "data": "suppliers" + } + }, + + { + "host": ["http://upload:9019"], + "url_pattern": "/api/v1/uploads", + "mapping": { + "data": "uploads" + } + }, + + { + "host": ["http://th:9020"], + "url_pattern": "/api/v1/ths", + "mapping": { + "data": "ths" + } + }, + + { + "host": ["http://kjhgf:9021"], + "url_pattern": "/api/v1/kjhgfs", + "mapping": { + "data": "kjhgfs" + } + }, + + { + "host": ["http://hhgfdsdfghj:9022"], + "url_pattern": "/api/v1/hhgfdsdfghjs", + "mapping": { + "data": "hhgfdsdfghjs" + } + }, + + { + "host": ["http://ghjk:9023"], + "url_pattern": "/api/v1/ghjks", + "mapping": { + "data": "ghjks" + } + }, + + { + "host": ["http://shjksgd:30067"], + "url_pattern": "/api/v1/shjksgds", + "mapping": { + "data": "shjksgds" + } + }] + }, + { + "@comment": "Fetch all data from the hd service", + "endpoint": "/api/v1/hds", + "method": "GET", + "backend": [ + { + "host": ["http://hd:null"], + "url_pattern": "/api/v1/hds", + "mapping": { + "data": "hds" + } + }] + } + ] +} \ No newline at end of file diff --git a/gateways/apps/hkd/nginx/Dockerfile b/gateways/apps/hkd/nginx/Dockerfile new file mode 100644 index 0000000..ddf7281 --- /dev/null +++ b/gateways/apps/hkd/nginx/Dockerfile @@ -0,0 +1,3 @@ + +FROM nginx +COPY ./default.conf /etc/nginx/conf.d/default.conf \ No newline at end of file diff --git a/gateways/apps/hkd/nginx/Dockerfile.dev b/gateways/apps/hkd/nginx/Dockerfile.dev new file mode 100644 index 0000000..ddf7281 --- /dev/null +++ b/gateways/apps/hkd/nginx/Dockerfile.dev @@ -0,0 +1,3 @@ + +FROM nginx +COPY ./default.conf /etc/nginx/conf.d/default.conf \ No newline at end of file diff --git a/gateways/apps/hkd/nginx/default.conf b/gateways/apps/hkd/nginx/default.conf new file mode 100644 index 0000000..d4dace0 --- /dev/null +++ b/gateways/apps/hkd/nginx/default.conf @@ -0,0 +1,282 @@ + + +upstream hd_upstream { + server hd:null; +} + +upstream customer-service_upstream { + server customer-service:9000; +} + +upstream product-service_upstream { + server product-service:9002; +} + +upstream rbac-service_upstream { + server rbac-service:9004; +} + +upstream payment-service_upstream { + server payment-service:9006; +} + +upstream notification-service_upstream { + server notification-service:9007; +} + +upstream email-service_upstream { + server email-service:9008; +} + +upstream cart-service_upstream { + server cart-service:9009; +} + +upstream cart_upstream { + server cart:9010; +} + +upstream user_upstream { + server user:9011; +} + +upstream customer_upstream { + server customer:9012; +} + +upstream email_upstream { + server email:9013; +} + +upstream notification_upstream { + server notification:9014; +} + +upstream payment_upstream { + server payment:9015; +} + +upstream product_upstream { + server product:9016; +} + +upstream rbac_upstream { + server rbac:9017; +} + +upstream supplier_upstream { + server supplier:9018; +} + +upstream upload_upstream { + server upload:9019; +} + +upstream th_upstream { + server th:9020; +} + +upstream kjhgf_upstream { + server kjhgf:9021; +} + +upstream hhgfdsdfghj_upstream { + server hhgfdsdfghj:9022; +} + +upstream ghjk_upstream { + server ghjk:9023; +} + +upstream shjksgd_upstream { + server shjksgd:30067; +} + +server { + listen 80; + + + location /api/v1/hds { + proxy_pass http://hd_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/customer-services { + proxy_pass http://customer-service_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/product-services { + proxy_pass http://product-service_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/rbac-services { + proxy_pass http://rbac-service_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/payment-services { + proxy_pass http://payment-service_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/notification-services { + proxy_pass http://notification-service_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/email-services { + proxy_pass http://email-service_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/cart-services { + proxy_pass http://cart-service_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/carts { + proxy_pass http://cart_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/users { + proxy_pass http://user_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/customers { + proxy_pass http://customer_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/emails { + proxy_pass http://email_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/notifications { + proxy_pass http://notification_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/payments { + proxy_pass http://payment_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/products { + proxy_pass http://product_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/rbacs { + proxy_pass http://rbac_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/suppliers { + proxy_pass http://supplier_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/uploads { + proxy_pass http://upload_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/ths { + proxy_pass http://th_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/kjhgfs { + proxy_pass http://kjhgf_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/hhgfdsdfghjs { + proxy_pass http://hhgfdsdfghj_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/ghjks { + proxy_pass http://ghjk_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/shjksgds { + proxy_pass http://shjksgd_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } +} \ No newline at end of file diff --git a/gateways/apps/kdfasg/docker-compose.dev.yml b/gateways/apps/kdfasg/docker-compose.dev.yml new file mode 100644 index 0000000..2e403c2 --- /dev/null +++ b/gateways/apps/kdfasg/docker-compose.dev.yml @@ -0,0 +1,367 @@ + +version: '3.8' +services: + + hd: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/hd + ports: + - "null:null" + volumes: + - /app/node_modules + - ../../../microservices/hd:/app + depends_on: + rabbitmq: + condition: service_healthy + + customer-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/customer-service + ports: + - "9000:9000" + volumes: + - /app/node_modules + - ../../../microservices/customer-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + product-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/product-service + ports: + - "9002:9002" + volumes: + - /app/node_modules + - ../../../microservices/product-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + rbac-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/rbac-service + ports: + - "9004:9004" + volumes: + - /app/node_modules + - ../../../microservices/rbac-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + payment-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/payment-service + ports: + - "9006:9006" + volumes: + - /app/node_modules + - ../../../microservices/payment-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + notification-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/notification-service + ports: + - "9007:9007" + volumes: + - /app/node_modules + - ../../../microservices/notification-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + email-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/email-service + ports: + - "9008:9008" + volumes: + - /app/node_modules + - ../../../microservices/email-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + cart-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/cart-service + ports: + - "9009:9009" + volumes: + - /app/node_modules + - ../../../microservices/cart-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + cart: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/cart + ports: + - "9010:9010" + volumes: + - /app/node_modules + - ../../../microservices/cart:/app + depends_on: + rabbitmq: + condition: service_healthy + + user: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/user + ports: + - "9011:9011" + volumes: + - /app/node_modules + - ../../../microservices/user:/app + depends_on: + rabbitmq: + condition: service_healthy + + customer: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/customer + ports: + - "9012:9012" + volumes: + - /app/node_modules + - ../../../microservices/customer:/app + depends_on: + rabbitmq: + condition: service_healthy + + email: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/email + ports: + - "9013:9013" + volumes: + - /app/node_modules + - ../../../microservices/email:/app + depends_on: + rabbitmq: + condition: service_healthy + + notification: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/notification + ports: + - "9014:9014" + volumes: + - /app/node_modules + - ../../../microservices/notification:/app + depends_on: + rabbitmq: + condition: service_healthy + + payment: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/payment + ports: + - "9015:9015" + volumes: + - /app/node_modules + - ../../../microservices/payment:/app + depends_on: + rabbitmq: + condition: service_healthy + + product: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/product + ports: + - "9016:9016" + volumes: + - /app/node_modules + - ../../../microservices/product:/app + depends_on: + rabbitmq: + condition: service_healthy + + rbac: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/rbac + ports: + - "9017:9017" + volumes: + - /app/node_modules + - ../../../microservices/rbac:/app + depends_on: + rabbitmq: + condition: service_healthy + + supplier: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/supplier + ports: + - "9018:9018" + volumes: + - /app/node_modules + - ../../../microservices/supplier:/app + depends_on: + rabbitmq: + condition: service_healthy + + upload: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/upload + ports: + - "9019:9019" + volumes: + - /app/node_modules + - ../../../microservices/upload:/app + depends_on: + rabbitmq: + condition: service_healthy + + th: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/th + ports: + - "9020:9020" + volumes: + - /app/node_modules + - ../../../microservices/th:/app + depends_on: + rabbitmq: + condition: service_healthy + + kjhgf: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/kjhgf + ports: + - "9021:9021" + volumes: + - /app/node_modules + - ../../../microservices/kjhgf:/app + depends_on: + rabbitmq: + condition: service_healthy + + hhgfdsdfghj: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/hhgfdsdfghj + ports: + - "9022:9022" + volumes: + - /app/node_modules + - ../../../microservices/hhgfdsdfghj:/app + depends_on: + rabbitmq: + condition: service_healthy + + ghjk: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/ghjk + ports: + - "9023:9023" + volumes: + - /app/node_modules + - ../../../microservices/ghjk:/app + depends_on: + rabbitmq: + condition: service_healthy + + shjksgd: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/shjksgd + ports: + - "30067:30067" + volumes: + - /app/node_modules + - ../../../microservices/shjksgd:/app + depends_on: + rabbitmq: + condition: service_healthy + + nginx: + depends_on: + - hd + - customer-service + - product-service + - rbac-service + - payment-service + - notification-service + - email-service + - cart-service + - cart + - user + - customer + - email + - notification + - payment + - product + - rbac + - supplier + - upload + - th + - kjhgf + - hhgfdsdfghj + - ghjk + - shjksgd + restart: always + build: + context: ./nginx + dockerfile: Dockerfile.dev + ports: + - '4000:80' + healthcheck: + test: ["CMD-SHELL", "curl -f http://localhost:80/health || exit 1"] + interval: 30s + timeout: 10s + retries: 3 + start_period: 40s + rabbitmq: + image: rabbitmq:3.13-management + container_name: rabbitmq + ports: + - '5672:5672' + - '15672:15672' + healthcheck: + test: ["CMD", "rabbitmq-diagnostics", "ping"] + interval: 30s + retries: 5 + mongodb: + image: mongo + ports: + - '27017:27017' + restart: always + volumes: + - type: bind + source: ./data + target: /data/db + krakend: + image: devopsfaith/krakend:2.7-watch + ports: + - '9000:9000' + - '8090:8090' + volumes: + - ./krakend/:/etc/krakend/ + command: ['run','-d','-c','/etc/krakend/krakend.json'] \ No newline at end of file diff --git a/gateways/apps/kdfasg/docker-compose.yml b/gateways/apps/kdfasg/docker-compose.yml new file mode 100644 index 0000000..f33baeb --- /dev/null +++ b/gateways/apps/kdfasg/docker-compose.yml @@ -0,0 +1,367 @@ + +version: '3.8' +services: + + hd: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/hd + ports: + - "null:null" + volumes: + - /app/node_modules + - ../../../microservices/hd:/app + depends_on: + rabbitmq: + condition: service_healthy + + customer-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/customer-service + ports: + - "9000:9000" + volumes: + - /app/node_modules + - ../../../microservices/customer-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + product-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/product-service + ports: + - "9002:9002" + volumes: + - /app/node_modules + - ../../../microservices/product-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + rbac-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/rbac-service + ports: + - "9004:9004" + volumes: + - /app/node_modules + - ../../../microservices/rbac-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + payment-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/payment-service + ports: + - "9006:9006" + volumes: + - /app/node_modules + - ../../../microservices/payment-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + notification-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/notification-service + ports: + - "9007:9007" + volumes: + - /app/node_modules + - ../../../microservices/notification-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + email-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/email-service + ports: + - "9008:9008" + volumes: + - /app/node_modules + - ../../../microservices/email-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + cart-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/cart-service + ports: + - "9009:9009" + volumes: + - /app/node_modules + - ../../../microservices/cart-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + cart: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/cart + ports: + - "9010:9010" + volumes: + - /app/node_modules + - ../../../microservices/cart:/app + depends_on: + rabbitmq: + condition: service_healthy + + user: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/user + ports: + - "9011:9011" + volumes: + - /app/node_modules + - ../../../microservices/user:/app + depends_on: + rabbitmq: + condition: service_healthy + + customer: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/customer + ports: + - "9012:9012" + volumes: + - /app/node_modules + - ../../../microservices/customer:/app + depends_on: + rabbitmq: + condition: service_healthy + + email: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/email + ports: + - "9013:9013" + volumes: + - /app/node_modules + - ../../../microservices/email:/app + depends_on: + rabbitmq: + condition: service_healthy + + notification: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/notification + ports: + - "9014:9014" + volumes: + - /app/node_modules + - ../../../microservices/notification:/app + depends_on: + rabbitmq: + condition: service_healthy + + payment: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/payment + ports: + - "9015:9015" + volumes: + - /app/node_modules + - ../../../microservices/payment:/app + depends_on: + rabbitmq: + condition: service_healthy + + product: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/product + ports: + - "9016:9016" + volumes: + - /app/node_modules + - ../../../microservices/product:/app + depends_on: + rabbitmq: + condition: service_healthy + + rbac: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/rbac + ports: + - "9017:9017" + volumes: + - /app/node_modules + - ../../../microservices/rbac:/app + depends_on: + rabbitmq: + condition: service_healthy + + supplier: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/supplier + ports: + - "9018:9018" + volumes: + - /app/node_modules + - ../../../microservices/supplier:/app + depends_on: + rabbitmq: + condition: service_healthy + + upload: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/upload + ports: + - "9019:9019" + volumes: + - /app/node_modules + - ../../../microservices/upload:/app + depends_on: + rabbitmq: + condition: service_healthy + + th: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/th + ports: + - "9020:9020" + volumes: + - /app/node_modules + - ../../../microservices/th:/app + depends_on: + rabbitmq: + condition: service_healthy + + kjhgf: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/kjhgf + ports: + - "9021:9021" + volumes: + - /app/node_modules + - ../../../microservices/kjhgf:/app + depends_on: + rabbitmq: + condition: service_healthy + + hhgfdsdfghj: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/hhgfdsdfghj + ports: + - "9022:9022" + volumes: + - /app/node_modules + - ../../../microservices/hhgfdsdfghj:/app + depends_on: + rabbitmq: + condition: service_healthy + + ghjk: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/ghjk + ports: + - "9023:9023" + volumes: + - /app/node_modules + - ../../../microservices/ghjk:/app + depends_on: + rabbitmq: + condition: service_healthy + + shjksgd: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/shjksgd + ports: + - "30067:30067" + volumes: + - /app/node_modules + - ../../../microservices/shjksgd:/app + depends_on: + rabbitmq: + condition: service_healthy + + nginx: + depends_on: + - hd + - customer-service + - product-service + - rbac-service + - payment-service + - notification-service + - email-service + - cart-service + - cart + - user + - customer + - email + - notification + - payment + - product + - rbac + - supplier + - upload + - th + - kjhgf + - hhgfdsdfghj + - ghjk + - shjksgd + restart: always + build: + context: ./nginx + dockerfile: Dockerfile.dev + ports: + - '4000:80' + healthcheck: + test: ["CMD-SHELL", "curl -f http://localhost:80/health || exit 1"] + interval: 30s + timeout: 10s + retries: 3 + start_period: 40s + rabbitmq: + image: rabbitmq:3.13-management + container_name: rabbitmq + ports: + - '5672:5672' + - '15672:15672' + healthcheck: + test: ["CMD", "rabbitmq-diagnostics", "ping"] + interval: 30s + retries: 5 + mongodb: + image: mongo + ports: + - '27017:27017' + restart: always + volumes: + - type: bind + source: ./data + target: /data/db + krakend: + image: devopsfaith/krakend:2.7 + ports: + - '9000:9000' + - '8090:8090' + volumes: + - ./krakend/:/etc/krakend/ + command: ['run','-d','-c','/etc/krakend/krakend.json'] \ No newline at end of file diff --git a/gateways/apps/kdfasg/krakend/krakend.json b/gateways/apps/kdfasg/krakend/krakend.json new file mode 100644 index 0000000..5e3320a --- /dev/null +++ b/gateways/apps/kdfasg/krakend/krakend.json @@ -0,0 +1,402 @@ + +{ + "$schema": "https://www.krakend.io/schema/v2.5/krakend.json", + "version": 3, + "name": "Microservices-suite API Gateway", + "port": 9000, + "cache_ttl": "3600s", + "timeout": "300s", + "endpoints": [ + { + "@comment": "Check the health of all your APIs", + "endpoint": "/__suite_status", + "method": "GET", + "backend": [ + { + "host": ["http://hd:null"], + "url_pattern": "/", + "mapping": { + "message": "hd" + } + }, + + { + "host": ["http://customer-service:9000"], + "url_pattern": "/", + "mapping": { + "message": "customer-service" + } + }, + + { + "host": ["http://product-service:9002"], + "url_pattern": "/", + "mapping": { + "message": "product-service" + } + }, + + { + "host": ["http://rbac-service:9004"], + "url_pattern": "/", + "mapping": { + "message": "rbac-service" + } + }, + + { + "host": ["http://payment-service:9006"], + "url_pattern": "/", + "mapping": { + "message": "payment-service" + } + }, + + { + "host": ["http://notification-service:9007"], + "url_pattern": "/", + "mapping": { + "message": "notification-service" + } + }, + + { + "host": ["http://email-service:9008"], + "url_pattern": "/", + "mapping": { + "message": "email-service" + } + }, + + { + "host": ["http://cart-service:9009"], + "url_pattern": "/", + "mapping": { + "message": "cart-service" + } + }, + + { + "host": ["http://cart:9010"], + "url_pattern": "/", + "mapping": { + "message": "cart" + } + }, + + { + "host": ["http://user:9011"], + "url_pattern": "/", + "mapping": { + "message": "user" + } + }, + + { + "host": ["http://customer:9012"], + "url_pattern": "/", + "mapping": { + "message": "customer" + } + }, + + { + "host": ["http://email:9013"], + "url_pattern": "/", + "mapping": { + "message": "email" + } + }, + + { + "host": ["http://notification:9014"], + "url_pattern": "/", + "mapping": { + "message": "notification" + } + }, + + { + "host": ["http://payment:9015"], + "url_pattern": "/", + "mapping": { + "message": "payment" + } + }, + + { + "host": ["http://product:9016"], + "url_pattern": "/", + "mapping": { + "message": "product" + } + }, + + { + "host": ["http://rbac:9017"], + "url_pattern": "/", + "mapping": { + "message": "rbac" + } + }, + + { + "host": ["http://supplier:9018"], + "url_pattern": "/", + "mapping": { + "message": "supplier" + } + }, + + { + "host": ["http://upload:9019"], + "url_pattern": "/", + "mapping": { + "message": "upload" + } + }, + + { + "host": ["http://th:9020"], + "url_pattern": "/", + "mapping": { + "message": "th" + } + }, + + { + "host": ["http://kjhgf:9021"], + "url_pattern": "/", + "mapping": { + "message": "kjhgf" + } + }, + + { + "host": ["http://hhgfdsdfghj:9022"], + "url_pattern": "/", + "mapping": { + "message": "hhgfdsdfghj" + } + }, + + { + "host": ["http://ghjk:9023"], + "url_pattern": "/", + "mapping": { + "message": "ghjk" + } + }, + + { + "host": ["http://shjksgd:30067"], + "url_pattern": "/", + "mapping": { + "message": "shjksgd" + } + }] + }, + { + "@comment": "Hit all API list endpoints simultaneously", + "endpoint": "/api/v1/", + "method": "GET", + "backend": [ + { + "host": ["http://hd:null"], + "url_pattern": "/api/v1/hds", + "mapping": { + "data": "hds" + } + }, + + { + "host": ["http://customer-service:9000"], + "url_pattern": "/api/v1/customer-services", + "mapping": { + "data": "customer-services" + } + }, + + { + "host": ["http://product-service:9002"], + "url_pattern": "/api/v1/product-services", + "mapping": { + "data": "product-services" + } + }, + + { + "host": ["http://rbac-service:9004"], + "url_pattern": "/api/v1/rbac-services", + "mapping": { + "data": "rbac-services" + } + }, + + { + "host": ["http://payment-service:9006"], + "url_pattern": "/api/v1/payment-services", + "mapping": { + "data": "payment-services" + } + }, + + { + "host": ["http://notification-service:9007"], + "url_pattern": "/api/v1/notification-services", + "mapping": { + "data": "notification-services" + } + }, + + { + "host": ["http://email-service:9008"], + "url_pattern": "/api/v1/email-services", + "mapping": { + "data": "email-services" + } + }, + + { + "host": ["http://cart-service:9009"], + "url_pattern": "/api/v1/cart-services", + "mapping": { + "data": "cart-services" + } + }, + + { + "host": ["http://cart:9010"], + "url_pattern": "/api/v1/carts", + "mapping": { + "data": "carts" + } + }, + + { + "host": ["http://user:9011"], + "url_pattern": "/api/v1/users", + "mapping": { + "data": "users" + } + }, + + { + "host": ["http://customer:9012"], + "url_pattern": "/api/v1/customers", + "mapping": { + "data": "customers" + } + }, + + { + "host": ["http://email:9013"], + "url_pattern": "/api/v1/emails", + "mapping": { + "data": "emails" + } + }, + + { + "host": ["http://notification:9014"], + "url_pattern": "/api/v1/notifications", + "mapping": { + "data": "notifications" + } + }, + + { + "host": ["http://payment:9015"], + "url_pattern": "/api/v1/payments", + "mapping": { + "data": "payments" + } + }, + + { + "host": ["http://product:9016"], + "url_pattern": "/api/v1/products", + "mapping": { + "data": "products" + } + }, + + { + "host": ["http://rbac:9017"], + "url_pattern": "/api/v1/rbacs", + "mapping": { + "data": "rbacs" + } + }, + + { + "host": ["http://supplier:9018"], + "url_pattern": "/api/v1/suppliers", + "mapping": { + "data": "suppliers" + } + }, + + { + "host": ["http://upload:9019"], + "url_pattern": "/api/v1/uploads", + "mapping": { + "data": "uploads" + } + }, + + { + "host": ["http://th:9020"], + "url_pattern": "/api/v1/ths", + "mapping": { + "data": "ths" + } + }, + + { + "host": ["http://kjhgf:9021"], + "url_pattern": "/api/v1/kjhgfs", + "mapping": { + "data": "kjhgfs" + } + }, + + { + "host": ["http://hhgfdsdfghj:9022"], + "url_pattern": "/api/v1/hhgfdsdfghjs", + "mapping": { + "data": "hhgfdsdfghjs" + } + }, + + { + "host": ["http://ghjk:9023"], + "url_pattern": "/api/v1/ghjks", + "mapping": { + "data": "ghjks" + } + }, + + { + "host": ["http://shjksgd:30067"], + "url_pattern": "/api/v1/shjksgds", + "mapping": { + "data": "shjksgds" + } + }] + }, + { + "@comment": "Fetch all data from the hd service", + "endpoint": "/api/v1/hds", + "method": "GET", + "backend": [ + { + "host": ["http://hd:null"], + "url_pattern": "/api/v1/hds", + "mapping": { + "data": "hds" + } + }] + } + ] +} \ No newline at end of file diff --git a/gateways/apps/kdfasg/nginx/Dockerfile b/gateways/apps/kdfasg/nginx/Dockerfile new file mode 100644 index 0000000..ddf7281 --- /dev/null +++ b/gateways/apps/kdfasg/nginx/Dockerfile @@ -0,0 +1,3 @@ + +FROM nginx +COPY ./default.conf /etc/nginx/conf.d/default.conf \ No newline at end of file diff --git a/gateways/apps/kdfasg/nginx/Dockerfile.dev b/gateways/apps/kdfasg/nginx/Dockerfile.dev new file mode 100644 index 0000000..ddf7281 --- /dev/null +++ b/gateways/apps/kdfasg/nginx/Dockerfile.dev @@ -0,0 +1,3 @@ + +FROM nginx +COPY ./default.conf /etc/nginx/conf.d/default.conf \ No newline at end of file diff --git a/gateways/apps/kdfasg/nginx/default.conf b/gateways/apps/kdfasg/nginx/default.conf new file mode 100644 index 0000000..d4dace0 --- /dev/null +++ b/gateways/apps/kdfasg/nginx/default.conf @@ -0,0 +1,282 @@ + + +upstream hd_upstream { + server hd:null; +} + +upstream customer-service_upstream { + server customer-service:9000; +} + +upstream product-service_upstream { + server product-service:9002; +} + +upstream rbac-service_upstream { + server rbac-service:9004; +} + +upstream payment-service_upstream { + server payment-service:9006; +} + +upstream notification-service_upstream { + server notification-service:9007; +} + +upstream email-service_upstream { + server email-service:9008; +} + +upstream cart-service_upstream { + server cart-service:9009; +} + +upstream cart_upstream { + server cart:9010; +} + +upstream user_upstream { + server user:9011; +} + +upstream customer_upstream { + server customer:9012; +} + +upstream email_upstream { + server email:9013; +} + +upstream notification_upstream { + server notification:9014; +} + +upstream payment_upstream { + server payment:9015; +} + +upstream product_upstream { + server product:9016; +} + +upstream rbac_upstream { + server rbac:9017; +} + +upstream supplier_upstream { + server supplier:9018; +} + +upstream upload_upstream { + server upload:9019; +} + +upstream th_upstream { + server th:9020; +} + +upstream kjhgf_upstream { + server kjhgf:9021; +} + +upstream hhgfdsdfghj_upstream { + server hhgfdsdfghj:9022; +} + +upstream ghjk_upstream { + server ghjk:9023; +} + +upstream shjksgd_upstream { + server shjksgd:30067; +} + +server { + listen 80; + + + location /api/v1/hds { + proxy_pass http://hd_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/customer-services { + proxy_pass http://customer-service_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/product-services { + proxy_pass http://product-service_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/rbac-services { + proxy_pass http://rbac-service_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/payment-services { + proxy_pass http://payment-service_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/notification-services { + proxy_pass http://notification-service_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/email-services { + proxy_pass http://email-service_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/cart-services { + proxy_pass http://cart-service_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/carts { + proxy_pass http://cart_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/users { + proxy_pass http://user_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/customers { + proxy_pass http://customer_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/emails { + proxy_pass http://email_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/notifications { + proxy_pass http://notification_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/payments { + proxy_pass http://payment_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/products { + proxy_pass http://product_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/rbacs { + proxy_pass http://rbac_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/suppliers { + proxy_pass http://supplier_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/uploads { + proxy_pass http://upload_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/ths { + proxy_pass http://th_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/kjhgfs { + proxy_pass http://kjhgf_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/hhgfdsdfghjs { + proxy_pass http://hhgfdsdfghj_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/ghjks { + proxy_pass http://ghjk_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/shjksgds { + proxy_pass http://shjksgd_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } +} \ No newline at end of file diff --git a/gateways/apps/name/docker-compose.dev.yml b/gateways/apps/name/docker-compose.dev.yml new file mode 100644 index 0000000..8f4f751 --- /dev/null +++ b/gateways/apps/name/docker-compose.dev.yml @@ -0,0 +1,367 @@ + +version: '3.8' +services: + + hd: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/hd + ports: + - "null:null" + volumes: + - /app/node_modules + - ../../../microservices/hd:/app + depends_on: + rabbitmq: + condition: service_healthy + + customer-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/customer-service + ports: + - "9000:9000" + volumes: + - /app/node_modules + - ../../../microservices/customer-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + product-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/product-service + ports: + - "9002:9002" + volumes: + - /app/node_modules + - ../../../microservices/product-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + rbac-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/rbac-service + ports: + - "9004:9004" + volumes: + - /app/node_modules + - ../../../microservices/rbac-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + payment-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/payment-service + ports: + - "9006:9006" + volumes: + - /app/node_modules + - ../../../microservices/payment-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + notification-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/notification-service + ports: + - "9007:9007" + volumes: + - /app/node_modules + - ../../../microservices/notification-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + email-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/email-service + ports: + - "9008:9008" + volumes: + - /app/node_modules + - ../../../microservices/email-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + cart-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/cart-service + ports: + - "9009:9009" + volumes: + - /app/node_modules + - ../../../microservices/cart-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + cart: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/cart + ports: + - "9010:9010" + volumes: + - /app/node_modules + - ../../../microservices/cart:/app + depends_on: + rabbitmq: + condition: service_healthy + + user: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/user + ports: + - "9011:9011" + volumes: + - /app/node_modules + - ../../../microservices/user:/app + depends_on: + rabbitmq: + condition: service_healthy + + customer: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/customer + ports: + - "9012:9012" + volumes: + - /app/node_modules + - ../../../microservices/customer:/app + depends_on: + rabbitmq: + condition: service_healthy + + email: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/email + ports: + - "9013:9013" + volumes: + - /app/node_modules + - ../../../microservices/email:/app + depends_on: + rabbitmq: + condition: service_healthy + + notification: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/notification + ports: + - "9014:9014" + volumes: + - /app/node_modules + - ../../../microservices/notification:/app + depends_on: + rabbitmq: + condition: service_healthy + + payment: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/payment + ports: + - "9015:9015" + volumes: + - /app/node_modules + - ../../../microservices/payment:/app + depends_on: + rabbitmq: + condition: service_healthy + + product: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/product + ports: + - "9016:9016" + volumes: + - /app/node_modules + - ../../../microservices/product:/app + depends_on: + rabbitmq: + condition: service_healthy + + rbac: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/rbac + ports: + - "9017:9017" + volumes: + - /app/node_modules + - ../../../microservices/rbac:/app + depends_on: + rabbitmq: + condition: service_healthy + + supplier: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/supplier + ports: + - "9018:9018" + volumes: + - /app/node_modules + - ../../../microservices/supplier:/app + depends_on: + rabbitmq: + condition: service_healthy + + upload: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/upload + ports: + - "9019:9019" + volumes: + - /app/node_modules + - ../../../microservices/upload:/app + depends_on: + rabbitmq: + condition: service_healthy + + th: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/th + ports: + - "9020:9020" + volumes: + - /app/node_modules + - ../../../microservices/th:/app + depends_on: + rabbitmq: + condition: service_healthy + + kjhgf: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/kjhgf + ports: + - "9021:9021" + volumes: + - /app/node_modules + - ../../../microservices/kjhgf:/app + depends_on: + rabbitmq: + condition: service_healthy + + hhgfdsdfghj: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/hhgfdsdfghj + ports: + - "9022:9022" + volumes: + - /app/node_modules + - ../../../microservices/hhgfdsdfghj:/app + depends_on: + rabbitmq: + condition: service_healthy + + ghjk: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/ghjk + ports: + - "9023:9023" + volumes: + - /app/node_modules + - ../../../microservices/ghjk:/app + depends_on: + rabbitmq: + condition: service_healthy + + shjksgd: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/shjksgd + ports: + - "30067:30067" + volumes: + - /app/node_modules + - ../../../microservices/shjksgd:/app + depends_on: + rabbitmq: + condition: service_healthy + + nginx: + depends_on: + - hd + - customer-service + - product-service + - rbac-service + - payment-service + - notification-service + - email-service + - cart-service + - cart + - user + - customer + - email + - notification + - payment + - product + - rbac + - supplier + - upload + - th + - kjhgf + - hhgfdsdfghj + - ghjk + - shjksgd + restart: always + build: + context: ./nginx + dockerfile: Dockerfile.dev + ports: + - '4000:80' + healthcheck: + test: ["CMD-SHELL", "curl -f http://localhost:80/health || exit 1"] + interval: 30s + timeout: 10s + retries: 3 + start_period: 40s + rabbitmq: + image: rabbitmq:3.13-management + container_name: rabbitmq + ports: + - '5672:5672' + - '15672:15672' + healthcheck: + test: ["CMD", "rabbitmq-diagnostics", "ping"] + interval: 30s + retries: 5 + mongodb: + image: mongo + ports: + - '27017:27017' + restart: always + volumes: + - type: bind + source: ./data + target: /data/db + krakend: + image: devopsfaith/krakend:2.7-watch + ports: + - '8080:8080' + - '8090:8090' + volumes: + - ./krakend/:/etc/krakend/ + command: ['run','-d','-c','/etc/krakend/krakend.json'] \ No newline at end of file diff --git a/gateways/apps/name/docker-compose.yml b/gateways/apps/name/docker-compose.yml new file mode 100644 index 0000000..97e3b67 --- /dev/null +++ b/gateways/apps/name/docker-compose.yml @@ -0,0 +1,367 @@ + +version: '3.8' +services: + + hd: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/hd + ports: + - "null:null" + volumes: + - /app/node_modules + - ../../../microservices/hd:/app + depends_on: + rabbitmq: + condition: service_healthy + + customer-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/customer-service + ports: + - "9000:9000" + volumes: + - /app/node_modules + - ../../../microservices/customer-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + product-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/product-service + ports: + - "9002:9002" + volumes: + - /app/node_modules + - ../../../microservices/product-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + rbac-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/rbac-service + ports: + - "9004:9004" + volumes: + - /app/node_modules + - ../../../microservices/rbac-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + payment-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/payment-service + ports: + - "9006:9006" + volumes: + - /app/node_modules + - ../../../microservices/payment-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + notification-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/notification-service + ports: + - "9007:9007" + volumes: + - /app/node_modules + - ../../../microservices/notification-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + email-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/email-service + ports: + - "9008:9008" + volumes: + - /app/node_modules + - ../../../microservices/email-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + cart-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/cart-service + ports: + - "9009:9009" + volumes: + - /app/node_modules + - ../../../microservices/cart-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + cart: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/cart + ports: + - "9010:9010" + volumes: + - /app/node_modules + - ../../../microservices/cart:/app + depends_on: + rabbitmq: + condition: service_healthy + + user: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/user + ports: + - "9011:9011" + volumes: + - /app/node_modules + - ../../../microservices/user:/app + depends_on: + rabbitmq: + condition: service_healthy + + customer: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/customer + ports: + - "9012:9012" + volumes: + - /app/node_modules + - ../../../microservices/customer:/app + depends_on: + rabbitmq: + condition: service_healthy + + email: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/email + ports: + - "9013:9013" + volumes: + - /app/node_modules + - ../../../microservices/email:/app + depends_on: + rabbitmq: + condition: service_healthy + + notification: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/notification + ports: + - "9014:9014" + volumes: + - /app/node_modules + - ../../../microservices/notification:/app + depends_on: + rabbitmq: + condition: service_healthy + + payment: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/payment + ports: + - "9015:9015" + volumes: + - /app/node_modules + - ../../../microservices/payment:/app + depends_on: + rabbitmq: + condition: service_healthy + + product: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/product + ports: + - "9016:9016" + volumes: + - /app/node_modules + - ../../../microservices/product:/app + depends_on: + rabbitmq: + condition: service_healthy + + rbac: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/rbac + ports: + - "9017:9017" + volumes: + - /app/node_modules + - ../../../microservices/rbac:/app + depends_on: + rabbitmq: + condition: service_healthy + + supplier: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/supplier + ports: + - "9018:9018" + volumes: + - /app/node_modules + - ../../../microservices/supplier:/app + depends_on: + rabbitmq: + condition: service_healthy + + upload: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/upload + ports: + - "9019:9019" + volumes: + - /app/node_modules + - ../../../microservices/upload:/app + depends_on: + rabbitmq: + condition: service_healthy + + th: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/th + ports: + - "9020:9020" + volumes: + - /app/node_modules + - ../../../microservices/th:/app + depends_on: + rabbitmq: + condition: service_healthy + + kjhgf: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/kjhgf + ports: + - "9021:9021" + volumes: + - /app/node_modules + - ../../../microservices/kjhgf:/app + depends_on: + rabbitmq: + condition: service_healthy + + hhgfdsdfghj: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/hhgfdsdfghj + ports: + - "9022:9022" + volumes: + - /app/node_modules + - ../../../microservices/hhgfdsdfghj:/app + depends_on: + rabbitmq: + condition: service_healthy + + ghjk: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/ghjk + ports: + - "9023:9023" + volumes: + - /app/node_modules + - ../../../microservices/ghjk:/app + depends_on: + rabbitmq: + condition: service_healthy + + shjksgd: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/shjksgd + ports: + - "30067:30067" + volumes: + - /app/node_modules + - ../../../microservices/shjksgd:/app + depends_on: + rabbitmq: + condition: service_healthy + + nginx: + depends_on: + - hd + - customer-service + - product-service + - rbac-service + - payment-service + - notification-service + - email-service + - cart-service + - cart + - user + - customer + - email + - notification + - payment + - product + - rbac + - supplier + - upload + - th + - kjhgf + - hhgfdsdfghj + - ghjk + - shjksgd + restart: always + build: + context: ./nginx + dockerfile: Dockerfile.dev + ports: + - '4000:80' + healthcheck: + test: ["CMD-SHELL", "curl -f http://localhost:80/health || exit 1"] + interval: 30s + timeout: 10s + retries: 3 + start_period: 40s + rabbitmq: + image: rabbitmq:3.13-management + container_name: rabbitmq + ports: + - '5672:5672' + - '15672:15672' + healthcheck: + test: ["CMD", "rabbitmq-diagnostics", "ping"] + interval: 30s + retries: 5 + mongodb: + image: mongo + ports: + - '27017:27017' + restart: always + volumes: + - type: bind + source: ./data + target: /data/db + krakend: + image: devopsfaith/krakend:2.7 + ports: + - '8080:8080' + - '8090:8090' + volumes: + - ./krakend/:/etc/krakend/ + command: ['run','-d','-c','/etc/krakend/krakend.json'] \ No newline at end of file diff --git a/gateways/apps/name/krakend/krakend.json b/gateways/apps/name/krakend/krakend.json new file mode 100644 index 0000000..89d801a --- /dev/null +++ b/gateways/apps/name/krakend/krakend.json @@ -0,0 +1,402 @@ + +{ + "$schema": "https://www.krakend.io/schema/v2.5/krakend.json", + "version": 3, + "name": "Microservices-suite API Gateway", + "port": 8080, + "cache_ttl": "3600s", + "timeout": "300s", + "endpoints": [ + { + "@comment": "Check the health of all your APIs", + "endpoint": "/__suite_status", + "method": "GET", + "backend": [ + { + "host": ["http://hd:null"], + "url_pattern": "/", + "mapping": { + "message": "hd" + } + }, + + { + "host": ["http://customer-service:9000"], + "url_pattern": "/", + "mapping": { + "message": "customer-service" + } + }, + + { + "host": ["http://product-service:9002"], + "url_pattern": "/", + "mapping": { + "message": "product-service" + } + }, + + { + "host": ["http://rbac-service:9004"], + "url_pattern": "/", + "mapping": { + "message": "rbac-service" + } + }, + + { + "host": ["http://payment-service:9006"], + "url_pattern": "/", + "mapping": { + "message": "payment-service" + } + }, + + { + "host": ["http://notification-service:9007"], + "url_pattern": "/", + "mapping": { + "message": "notification-service" + } + }, + + { + "host": ["http://email-service:9008"], + "url_pattern": "/", + "mapping": { + "message": "email-service" + } + }, + + { + "host": ["http://cart-service:9009"], + "url_pattern": "/", + "mapping": { + "message": "cart-service" + } + }, + + { + "host": ["http://cart:9010"], + "url_pattern": "/", + "mapping": { + "message": "cart" + } + }, + + { + "host": ["http://user:9011"], + "url_pattern": "/", + "mapping": { + "message": "user" + } + }, + + { + "host": ["http://customer:9012"], + "url_pattern": "/", + "mapping": { + "message": "customer" + } + }, + + { + "host": ["http://email:9013"], + "url_pattern": "/", + "mapping": { + "message": "email" + } + }, + + { + "host": ["http://notification:9014"], + "url_pattern": "/", + "mapping": { + "message": "notification" + } + }, + + { + "host": ["http://payment:9015"], + "url_pattern": "/", + "mapping": { + "message": "payment" + } + }, + + { + "host": ["http://product:9016"], + "url_pattern": "/", + "mapping": { + "message": "product" + } + }, + + { + "host": ["http://rbac:9017"], + "url_pattern": "/", + "mapping": { + "message": "rbac" + } + }, + + { + "host": ["http://supplier:9018"], + "url_pattern": "/", + "mapping": { + "message": "supplier" + } + }, + + { + "host": ["http://upload:9019"], + "url_pattern": "/", + "mapping": { + "message": "upload" + } + }, + + { + "host": ["http://th:9020"], + "url_pattern": "/", + "mapping": { + "message": "th" + } + }, + + { + "host": ["http://kjhgf:9021"], + "url_pattern": "/", + "mapping": { + "message": "kjhgf" + } + }, + + { + "host": ["http://hhgfdsdfghj:9022"], + "url_pattern": "/", + "mapping": { + "message": "hhgfdsdfghj" + } + }, + + { + "host": ["http://ghjk:9023"], + "url_pattern": "/", + "mapping": { + "message": "ghjk" + } + }, + + { + "host": ["http://shjksgd:30067"], + "url_pattern": "/", + "mapping": { + "message": "shjksgd" + } + }] + }, + { + "@comment": "Hit all API list endpoints simultaneously", + "endpoint": "/api/v1/", + "method": "GET", + "backend": [ + { + "host": ["http://hd:null"], + "url_pattern": "/api/v1/hds", + "mapping": { + "data": "hds" + } + }, + + { + "host": ["http://customer-service:9000"], + "url_pattern": "/api/v1/customer-services", + "mapping": { + "data": "customer-services" + } + }, + + { + "host": ["http://product-service:9002"], + "url_pattern": "/api/v1/product-services", + "mapping": { + "data": "product-services" + } + }, + + { + "host": ["http://rbac-service:9004"], + "url_pattern": "/api/v1/rbac-services", + "mapping": { + "data": "rbac-services" + } + }, + + { + "host": ["http://payment-service:9006"], + "url_pattern": "/api/v1/payment-services", + "mapping": { + "data": "payment-services" + } + }, + + { + "host": ["http://notification-service:9007"], + "url_pattern": "/api/v1/notification-services", + "mapping": { + "data": "notification-services" + } + }, + + { + "host": ["http://email-service:9008"], + "url_pattern": "/api/v1/email-services", + "mapping": { + "data": "email-services" + } + }, + + { + "host": ["http://cart-service:9009"], + "url_pattern": "/api/v1/cart-services", + "mapping": { + "data": "cart-services" + } + }, + + { + "host": ["http://cart:9010"], + "url_pattern": "/api/v1/carts", + "mapping": { + "data": "carts" + } + }, + + { + "host": ["http://user:9011"], + "url_pattern": "/api/v1/users", + "mapping": { + "data": "users" + } + }, + + { + "host": ["http://customer:9012"], + "url_pattern": "/api/v1/customers", + "mapping": { + "data": "customers" + } + }, + + { + "host": ["http://email:9013"], + "url_pattern": "/api/v1/emails", + "mapping": { + "data": "emails" + } + }, + + { + "host": ["http://notification:9014"], + "url_pattern": "/api/v1/notifications", + "mapping": { + "data": "notifications" + } + }, + + { + "host": ["http://payment:9015"], + "url_pattern": "/api/v1/payments", + "mapping": { + "data": "payments" + } + }, + + { + "host": ["http://product:9016"], + "url_pattern": "/api/v1/products", + "mapping": { + "data": "products" + } + }, + + { + "host": ["http://rbac:9017"], + "url_pattern": "/api/v1/rbacs", + "mapping": { + "data": "rbacs" + } + }, + + { + "host": ["http://supplier:9018"], + "url_pattern": "/api/v1/suppliers", + "mapping": { + "data": "suppliers" + } + }, + + { + "host": ["http://upload:9019"], + "url_pattern": "/api/v1/uploads", + "mapping": { + "data": "uploads" + } + }, + + { + "host": ["http://th:9020"], + "url_pattern": "/api/v1/ths", + "mapping": { + "data": "ths" + } + }, + + { + "host": ["http://kjhgf:9021"], + "url_pattern": "/api/v1/kjhgfs", + "mapping": { + "data": "kjhgfs" + } + }, + + { + "host": ["http://hhgfdsdfghj:9022"], + "url_pattern": "/api/v1/hhgfdsdfghjs", + "mapping": { + "data": "hhgfdsdfghjs" + } + }, + + { + "host": ["http://ghjk:9023"], + "url_pattern": "/api/v1/ghjks", + "mapping": { + "data": "ghjks" + } + }, + + { + "host": ["http://shjksgd:30067"], + "url_pattern": "/api/v1/shjksgds", + "mapping": { + "data": "shjksgds" + } + }] + }, + { + "@comment": "Fetch all data from the hd service", + "endpoint": "/api/v1/hds", + "method": "GET", + "backend": [ + { + "host": ["http://hd:null"], + "url_pattern": "/api/v1/hds", + "mapping": { + "data": "hds" + } + }] + } + ] +} \ No newline at end of file diff --git a/gateways/apps/name/nginx/Dockerfile b/gateways/apps/name/nginx/Dockerfile new file mode 100644 index 0000000..ddf7281 --- /dev/null +++ b/gateways/apps/name/nginx/Dockerfile @@ -0,0 +1,3 @@ + +FROM nginx +COPY ./default.conf /etc/nginx/conf.d/default.conf \ No newline at end of file diff --git a/gateways/apps/name/nginx/Dockerfile.dev b/gateways/apps/name/nginx/Dockerfile.dev new file mode 100644 index 0000000..ddf7281 --- /dev/null +++ b/gateways/apps/name/nginx/Dockerfile.dev @@ -0,0 +1,3 @@ + +FROM nginx +COPY ./default.conf /etc/nginx/conf.d/default.conf \ No newline at end of file diff --git a/gateways/apps/name/nginx/default.conf b/gateways/apps/name/nginx/default.conf new file mode 100644 index 0000000..d4dace0 --- /dev/null +++ b/gateways/apps/name/nginx/default.conf @@ -0,0 +1,282 @@ + + +upstream hd_upstream { + server hd:null; +} + +upstream customer-service_upstream { + server customer-service:9000; +} + +upstream product-service_upstream { + server product-service:9002; +} + +upstream rbac-service_upstream { + server rbac-service:9004; +} + +upstream payment-service_upstream { + server payment-service:9006; +} + +upstream notification-service_upstream { + server notification-service:9007; +} + +upstream email-service_upstream { + server email-service:9008; +} + +upstream cart-service_upstream { + server cart-service:9009; +} + +upstream cart_upstream { + server cart:9010; +} + +upstream user_upstream { + server user:9011; +} + +upstream customer_upstream { + server customer:9012; +} + +upstream email_upstream { + server email:9013; +} + +upstream notification_upstream { + server notification:9014; +} + +upstream payment_upstream { + server payment:9015; +} + +upstream product_upstream { + server product:9016; +} + +upstream rbac_upstream { + server rbac:9017; +} + +upstream supplier_upstream { + server supplier:9018; +} + +upstream upload_upstream { + server upload:9019; +} + +upstream th_upstream { + server th:9020; +} + +upstream kjhgf_upstream { + server kjhgf:9021; +} + +upstream hhgfdsdfghj_upstream { + server hhgfdsdfghj:9022; +} + +upstream ghjk_upstream { + server ghjk:9023; +} + +upstream shjksgd_upstream { + server shjksgd:30067; +} + +server { + listen 80; + + + location /api/v1/hds { + proxy_pass http://hd_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/customer-services { + proxy_pass http://customer-service_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/product-services { + proxy_pass http://product-service_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/rbac-services { + proxy_pass http://rbac-service_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/payment-services { + proxy_pass http://payment-service_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/notification-services { + proxy_pass http://notification-service_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/email-services { + proxy_pass http://email-service_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/cart-services { + proxy_pass http://cart-service_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/carts { + proxy_pass http://cart_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/users { + proxy_pass http://user_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/customers { + proxy_pass http://customer_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/emails { + proxy_pass http://email_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/notifications { + proxy_pass http://notification_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/payments { + proxy_pass http://payment_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/products { + proxy_pass http://product_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/rbacs { + proxy_pass http://rbac_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/suppliers { + proxy_pass http://supplier_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/uploads { + proxy_pass http://upload_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/ths { + proxy_pass http://th_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/kjhgfs { + proxy_pass http://kjhgf_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/hhgfdsdfghjs { + proxy_pass http://hhgfdsdfghj_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/ghjks { + proxy_pass http://ghjk_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/shjksgds { + proxy_pass http://shjksgd_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } +} \ No newline at end of file diff --git a/gateways/apps/orders/docker-compose.dev.yml b/gateways/apps/orders/docker-compose.dev.yml new file mode 100644 index 0000000..8f4f751 --- /dev/null +++ b/gateways/apps/orders/docker-compose.dev.yml @@ -0,0 +1,367 @@ + +version: '3.8' +services: + + hd: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/hd + ports: + - "null:null" + volumes: + - /app/node_modules + - ../../../microservices/hd:/app + depends_on: + rabbitmq: + condition: service_healthy + + customer-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/customer-service + ports: + - "9000:9000" + volumes: + - /app/node_modules + - ../../../microservices/customer-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + product-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/product-service + ports: + - "9002:9002" + volumes: + - /app/node_modules + - ../../../microservices/product-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + rbac-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/rbac-service + ports: + - "9004:9004" + volumes: + - /app/node_modules + - ../../../microservices/rbac-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + payment-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/payment-service + ports: + - "9006:9006" + volumes: + - /app/node_modules + - ../../../microservices/payment-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + notification-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/notification-service + ports: + - "9007:9007" + volumes: + - /app/node_modules + - ../../../microservices/notification-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + email-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/email-service + ports: + - "9008:9008" + volumes: + - /app/node_modules + - ../../../microservices/email-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + cart-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/cart-service + ports: + - "9009:9009" + volumes: + - /app/node_modules + - ../../../microservices/cart-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + cart: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/cart + ports: + - "9010:9010" + volumes: + - /app/node_modules + - ../../../microservices/cart:/app + depends_on: + rabbitmq: + condition: service_healthy + + user: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/user + ports: + - "9011:9011" + volumes: + - /app/node_modules + - ../../../microservices/user:/app + depends_on: + rabbitmq: + condition: service_healthy + + customer: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/customer + ports: + - "9012:9012" + volumes: + - /app/node_modules + - ../../../microservices/customer:/app + depends_on: + rabbitmq: + condition: service_healthy + + email: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/email + ports: + - "9013:9013" + volumes: + - /app/node_modules + - ../../../microservices/email:/app + depends_on: + rabbitmq: + condition: service_healthy + + notification: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/notification + ports: + - "9014:9014" + volumes: + - /app/node_modules + - ../../../microservices/notification:/app + depends_on: + rabbitmq: + condition: service_healthy + + payment: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/payment + ports: + - "9015:9015" + volumes: + - /app/node_modules + - ../../../microservices/payment:/app + depends_on: + rabbitmq: + condition: service_healthy + + product: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/product + ports: + - "9016:9016" + volumes: + - /app/node_modules + - ../../../microservices/product:/app + depends_on: + rabbitmq: + condition: service_healthy + + rbac: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/rbac + ports: + - "9017:9017" + volumes: + - /app/node_modules + - ../../../microservices/rbac:/app + depends_on: + rabbitmq: + condition: service_healthy + + supplier: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/supplier + ports: + - "9018:9018" + volumes: + - /app/node_modules + - ../../../microservices/supplier:/app + depends_on: + rabbitmq: + condition: service_healthy + + upload: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/upload + ports: + - "9019:9019" + volumes: + - /app/node_modules + - ../../../microservices/upload:/app + depends_on: + rabbitmq: + condition: service_healthy + + th: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/th + ports: + - "9020:9020" + volumes: + - /app/node_modules + - ../../../microservices/th:/app + depends_on: + rabbitmq: + condition: service_healthy + + kjhgf: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/kjhgf + ports: + - "9021:9021" + volumes: + - /app/node_modules + - ../../../microservices/kjhgf:/app + depends_on: + rabbitmq: + condition: service_healthy + + hhgfdsdfghj: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/hhgfdsdfghj + ports: + - "9022:9022" + volumes: + - /app/node_modules + - ../../../microservices/hhgfdsdfghj:/app + depends_on: + rabbitmq: + condition: service_healthy + + ghjk: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/ghjk + ports: + - "9023:9023" + volumes: + - /app/node_modules + - ../../../microservices/ghjk:/app + depends_on: + rabbitmq: + condition: service_healthy + + shjksgd: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/shjksgd + ports: + - "30067:30067" + volumes: + - /app/node_modules + - ../../../microservices/shjksgd:/app + depends_on: + rabbitmq: + condition: service_healthy + + nginx: + depends_on: + - hd + - customer-service + - product-service + - rbac-service + - payment-service + - notification-service + - email-service + - cart-service + - cart + - user + - customer + - email + - notification + - payment + - product + - rbac + - supplier + - upload + - th + - kjhgf + - hhgfdsdfghj + - ghjk + - shjksgd + restart: always + build: + context: ./nginx + dockerfile: Dockerfile.dev + ports: + - '4000:80' + healthcheck: + test: ["CMD-SHELL", "curl -f http://localhost:80/health || exit 1"] + interval: 30s + timeout: 10s + retries: 3 + start_period: 40s + rabbitmq: + image: rabbitmq:3.13-management + container_name: rabbitmq + ports: + - '5672:5672' + - '15672:15672' + healthcheck: + test: ["CMD", "rabbitmq-diagnostics", "ping"] + interval: 30s + retries: 5 + mongodb: + image: mongo + ports: + - '27017:27017' + restart: always + volumes: + - type: bind + source: ./data + target: /data/db + krakend: + image: devopsfaith/krakend:2.7-watch + ports: + - '8080:8080' + - '8090:8090' + volumes: + - ./krakend/:/etc/krakend/ + command: ['run','-d','-c','/etc/krakend/krakend.json'] \ No newline at end of file diff --git a/gateways/apps/orders/docker-compose.yml b/gateways/apps/orders/docker-compose.yml new file mode 100644 index 0000000..97e3b67 --- /dev/null +++ b/gateways/apps/orders/docker-compose.yml @@ -0,0 +1,367 @@ + +version: '3.8' +services: + + hd: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/hd + ports: + - "null:null" + volumes: + - /app/node_modules + - ../../../microservices/hd:/app + depends_on: + rabbitmq: + condition: service_healthy + + customer-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/customer-service + ports: + - "9000:9000" + volumes: + - /app/node_modules + - ../../../microservices/customer-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + product-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/product-service + ports: + - "9002:9002" + volumes: + - /app/node_modules + - ../../../microservices/product-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + rbac-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/rbac-service + ports: + - "9004:9004" + volumes: + - /app/node_modules + - ../../../microservices/rbac-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + payment-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/payment-service + ports: + - "9006:9006" + volumes: + - /app/node_modules + - ../../../microservices/payment-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + notification-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/notification-service + ports: + - "9007:9007" + volumes: + - /app/node_modules + - ../../../microservices/notification-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + email-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/email-service + ports: + - "9008:9008" + volumes: + - /app/node_modules + - ../../../microservices/email-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + cart-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/cart-service + ports: + - "9009:9009" + volumes: + - /app/node_modules + - ../../../microservices/cart-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + cart: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/cart + ports: + - "9010:9010" + volumes: + - /app/node_modules + - ../../../microservices/cart:/app + depends_on: + rabbitmq: + condition: service_healthy + + user: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/user + ports: + - "9011:9011" + volumes: + - /app/node_modules + - ../../../microservices/user:/app + depends_on: + rabbitmq: + condition: service_healthy + + customer: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/customer + ports: + - "9012:9012" + volumes: + - /app/node_modules + - ../../../microservices/customer:/app + depends_on: + rabbitmq: + condition: service_healthy + + email: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/email + ports: + - "9013:9013" + volumes: + - /app/node_modules + - ../../../microservices/email:/app + depends_on: + rabbitmq: + condition: service_healthy + + notification: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/notification + ports: + - "9014:9014" + volumes: + - /app/node_modules + - ../../../microservices/notification:/app + depends_on: + rabbitmq: + condition: service_healthy + + payment: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/payment + ports: + - "9015:9015" + volumes: + - /app/node_modules + - ../../../microservices/payment:/app + depends_on: + rabbitmq: + condition: service_healthy + + product: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/product + ports: + - "9016:9016" + volumes: + - /app/node_modules + - ../../../microservices/product:/app + depends_on: + rabbitmq: + condition: service_healthy + + rbac: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/rbac + ports: + - "9017:9017" + volumes: + - /app/node_modules + - ../../../microservices/rbac:/app + depends_on: + rabbitmq: + condition: service_healthy + + supplier: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/supplier + ports: + - "9018:9018" + volumes: + - /app/node_modules + - ../../../microservices/supplier:/app + depends_on: + rabbitmq: + condition: service_healthy + + upload: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/upload + ports: + - "9019:9019" + volumes: + - /app/node_modules + - ../../../microservices/upload:/app + depends_on: + rabbitmq: + condition: service_healthy + + th: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/th + ports: + - "9020:9020" + volumes: + - /app/node_modules + - ../../../microservices/th:/app + depends_on: + rabbitmq: + condition: service_healthy + + kjhgf: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/kjhgf + ports: + - "9021:9021" + volumes: + - /app/node_modules + - ../../../microservices/kjhgf:/app + depends_on: + rabbitmq: + condition: service_healthy + + hhgfdsdfghj: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/hhgfdsdfghj + ports: + - "9022:9022" + volumes: + - /app/node_modules + - ../../../microservices/hhgfdsdfghj:/app + depends_on: + rabbitmq: + condition: service_healthy + + ghjk: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/ghjk + ports: + - "9023:9023" + volumes: + - /app/node_modules + - ../../../microservices/ghjk:/app + depends_on: + rabbitmq: + condition: service_healthy + + shjksgd: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/shjksgd + ports: + - "30067:30067" + volumes: + - /app/node_modules + - ../../../microservices/shjksgd:/app + depends_on: + rabbitmq: + condition: service_healthy + + nginx: + depends_on: + - hd + - customer-service + - product-service + - rbac-service + - payment-service + - notification-service + - email-service + - cart-service + - cart + - user + - customer + - email + - notification + - payment + - product + - rbac + - supplier + - upload + - th + - kjhgf + - hhgfdsdfghj + - ghjk + - shjksgd + restart: always + build: + context: ./nginx + dockerfile: Dockerfile.dev + ports: + - '4000:80' + healthcheck: + test: ["CMD-SHELL", "curl -f http://localhost:80/health || exit 1"] + interval: 30s + timeout: 10s + retries: 3 + start_period: 40s + rabbitmq: + image: rabbitmq:3.13-management + container_name: rabbitmq + ports: + - '5672:5672' + - '15672:15672' + healthcheck: + test: ["CMD", "rabbitmq-diagnostics", "ping"] + interval: 30s + retries: 5 + mongodb: + image: mongo + ports: + - '27017:27017' + restart: always + volumes: + - type: bind + source: ./data + target: /data/db + krakend: + image: devopsfaith/krakend:2.7 + ports: + - '8080:8080' + - '8090:8090' + volumes: + - ./krakend/:/etc/krakend/ + command: ['run','-d','-c','/etc/krakend/krakend.json'] \ No newline at end of file diff --git a/gateways/apps/orders/krakend/krakend.json b/gateways/apps/orders/krakend/krakend.json new file mode 100644 index 0000000..89d801a --- /dev/null +++ b/gateways/apps/orders/krakend/krakend.json @@ -0,0 +1,402 @@ + +{ + "$schema": "https://www.krakend.io/schema/v2.5/krakend.json", + "version": 3, + "name": "Microservices-suite API Gateway", + "port": 8080, + "cache_ttl": "3600s", + "timeout": "300s", + "endpoints": [ + { + "@comment": "Check the health of all your APIs", + "endpoint": "/__suite_status", + "method": "GET", + "backend": [ + { + "host": ["http://hd:null"], + "url_pattern": "/", + "mapping": { + "message": "hd" + } + }, + + { + "host": ["http://customer-service:9000"], + "url_pattern": "/", + "mapping": { + "message": "customer-service" + } + }, + + { + "host": ["http://product-service:9002"], + "url_pattern": "/", + "mapping": { + "message": "product-service" + } + }, + + { + "host": ["http://rbac-service:9004"], + "url_pattern": "/", + "mapping": { + "message": "rbac-service" + } + }, + + { + "host": ["http://payment-service:9006"], + "url_pattern": "/", + "mapping": { + "message": "payment-service" + } + }, + + { + "host": ["http://notification-service:9007"], + "url_pattern": "/", + "mapping": { + "message": "notification-service" + } + }, + + { + "host": ["http://email-service:9008"], + "url_pattern": "/", + "mapping": { + "message": "email-service" + } + }, + + { + "host": ["http://cart-service:9009"], + "url_pattern": "/", + "mapping": { + "message": "cart-service" + } + }, + + { + "host": ["http://cart:9010"], + "url_pattern": "/", + "mapping": { + "message": "cart" + } + }, + + { + "host": ["http://user:9011"], + "url_pattern": "/", + "mapping": { + "message": "user" + } + }, + + { + "host": ["http://customer:9012"], + "url_pattern": "/", + "mapping": { + "message": "customer" + } + }, + + { + "host": ["http://email:9013"], + "url_pattern": "/", + "mapping": { + "message": "email" + } + }, + + { + "host": ["http://notification:9014"], + "url_pattern": "/", + "mapping": { + "message": "notification" + } + }, + + { + "host": ["http://payment:9015"], + "url_pattern": "/", + "mapping": { + "message": "payment" + } + }, + + { + "host": ["http://product:9016"], + "url_pattern": "/", + "mapping": { + "message": "product" + } + }, + + { + "host": ["http://rbac:9017"], + "url_pattern": "/", + "mapping": { + "message": "rbac" + } + }, + + { + "host": ["http://supplier:9018"], + "url_pattern": "/", + "mapping": { + "message": "supplier" + } + }, + + { + "host": ["http://upload:9019"], + "url_pattern": "/", + "mapping": { + "message": "upload" + } + }, + + { + "host": ["http://th:9020"], + "url_pattern": "/", + "mapping": { + "message": "th" + } + }, + + { + "host": ["http://kjhgf:9021"], + "url_pattern": "/", + "mapping": { + "message": "kjhgf" + } + }, + + { + "host": ["http://hhgfdsdfghj:9022"], + "url_pattern": "/", + "mapping": { + "message": "hhgfdsdfghj" + } + }, + + { + "host": ["http://ghjk:9023"], + "url_pattern": "/", + "mapping": { + "message": "ghjk" + } + }, + + { + "host": ["http://shjksgd:30067"], + "url_pattern": "/", + "mapping": { + "message": "shjksgd" + } + }] + }, + { + "@comment": "Hit all API list endpoints simultaneously", + "endpoint": "/api/v1/", + "method": "GET", + "backend": [ + { + "host": ["http://hd:null"], + "url_pattern": "/api/v1/hds", + "mapping": { + "data": "hds" + } + }, + + { + "host": ["http://customer-service:9000"], + "url_pattern": "/api/v1/customer-services", + "mapping": { + "data": "customer-services" + } + }, + + { + "host": ["http://product-service:9002"], + "url_pattern": "/api/v1/product-services", + "mapping": { + "data": "product-services" + } + }, + + { + "host": ["http://rbac-service:9004"], + "url_pattern": "/api/v1/rbac-services", + "mapping": { + "data": "rbac-services" + } + }, + + { + "host": ["http://payment-service:9006"], + "url_pattern": "/api/v1/payment-services", + "mapping": { + "data": "payment-services" + } + }, + + { + "host": ["http://notification-service:9007"], + "url_pattern": "/api/v1/notification-services", + "mapping": { + "data": "notification-services" + } + }, + + { + "host": ["http://email-service:9008"], + "url_pattern": "/api/v1/email-services", + "mapping": { + "data": "email-services" + } + }, + + { + "host": ["http://cart-service:9009"], + "url_pattern": "/api/v1/cart-services", + "mapping": { + "data": "cart-services" + } + }, + + { + "host": ["http://cart:9010"], + "url_pattern": "/api/v1/carts", + "mapping": { + "data": "carts" + } + }, + + { + "host": ["http://user:9011"], + "url_pattern": "/api/v1/users", + "mapping": { + "data": "users" + } + }, + + { + "host": ["http://customer:9012"], + "url_pattern": "/api/v1/customers", + "mapping": { + "data": "customers" + } + }, + + { + "host": ["http://email:9013"], + "url_pattern": "/api/v1/emails", + "mapping": { + "data": "emails" + } + }, + + { + "host": ["http://notification:9014"], + "url_pattern": "/api/v1/notifications", + "mapping": { + "data": "notifications" + } + }, + + { + "host": ["http://payment:9015"], + "url_pattern": "/api/v1/payments", + "mapping": { + "data": "payments" + } + }, + + { + "host": ["http://product:9016"], + "url_pattern": "/api/v1/products", + "mapping": { + "data": "products" + } + }, + + { + "host": ["http://rbac:9017"], + "url_pattern": "/api/v1/rbacs", + "mapping": { + "data": "rbacs" + } + }, + + { + "host": ["http://supplier:9018"], + "url_pattern": "/api/v1/suppliers", + "mapping": { + "data": "suppliers" + } + }, + + { + "host": ["http://upload:9019"], + "url_pattern": "/api/v1/uploads", + "mapping": { + "data": "uploads" + } + }, + + { + "host": ["http://th:9020"], + "url_pattern": "/api/v1/ths", + "mapping": { + "data": "ths" + } + }, + + { + "host": ["http://kjhgf:9021"], + "url_pattern": "/api/v1/kjhgfs", + "mapping": { + "data": "kjhgfs" + } + }, + + { + "host": ["http://hhgfdsdfghj:9022"], + "url_pattern": "/api/v1/hhgfdsdfghjs", + "mapping": { + "data": "hhgfdsdfghjs" + } + }, + + { + "host": ["http://ghjk:9023"], + "url_pattern": "/api/v1/ghjks", + "mapping": { + "data": "ghjks" + } + }, + + { + "host": ["http://shjksgd:30067"], + "url_pattern": "/api/v1/shjksgds", + "mapping": { + "data": "shjksgds" + } + }] + }, + { + "@comment": "Fetch all data from the hd service", + "endpoint": "/api/v1/hds", + "method": "GET", + "backend": [ + { + "host": ["http://hd:null"], + "url_pattern": "/api/v1/hds", + "mapping": { + "data": "hds" + } + }] + } + ] +} \ No newline at end of file diff --git a/gateways/apps/orders/nginx/Dockerfile b/gateways/apps/orders/nginx/Dockerfile new file mode 100644 index 0000000..ddf7281 --- /dev/null +++ b/gateways/apps/orders/nginx/Dockerfile @@ -0,0 +1,3 @@ + +FROM nginx +COPY ./default.conf /etc/nginx/conf.d/default.conf \ No newline at end of file diff --git a/gateways/apps/orders/nginx/Dockerfile.dev b/gateways/apps/orders/nginx/Dockerfile.dev new file mode 100644 index 0000000..ddf7281 --- /dev/null +++ b/gateways/apps/orders/nginx/Dockerfile.dev @@ -0,0 +1,3 @@ + +FROM nginx +COPY ./default.conf /etc/nginx/conf.d/default.conf \ No newline at end of file diff --git a/gateways/apps/orders/nginx/default.conf b/gateways/apps/orders/nginx/default.conf new file mode 100644 index 0000000..d4dace0 --- /dev/null +++ b/gateways/apps/orders/nginx/default.conf @@ -0,0 +1,282 @@ + + +upstream hd_upstream { + server hd:null; +} + +upstream customer-service_upstream { + server customer-service:9000; +} + +upstream product-service_upstream { + server product-service:9002; +} + +upstream rbac-service_upstream { + server rbac-service:9004; +} + +upstream payment-service_upstream { + server payment-service:9006; +} + +upstream notification-service_upstream { + server notification-service:9007; +} + +upstream email-service_upstream { + server email-service:9008; +} + +upstream cart-service_upstream { + server cart-service:9009; +} + +upstream cart_upstream { + server cart:9010; +} + +upstream user_upstream { + server user:9011; +} + +upstream customer_upstream { + server customer:9012; +} + +upstream email_upstream { + server email:9013; +} + +upstream notification_upstream { + server notification:9014; +} + +upstream payment_upstream { + server payment:9015; +} + +upstream product_upstream { + server product:9016; +} + +upstream rbac_upstream { + server rbac:9017; +} + +upstream supplier_upstream { + server supplier:9018; +} + +upstream upload_upstream { + server upload:9019; +} + +upstream th_upstream { + server th:9020; +} + +upstream kjhgf_upstream { + server kjhgf:9021; +} + +upstream hhgfdsdfghj_upstream { + server hhgfdsdfghj:9022; +} + +upstream ghjk_upstream { + server ghjk:9023; +} + +upstream shjksgd_upstream { + server shjksgd:30067; +} + +server { + listen 80; + + + location /api/v1/hds { + proxy_pass http://hd_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/customer-services { + proxy_pass http://customer-service_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/product-services { + proxy_pass http://product-service_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/rbac-services { + proxy_pass http://rbac-service_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/payment-services { + proxy_pass http://payment-service_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/notification-services { + proxy_pass http://notification-service_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/email-services { + proxy_pass http://email-service_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/cart-services { + proxy_pass http://cart-service_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/carts { + proxy_pass http://cart_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/users { + proxy_pass http://user_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/customers { + proxy_pass http://customer_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/emails { + proxy_pass http://email_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/notifications { + proxy_pass http://notification_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/payments { + proxy_pass http://payment_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/products { + proxy_pass http://product_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/rbacs { + proxy_pass http://rbac_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/suppliers { + proxy_pass http://supplier_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/uploads { + proxy_pass http://upload_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/ths { + proxy_pass http://th_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/kjhgfs { + proxy_pass http://kjhgf_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/hhgfdsdfghjs { + proxy_pass http://hhgfdsdfghj_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/ghjks { + proxy_pass http://ghjk_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/shjksgds { + proxy_pass http://shjksgd_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } +} \ No newline at end of file diff --git a/gateways/apps/sdf/docker-compose.dev.yml b/gateways/apps/sdf/docker-compose.dev.yml new file mode 100644 index 0000000..5d85059 --- /dev/null +++ b/gateways/apps/sdf/docker-compose.dev.yml @@ -0,0 +1,367 @@ + +version: '3.8' +services: + + hd: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/hd + ports: + - "null:null" + volumes: + - /app/node_modules + - ../../../microservices/hd:/app + depends_on: + rabbitmq: + condition: service_healthy + + customer-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/customer-service + ports: + - "9000:9000" + volumes: + - /app/node_modules + - ../../../microservices/customer-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + product-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/product-service + ports: + - "9002:9002" + volumes: + - /app/node_modules + - ../../../microservices/product-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + rbac-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/rbac-service + ports: + - "9004:9004" + volumes: + - /app/node_modules + - ../../../microservices/rbac-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + payment-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/payment-service + ports: + - "9006:9006" + volumes: + - /app/node_modules + - ../../../microservices/payment-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + notification-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/notification-service + ports: + - "9007:9007" + volumes: + - /app/node_modules + - ../../../microservices/notification-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + email-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/email-service + ports: + - "9008:9008" + volumes: + - /app/node_modules + - ../../../microservices/email-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + cart-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/cart-service + ports: + - "9009:9009" + volumes: + - /app/node_modules + - ../../../microservices/cart-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + cart: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/cart + ports: + - "9010:9010" + volumes: + - /app/node_modules + - ../../../microservices/cart:/app + depends_on: + rabbitmq: + condition: service_healthy + + user: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/user + ports: + - "9011:9011" + volumes: + - /app/node_modules + - ../../../microservices/user:/app + depends_on: + rabbitmq: + condition: service_healthy + + customer: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/customer + ports: + - "9012:9012" + volumes: + - /app/node_modules + - ../../../microservices/customer:/app + depends_on: + rabbitmq: + condition: service_healthy + + email: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/email + ports: + - "9013:9013" + volumes: + - /app/node_modules + - ../../../microservices/email:/app + depends_on: + rabbitmq: + condition: service_healthy + + notification: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/notification + ports: + - "9014:9014" + volumes: + - /app/node_modules + - ../../../microservices/notification:/app + depends_on: + rabbitmq: + condition: service_healthy + + payment: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/payment + ports: + - "9015:9015" + volumes: + - /app/node_modules + - ../../../microservices/payment:/app + depends_on: + rabbitmq: + condition: service_healthy + + product: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/product + ports: + - "9016:9016" + volumes: + - /app/node_modules + - ../../../microservices/product:/app + depends_on: + rabbitmq: + condition: service_healthy + + rbac: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/rbac + ports: + - "9017:9017" + volumes: + - /app/node_modules + - ../../../microservices/rbac:/app + depends_on: + rabbitmq: + condition: service_healthy + + supplier: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/supplier + ports: + - "9018:9018" + volumes: + - /app/node_modules + - ../../../microservices/supplier:/app + depends_on: + rabbitmq: + condition: service_healthy + + upload: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/upload + ports: + - "9019:9019" + volumes: + - /app/node_modules + - ../../../microservices/upload:/app + depends_on: + rabbitmq: + condition: service_healthy + + th: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/th + ports: + - "9020:9020" + volumes: + - /app/node_modules + - ../../../microservices/th:/app + depends_on: + rabbitmq: + condition: service_healthy + + kjhgf: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/kjhgf + ports: + - "9021:9021" + volumes: + - /app/node_modules + - ../../../microservices/kjhgf:/app + depends_on: + rabbitmq: + condition: service_healthy + + hhgfdsdfghj: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/hhgfdsdfghj + ports: + - "9022:9022" + volumes: + - /app/node_modules + - ../../../microservices/hhgfdsdfghj:/app + depends_on: + rabbitmq: + condition: service_healthy + + ghjk: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/ghjk + ports: + - "9023:9023" + volumes: + - /app/node_modules + - ../../../microservices/ghjk:/app + depends_on: + rabbitmq: + condition: service_healthy + + shjksgd: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/shjksgd + ports: + - "30067:30067" + volumes: + - /app/node_modules + - ../../../microservices/shjksgd:/app + depends_on: + rabbitmq: + condition: service_healthy + + nginx: + depends_on: + - hd + - customer-service + - product-service + - rbac-service + - payment-service + - notification-service + - email-service + - cart-service + - cart + - user + - customer + - email + - notification + - payment + - product + - rbac + - supplier + - upload + - th + - kjhgf + - hhgfdsdfghj + - ghjk + - shjksgd + restart: always + build: + context: ./nginx + dockerfile: Dockerfile.dev + ports: + - '4000:80' + healthcheck: + test: ["CMD-SHELL", "curl -f http://localhost:80/health || exit 1"] + interval: 30s + timeout: 10s + retries: 3 + start_period: 40s + rabbitmq: + image: rabbitmq:3.13-management + container_name: rabbitmq + ports: + - '5672:5672' + - '15672:15672' + healthcheck: + test: ["CMD", "rabbitmq-diagnostics", "ping"] + interval: 30s + retries: 5 + mongodb: + image: mongo + ports: + - '27017:27017' + restart: always + volumes: + - type: bind + source: ./data + target: /data/db + krakend: + image: devopsfaith/krakend:2.7-watch + ports: + - '9001:9001' + - '8090:8090' + volumes: + - ./krakend/:/etc/krakend/ + command: ['run','-d','-c','/etc/krakend/krakend.json'] \ No newline at end of file diff --git a/gateways/apps/sdf/docker-compose.yml b/gateways/apps/sdf/docker-compose.yml new file mode 100644 index 0000000..cad4827 --- /dev/null +++ b/gateways/apps/sdf/docker-compose.yml @@ -0,0 +1,367 @@ + +version: '3.8' +services: + + hd: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/hd + ports: + - "null:null" + volumes: + - /app/node_modules + - ../../../microservices/hd:/app + depends_on: + rabbitmq: + condition: service_healthy + + customer-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/customer-service + ports: + - "9000:9000" + volumes: + - /app/node_modules + - ../../../microservices/customer-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + product-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/product-service + ports: + - "9002:9002" + volumes: + - /app/node_modules + - ../../../microservices/product-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + rbac-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/rbac-service + ports: + - "9004:9004" + volumes: + - /app/node_modules + - ../../../microservices/rbac-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + payment-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/payment-service + ports: + - "9006:9006" + volumes: + - /app/node_modules + - ../../../microservices/payment-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + notification-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/notification-service + ports: + - "9007:9007" + volumes: + - /app/node_modules + - ../../../microservices/notification-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + email-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/email-service + ports: + - "9008:9008" + volumes: + - /app/node_modules + - ../../../microservices/email-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + cart-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/cart-service + ports: + - "9009:9009" + volumes: + - /app/node_modules + - ../../../microservices/cart-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + cart: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/cart + ports: + - "9010:9010" + volumes: + - /app/node_modules + - ../../../microservices/cart:/app + depends_on: + rabbitmq: + condition: service_healthy + + user: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/user + ports: + - "9011:9011" + volumes: + - /app/node_modules + - ../../../microservices/user:/app + depends_on: + rabbitmq: + condition: service_healthy + + customer: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/customer + ports: + - "9012:9012" + volumes: + - /app/node_modules + - ../../../microservices/customer:/app + depends_on: + rabbitmq: + condition: service_healthy + + email: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/email + ports: + - "9013:9013" + volumes: + - /app/node_modules + - ../../../microservices/email:/app + depends_on: + rabbitmq: + condition: service_healthy + + notification: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/notification + ports: + - "9014:9014" + volumes: + - /app/node_modules + - ../../../microservices/notification:/app + depends_on: + rabbitmq: + condition: service_healthy + + payment: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/payment + ports: + - "9015:9015" + volumes: + - /app/node_modules + - ../../../microservices/payment:/app + depends_on: + rabbitmq: + condition: service_healthy + + product: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/product + ports: + - "9016:9016" + volumes: + - /app/node_modules + - ../../../microservices/product:/app + depends_on: + rabbitmq: + condition: service_healthy + + rbac: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/rbac + ports: + - "9017:9017" + volumes: + - /app/node_modules + - ../../../microservices/rbac:/app + depends_on: + rabbitmq: + condition: service_healthy + + supplier: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/supplier + ports: + - "9018:9018" + volumes: + - /app/node_modules + - ../../../microservices/supplier:/app + depends_on: + rabbitmq: + condition: service_healthy + + upload: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/upload + ports: + - "9019:9019" + volumes: + - /app/node_modules + - ../../../microservices/upload:/app + depends_on: + rabbitmq: + condition: service_healthy + + th: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/th + ports: + - "9020:9020" + volumes: + - /app/node_modules + - ../../../microservices/th:/app + depends_on: + rabbitmq: + condition: service_healthy + + kjhgf: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/kjhgf + ports: + - "9021:9021" + volumes: + - /app/node_modules + - ../../../microservices/kjhgf:/app + depends_on: + rabbitmq: + condition: service_healthy + + hhgfdsdfghj: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/hhgfdsdfghj + ports: + - "9022:9022" + volumes: + - /app/node_modules + - ../../../microservices/hhgfdsdfghj:/app + depends_on: + rabbitmq: + condition: service_healthy + + ghjk: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/ghjk + ports: + - "9023:9023" + volumes: + - /app/node_modules + - ../../../microservices/ghjk:/app + depends_on: + rabbitmq: + condition: service_healthy + + shjksgd: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/shjksgd + ports: + - "30067:30067" + volumes: + - /app/node_modules + - ../../../microservices/shjksgd:/app + depends_on: + rabbitmq: + condition: service_healthy + + nginx: + depends_on: + - hd + - customer-service + - product-service + - rbac-service + - payment-service + - notification-service + - email-service + - cart-service + - cart + - user + - customer + - email + - notification + - payment + - product + - rbac + - supplier + - upload + - th + - kjhgf + - hhgfdsdfghj + - ghjk + - shjksgd + restart: always + build: + context: ./nginx + dockerfile: Dockerfile.dev + ports: + - '4000:80' + healthcheck: + test: ["CMD-SHELL", "curl -f http://localhost:80/health || exit 1"] + interval: 30s + timeout: 10s + retries: 3 + start_period: 40s + rabbitmq: + image: rabbitmq:3.13-management + container_name: rabbitmq + ports: + - '5672:5672' + - '15672:15672' + healthcheck: + test: ["CMD", "rabbitmq-diagnostics", "ping"] + interval: 30s + retries: 5 + mongodb: + image: mongo + ports: + - '27017:27017' + restart: always + volumes: + - type: bind + source: ./data + target: /data/db + krakend: + image: devopsfaith/krakend:2.7 + ports: + - '9001:9001' + - '8090:8090' + volumes: + - ./krakend/:/etc/krakend/ + command: ['run','-d','-c','/etc/krakend/krakend.json'] \ No newline at end of file diff --git a/gateways/apps/sdf/krakend/krakend.json b/gateways/apps/sdf/krakend/krakend.json new file mode 100644 index 0000000..12a9d97 --- /dev/null +++ b/gateways/apps/sdf/krakend/krakend.json @@ -0,0 +1,402 @@ + +{ + "$schema": "https://www.krakend.io/schema/v2.5/krakend.json", + "version": 3, + "name": "Microservices-suite API Gateway", + "port": 9001, + "cache_ttl": "3600s", + "timeout": "300s", + "endpoints": [ + { + "@comment": "Check the health of all your APIs", + "endpoint": "/__suite_status", + "method": "GET", + "backend": [ + { + "host": ["http://hd:null"], + "url_pattern": "/", + "mapping": { + "message": "hd" + } + }, + + { + "host": ["http://customer-service:9000"], + "url_pattern": "/", + "mapping": { + "message": "customer-service" + } + }, + + { + "host": ["http://product-service:9002"], + "url_pattern": "/", + "mapping": { + "message": "product-service" + } + }, + + { + "host": ["http://rbac-service:9004"], + "url_pattern": "/", + "mapping": { + "message": "rbac-service" + } + }, + + { + "host": ["http://payment-service:9006"], + "url_pattern": "/", + "mapping": { + "message": "payment-service" + } + }, + + { + "host": ["http://notification-service:9007"], + "url_pattern": "/", + "mapping": { + "message": "notification-service" + } + }, + + { + "host": ["http://email-service:9008"], + "url_pattern": "/", + "mapping": { + "message": "email-service" + } + }, + + { + "host": ["http://cart-service:9009"], + "url_pattern": "/", + "mapping": { + "message": "cart-service" + } + }, + + { + "host": ["http://cart:9010"], + "url_pattern": "/", + "mapping": { + "message": "cart" + } + }, + + { + "host": ["http://user:9011"], + "url_pattern": "/", + "mapping": { + "message": "user" + } + }, + + { + "host": ["http://customer:9012"], + "url_pattern": "/", + "mapping": { + "message": "customer" + } + }, + + { + "host": ["http://email:9013"], + "url_pattern": "/", + "mapping": { + "message": "email" + } + }, + + { + "host": ["http://notification:9014"], + "url_pattern": "/", + "mapping": { + "message": "notification" + } + }, + + { + "host": ["http://payment:9015"], + "url_pattern": "/", + "mapping": { + "message": "payment" + } + }, + + { + "host": ["http://product:9016"], + "url_pattern": "/", + "mapping": { + "message": "product" + } + }, + + { + "host": ["http://rbac:9017"], + "url_pattern": "/", + "mapping": { + "message": "rbac" + } + }, + + { + "host": ["http://supplier:9018"], + "url_pattern": "/", + "mapping": { + "message": "supplier" + } + }, + + { + "host": ["http://upload:9019"], + "url_pattern": "/", + "mapping": { + "message": "upload" + } + }, + + { + "host": ["http://th:9020"], + "url_pattern": "/", + "mapping": { + "message": "th" + } + }, + + { + "host": ["http://kjhgf:9021"], + "url_pattern": "/", + "mapping": { + "message": "kjhgf" + } + }, + + { + "host": ["http://hhgfdsdfghj:9022"], + "url_pattern": "/", + "mapping": { + "message": "hhgfdsdfghj" + } + }, + + { + "host": ["http://ghjk:9023"], + "url_pattern": "/", + "mapping": { + "message": "ghjk" + } + }, + + { + "host": ["http://shjksgd:30067"], + "url_pattern": "/", + "mapping": { + "message": "shjksgd" + } + }] + }, + { + "@comment": "Hit all API list endpoints simultaneously", + "endpoint": "/api/v1/", + "method": "GET", + "backend": [ + { + "host": ["http://hd:null"], + "url_pattern": "/api/v1/hds", + "mapping": { + "data": "hds" + } + }, + + { + "host": ["http://customer-service:9000"], + "url_pattern": "/api/v1/customer-services", + "mapping": { + "data": "customer-services" + } + }, + + { + "host": ["http://product-service:9002"], + "url_pattern": "/api/v1/product-services", + "mapping": { + "data": "product-services" + } + }, + + { + "host": ["http://rbac-service:9004"], + "url_pattern": "/api/v1/rbac-services", + "mapping": { + "data": "rbac-services" + } + }, + + { + "host": ["http://payment-service:9006"], + "url_pattern": "/api/v1/payment-services", + "mapping": { + "data": "payment-services" + } + }, + + { + "host": ["http://notification-service:9007"], + "url_pattern": "/api/v1/notification-services", + "mapping": { + "data": "notification-services" + } + }, + + { + "host": ["http://email-service:9008"], + "url_pattern": "/api/v1/email-services", + "mapping": { + "data": "email-services" + } + }, + + { + "host": ["http://cart-service:9009"], + "url_pattern": "/api/v1/cart-services", + "mapping": { + "data": "cart-services" + } + }, + + { + "host": ["http://cart:9010"], + "url_pattern": "/api/v1/carts", + "mapping": { + "data": "carts" + } + }, + + { + "host": ["http://user:9011"], + "url_pattern": "/api/v1/users", + "mapping": { + "data": "users" + } + }, + + { + "host": ["http://customer:9012"], + "url_pattern": "/api/v1/customers", + "mapping": { + "data": "customers" + } + }, + + { + "host": ["http://email:9013"], + "url_pattern": "/api/v1/emails", + "mapping": { + "data": "emails" + } + }, + + { + "host": ["http://notification:9014"], + "url_pattern": "/api/v1/notifications", + "mapping": { + "data": "notifications" + } + }, + + { + "host": ["http://payment:9015"], + "url_pattern": "/api/v1/payments", + "mapping": { + "data": "payments" + } + }, + + { + "host": ["http://product:9016"], + "url_pattern": "/api/v1/products", + "mapping": { + "data": "products" + } + }, + + { + "host": ["http://rbac:9017"], + "url_pattern": "/api/v1/rbacs", + "mapping": { + "data": "rbacs" + } + }, + + { + "host": ["http://supplier:9018"], + "url_pattern": "/api/v1/suppliers", + "mapping": { + "data": "suppliers" + } + }, + + { + "host": ["http://upload:9019"], + "url_pattern": "/api/v1/uploads", + "mapping": { + "data": "uploads" + } + }, + + { + "host": ["http://th:9020"], + "url_pattern": "/api/v1/ths", + "mapping": { + "data": "ths" + } + }, + + { + "host": ["http://kjhgf:9021"], + "url_pattern": "/api/v1/kjhgfs", + "mapping": { + "data": "kjhgfs" + } + }, + + { + "host": ["http://hhgfdsdfghj:9022"], + "url_pattern": "/api/v1/hhgfdsdfghjs", + "mapping": { + "data": "hhgfdsdfghjs" + } + }, + + { + "host": ["http://ghjk:9023"], + "url_pattern": "/api/v1/ghjks", + "mapping": { + "data": "ghjks" + } + }, + + { + "host": ["http://shjksgd:30067"], + "url_pattern": "/api/v1/shjksgds", + "mapping": { + "data": "shjksgds" + } + }] + }, + { + "@comment": "Fetch all data from the hd service", + "endpoint": "/api/v1/hds", + "method": "GET", + "backend": [ + { + "host": ["http://hd:null"], + "url_pattern": "/api/v1/hds", + "mapping": { + "data": "hds" + } + }] + } + ] +} \ No newline at end of file diff --git a/gateways/apps/sdf/nginx/Dockerfile b/gateways/apps/sdf/nginx/Dockerfile new file mode 100644 index 0000000..ddf7281 --- /dev/null +++ b/gateways/apps/sdf/nginx/Dockerfile @@ -0,0 +1,3 @@ + +FROM nginx +COPY ./default.conf /etc/nginx/conf.d/default.conf \ No newline at end of file diff --git a/gateways/apps/sdf/nginx/Dockerfile.dev b/gateways/apps/sdf/nginx/Dockerfile.dev new file mode 100644 index 0000000..ddf7281 --- /dev/null +++ b/gateways/apps/sdf/nginx/Dockerfile.dev @@ -0,0 +1,3 @@ + +FROM nginx +COPY ./default.conf /etc/nginx/conf.d/default.conf \ No newline at end of file diff --git a/gateways/apps/sdf/nginx/default.conf b/gateways/apps/sdf/nginx/default.conf new file mode 100644 index 0000000..d4dace0 --- /dev/null +++ b/gateways/apps/sdf/nginx/default.conf @@ -0,0 +1,282 @@ + + +upstream hd_upstream { + server hd:null; +} + +upstream customer-service_upstream { + server customer-service:9000; +} + +upstream product-service_upstream { + server product-service:9002; +} + +upstream rbac-service_upstream { + server rbac-service:9004; +} + +upstream payment-service_upstream { + server payment-service:9006; +} + +upstream notification-service_upstream { + server notification-service:9007; +} + +upstream email-service_upstream { + server email-service:9008; +} + +upstream cart-service_upstream { + server cart-service:9009; +} + +upstream cart_upstream { + server cart:9010; +} + +upstream user_upstream { + server user:9011; +} + +upstream customer_upstream { + server customer:9012; +} + +upstream email_upstream { + server email:9013; +} + +upstream notification_upstream { + server notification:9014; +} + +upstream payment_upstream { + server payment:9015; +} + +upstream product_upstream { + server product:9016; +} + +upstream rbac_upstream { + server rbac:9017; +} + +upstream supplier_upstream { + server supplier:9018; +} + +upstream upload_upstream { + server upload:9019; +} + +upstream th_upstream { + server th:9020; +} + +upstream kjhgf_upstream { + server kjhgf:9021; +} + +upstream hhgfdsdfghj_upstream { + server hhgfdsdfghj:9022; +} + +upstream ghjk_upstream { + server ghjk:9023; +} + +upstream shjksgd_upstream { + server shjksgd:30067; +} + +server { + listen 80; + + + location /api/v1/hds { + proxy_pass http://hd_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/customer-services { + proxy_pass http://customer-service_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/product-services { + proxy_pass http://product-service_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/rbac-services { + proxy_pass http://rbac-service_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/payment-services { + proxy_pass http://payment-service_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/notification-services { + proxy_pass http://notification-service_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/email-services { + proxy_pass http://email-service_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/cart-services { + proxy_pass http://cart-service_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/carts { + proxy_pass http://cart_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/users { + proxy_pass http://user_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/customers { + proxy_pass http://customer_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/emails { + proxy_pass http://email_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/notifications { + proxy_pass http://notification_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/payments { + proxy_pass http://payment_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/products { + proxy_pass http://product_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/rbacs { + proxy_pass http://rbac_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/suppliers { + proxy_pass http://supplier_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/uploads { + proxy_pass http://upload_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/ths { + proxy_pass http://th_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/kjhgfs { + proxy_pass http://kjhgf_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/hhgfdsdfghjs { + proxy_pass http://hhgfdsdfghj_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/ghjks { + proxy_pass http://ghjk_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/shjksgds { + proxy_pass http://shjksgd_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } +} \ No newline at end of file diff --git a/gateways/apps/tesrtuigfghjk/docker-compose.dev.yml b/gateways/apps/tesrtuigfghjk/docker-compose.dev.yml new file mode 100644 index 0000000..deb401b --- /dev/null +++ b/gateways/apps/tesrtuigfghjk/docker-compose.dev.yml @@ -0,0 +1,325 @@ + +version: '3.8' +services: + + hd: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/hd + ports: + - "null:null" + volumes: + - /app/node_modules + - ../../../microservices/hd:/app + depends_on: + rabbitmq: + condition: service_healthy + + customer-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/customer-service + ports: + - "9000:9000" + volumes: + - /app/node_modules + - ../../../microservices/customer-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + product-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/product-service + ports: + - "9002:9002" + volumes: + - /app/node_modules + - ../../../microservices/product-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + rbac-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/rbac-service + ports: + - "9004:9004" + volumes: + - /app/node_modules + - ../../../microservices/rbac-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + payment-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/payment-service + ports: + - "9006:9006" + volumes: + - /app/node_modules + - ../../../microservices/payment-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + notification-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/notification-service + ports: + - "9007:9007" + volumes: + - /app/node_modules + - ../../../microservices/notification-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + email-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/email-service + ports: + - "9008:9008" + volumes: + - /app/node_modules + - ../../../microservices/email-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + cart-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/cart-service + ports: + - "9009:9009" + volumes: + - /app/node_modules + - ../../../microservices/cart-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + cart: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/cart + ports: + - "9010:9010" + volumes: + - /app/node_modules + - ../../../microservices/cart:/app + depends_on: + rabbitmq: + condition: service_healthy + + user: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/user + ports: + - "9011:9011" + volumes: + - /app/node_modules + - ../../../microservices/user:/app + depends_on: + rabbitmq: + condition: service_healthy + + customer: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/customer + ports: + - "9012:9012" + volumes: + - /app/node_modules + - ../../../microservices/customer:/app + depends_on: + rabbitmq: + condition: service_healthy + + email: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/email + ports: + - "9013:9013" + volumes: + - /app/node_modules + - ../../../microservices/email:/app + depends_on: + rabbitmq: + condition: service_healthy + + notification: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/notification + ports: + - "9014:9014" + volumes: + - /app/node_modules + - ../../../microservices/notification:/app + depends_on: + rabbitmq: + condition: service_healthy + + payment: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/payment + ports: + - "9015:9015" + volumes: + - /app/node_modules + - ../../../microservices/payment:/app + depends_on: + rabbitmq: + condition: service_healthy + + product: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/product + ports: + - "9016:9016" + volumes: + - /app/node_modules + - ../../../microservices/product:/app + depends_on: + rabbitmq: + condition: service_healthy + + rbac: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/rbac + ports: + - "9017:9017" + volumes: + - /app/node_modules + - ../../../microservices/rbac:/app + depends_on: + rabbitmq: + condition: service_healthy + + supplier: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/supplier + ports: + - "9018:9018" + volumes: + - /app/node_modules + - ../../../microservices/supplier:/app + depends_on: + rabbitmq: + condition: service_healthy + + upload: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/upload + ports: + - "9019:9019" + volumes: + - /app/node_modules + - ../../../microservices/upload:/app + depends_on: + rabbitmq: + condition: service_healthy + + th: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/th + ports: + - "9020:9020" + volumes: + - /app/node_modules + - ../../../microservices/th:/app + depends_on: + rabbitmq: + condition: service_healthy + + kjhgf: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/kjhgf + ports: + - "9021:9021" + volumes: + - /app/node_modules + - ../../../microservices/kjhgf:/app + depends_on: + rabbitmq: + condition: service_healthy + + nginx: + depends_on: + - hd + - customer-service + - product-service + - rbac-service + - payment-service + - notification-service + - email-service + - cart-service + - cart + - user + - customer + - email + - notification + - payment + - product + - rbac + - supplier + - upload + - th + - kjhgf + restart: always + build: + context: ./nginx + dockerfile: Dockerfile.dev + ports: + - '4000:80' + healthcheck: + test: ["CMD-SHELL", "curl -f http://localhost:80/health || exit 1"] + interval: 30s + timeout: 10s + retries: 3 + start_period: 40s + rabbitmq: + image: rabbitmq:3.13-management + container_name: rabbitmq + ports: + - '5672:5672' + - '15672:15672' + healthcheck: + test: ["CMD", "rabbitmq-diagnostics", "ping"] + interval: 30s + retries: 5 + mongodb: + image: mongo + ports: + - '27017:27017' + restart: always + volumes: + - type: bind + source: ./data + target: /data/db + krakend: + image: devopsfaith/krakend:2.7-watch + ports: + - '9001:9001' + - '8090:8090' + volumes: + - ./krakend/:/etc/krakend/ + command: ['run','-d','-c','/etc/krakend/krakend.json'] \ No newline at end of file diff --git a/gateways/apps/tesrtuigfghjk/docker-compose.yml b/gateways/apps/tesrtuigfghjk/docker-compose.yml new file mode 100644 index 0000000..be77908 --- /dev/null +++ b/gateways/apps/tesrtuigfghjk/docker-compose.yml @@ -0,0 +1,325 @@ + +version: '3.8' +services: + + hd: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/hd + ports: + - "null:null" + volumes: + - /app/node_modules + - ../../../microservices/hd:/app + depends_on: + rabbitmq: + condition: service_healthy + + customer-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/customer-service + ports: + - "9000:9000" + volumes: + - /app/node_modules + - ../../../microservices/customer-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + product-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/product-service + ports: + - "9002:9002" + volumes: + - /app/node_modules + - ../../../microservices/product-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + rbac-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/rbac-service + ports: + - "9004:9004" + volumes: + - /app/node_modules + - ../../../microservices/rbac-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + payment-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/payment-service + ports: + - "9006:9006" + volumes: + - /app/node_modules + - ../../../microservices/payment-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + notification-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/notification-service + ports: + - "9007:9007" + volumes: + - /app/node_modules + - ../../../microservices/notification-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + email-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/email-service + ports: + - "9008:9008" + volumes: + - /app/node_modules + - ../../../microservices/email-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + cart-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/cart-service + ports: + - "9009:9009" + volumes: + - /app/node_modules + - ../../../microservices/cart-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + cart: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/cart + ports: + - "9010:9010" + volumes: + - /app/node_modules + - ../../../microservices/cart:/app + depends_on: + rabbitmq: + condition: service_healthy + + user: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/user + ports: + - "9011:9011" + volumes: + - /app/node_modules + - ../../../microservices/user:/app + depends_on: + rabbitmq: + condition: service_healthy + + customer: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/customer + ports: + - "9012:9012" + volumes: + - /app/node_modules + - ../../../microservices/customer:/app + depends_on: + rabbitmq: + condition: service_healthy + + email: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/email + ports: + - "9013:9013" + volumes: + - /app/node_modules + - ../../../microservices/email:/app + depends_on: + rabbitmq: + condition: service_healthy + + notification: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/notification + ports: + - "9014:9014" + volumes: + - /app/node_modules + - ../../../microservices/notification:/app + depends_on: + rabbitmq: + condition: service_healthy + + payment: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/payment + ports: + - "9015:9015" + volumes: + - /app/node_modules + - ../../../microservices/payment:/app + depends_on: + rabbitmq: + condition: service_healthy + + product: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/product + ports: + - "9016:9016" + volumes: + - /app/node_modules + - ../../../microservices/product:/app + depends_on: + rabbitmq: + condition: service_healthy + + rbac: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/rbac + ports: + - "9017:9017" + volumes: + - /app/node_modules + - ../../../microservices/rbac:/app + depends_on: + rabbitmq: + condition: service_healthy + + supplier: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/supplier + ports: + - "9018:9018" + volumes: + - /app/node_modules + - ../../../microservices/supplier:/app + depends_on: + rabbitmq: + condition: service_healthy + + upload: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/upload + ports: + - "9019:9019" + volumes: + - /app/node_modules + - ../../../microservices/upload:/app + depends_on: + rabbitmq: + condition: service_healthy + + th: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/th + ports: + - "9020:9020" + volumes: + - /app/node_modules + - ../../../microservices/th:/app + depends_on: + rabbitmq: + condition: service_healthy + + kjhgf: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/kjhgf + ports: + - "9021:9021" + volumes: + - /app/node_modules + - ../../../microservices/kjhgf:/app + depends_on: + rabbitmq: + condition: service_healthy + + nginx: + depends_on: + - hd + - customer-service + - product-service + - rbac-service + - payment-service + - notification-service + - email-service + - cart-service + - cart + - user + - customer + - email + - notification + - payment + - product + - rbac + - supplier + - upload + - th + - kjhgf + restart: always + build: + context: ./nginx + dockerfile: Dockerfile.dev + ports: + - '4000:80' + healthcheck: + test: ["CMD-SHELL", "curl -f http://localhost:80/health || exit 1"] + interval: 30s + timeout: 10s + retries: 3 + start_period: 40s + rabbitmq: + image: rabbitmq:3.13-management + container_name: rabbitmq + ports: + - '5672:5672' + - '15672:15672' + healthcheck: + test: ["CMD", "rabbitmq-diagnostics", "ping"] + interval: 30s + retries: 5 + mongodb: + image: mongo + ports: + - '27017:27017' + restart: always + volumes: + - type: bind + source: ./data + target: /data/db + krakend: + image: devopsfaith/krakend:2.7 + ports: + - '9001:9001' + - '8090:8090' + volumes: + - ./krakend/:/etc/krakend/ + command: ['run','-d','-c','/etc/krakend/krakend.json'] \ No newline at end of file diff --git a/gateways/apps/tesrtuigfghjk/krakend/krakend.json b/gateways/apps/tesrtuigfghjk/krakend/krakend.json new file mode 100644 index 0000000..7038925 --- /dev/null +++ b/gateways/apps/tesrtuigfghjk/krakend/krakend.json @@ -0,0 +1,354 @@ + +{ + "$schema": "https://www.krakend.io/schema/v2.5/krakend.json", + "version": 3, + "name": "Microservices-suite API Gateway", + "port": 9001, + "cache_ttl": "3600s", + "timeout": "300s", + "endpoints": [ + { + "@comment": "Check the health of all your APIs", + "endpoint": "/__suite_status", + "method": "GET", + "backend": [ + { + "host": ["http://hd:null"], + "url_pattern": "/", + "mapping": { + "message": "hd" + } + }, + + { + "host": ["http://customer-service:9000"], + "url_pattern": "/", + "mapping": { + "message": "customer-service" + } + }, + + { + "host": ["http://product-service:9002"], + "url_pattern": "/", + "mapping": { + "message": "product-service" + } + }, + + { + "host": ["http://rbac-service:9004"], + "url_pattern": "/", + "mapping": { + "message": "rbac-service" + } + }, + + { + "host": ["http://payment-service:9006"], + "url_pattern": "/", + "mapping": { + "message": "payment-service" + } + }, + + { + "host": ["http://notification-service:9007"], + "url_pattern": "/", + "mapping": { + "message": "notification-service" + } + }, + + { + "host": ["http://email-service:9008"], + "url_pattern": "/", + "mapping": { + "message": "email-service" + } + }, + + { + "host": ["http://cart-service:9009"], + "url_pattern": "/", + "mapping": { + "message": "cart-service" + } + }, + + { + "host": ["http://cart:9010"], + "url_pattern": "/", + "mapping": { + "message": "cart" + } + }, + + { + "host": ["http://user:9011"], + "url_pattern": "/", + "mapping": { + "message": "user" + } + }, + + { + "host": ["http://customer:9012"], + "url_pattern": "/", + "mapping": { + "message": "customer" + } + }, + + { + "host": ["http://email:9013"], + "url_pattern": "/", + "mapping": { + "message": "email" + } + }, + + { + "host": ["http://notification:9014"], + "url_pattern": "/", + "mapping": { + "message": "notification" + } + }, + + { + "host": ["http://payment:9015"], + "url_pattern": "/", + "mapping": { + "message": "payment" + } + }, + + { + "host": ["http://product:9016"], + "url_pattern": "/", + "mapping": { + "message": "product" + } + }, + + { + "host": ["http://rbac:9017"], + "url_pattern": "/", + "mapping": { + "message": "rbac" + } + }, + + { + "host": ["http://supplier:9018"], + "url_pattern": "/", + "mapping": { + "message": "supplier" + } + }, + + { + "host": ["http://upload:9019"], + "url_pattern": "/", + "mapping": { + "message": "upload" + } + }, + + { + "host": ["http://th:9020"], + "url_pattern": "/", + "mapping": { + "message": "th" + } + }, + + { + "host": ["http://kjhgf:9021"], + "url_pattern": "/", + "mapping": { + "message": "kjhgf" + } + }] + }, + { + "@comment": "Hit all API list endpoints simultaneously", + "endpoint": "/api/v1/", + "method": "GET", + "backend": [ + { + "host": ["http://hd:null"], + "url_pattern": "/api/v1/hds", + "mapping": { + "data": "hds" + } + }, + + { + "host": ["http://customer-service:9000"], + "url_pattern": "/api/v1/customer-services", + "mapping": { + "data": "customer-services" + } + }, + + { + "host": ["http://product-service:9002"], + "url_pattern": "/api/v1/product-services", + "mapping": { + "data": "product-services" + } + }, + + { + "host": ["http://rbac-service:9004"], + "url_pattern": "/api/v1/rbac-services", + "mapping": { + "data": "rbac-services" + } + }, + + { + "host": ["http://payment-service:9006"], + "url_pattern": "/api/v1/payment-services", + "mapping": { + "data": "payment-services" + } + }, + + { + "host": ["http://notification-service:9007"], + "url_pattern": "/api/v1/notification-services", + "mapping": { + "data": "notification-services" + } + }, + + { + "host": ["http://email-service:9008"], + "url_pattern": "/api/v1/email-services", + "mapping": { + "data": "email-services" + } + }, + + { + "host": ["http://cart-service:9009"], + "url_pattern": "/api/v1/cart-services", + "mapping": { + "data": "cart-services" + } + }, + + { + "host": ["http://cart:9010"], + "url_pattern": "/api/v1/carts", + "mapping": { + "data": "carts" + } + }, + + { + "host": ["http://user:9011"], + "url_pattern": "/api/v1/users", + "mapping": { + "data": "users" + } + }, + + { + "host": ["http://customer:9012"], + "url_pattern": "/api/v1/customers", + "mapping": { + "data": "customers" + } + }, + + { + "host": ["http://email:9013"], + "url_pattern": "/api/v1/emails", + "mapping": { + "data": "emails" + } + }, + + { + "host": ["http://notification:9014"], + "url_pattern": "/api/v1/notifications", + "mapping": { + "data": "notifications" + } + }, + + { + "host": ["http://payment:9015"], + "url_pattern": "/api/v1/payments", + "mapping": { + "data": "payments" + } + }, + + { + "host": ["http://product:9016"], + "url_pattern": "/api/v1/products", + "mapping": { + "data": "products" + } + }, + + { + "host": ["http://rbac:9017"], + "url_pattern": "/api/v1/rbacs", + "mapping": { + "data": "rbacs" + } + }, + + { + "host": ["http://supplier:9018"], + "url_pattern": "/api/v1/suppliers", + "mapping": { + "data": "suppliers" + } + }, + + { + "host": ["http://upload:9019"], + "url_pattern": "/api/v1/uploads", + "mapping": { + "data": "uploads" + } + }, + + { + "host": ["http://th:9020"], + "url_pattern": "/api/v1/ths", + "mapping": { + "data": "ths" + } + }, + + { + "host": ["http://kjhgf:9021"], + "url_pattern": "/api/v1/kjhgfs", + "mapping": { + "data": "kjhgfs" + } + }] + }, + { + "@comment": "Fetch all data from the hd service", + "endpoint": "/api/v1/hds", + "method": "GET", + "backend": [ + { + "host": ["http://hd:null"], + "url_pattern": "/api/v1/hds", + "mapping": { + "data": "hds" + } + }] + } + ] +} \ No newline at end of file diff --git a/gateways/apps/tesrtuigfghjk/nginx/Dockerfile b/gateways/apps/tesrtuigfghjk/nginx/Dockerfile new file mode 100644 index 0000000..ddf7281 --- /dev/null +++ b/gateways/apps/tesrtuigfghjk/nginx/Dockerfile @@ -0,0 +1,3 @@ + +FROM nginx +COPY ./default.conf /etc/nginx/conf.d/default.conf \ No newline at end of file diff --git a/gateways/apps/tesrtuigfghjk/nginx/Dockerfile.dev b/gateways/apps/tesrtuigfghjk/nginx/Dockerfile.dev new file mode 100644 index 0000000..ddf7281 --- /dev/null +++ b/gateways/apps/tesrtuigfghjk/nginx/Dockerfile.dev @@ -0,0 +1,3 @@ + +FROM nginx +COPY ./default.conf /etc/nginx/conf.d/default.conf \ No newline at end of file diff --git a/gateways/apps/tesrtuigfghjk/nginx/default.conf b/gateways/apps/tesrtuigfghjk/nginx/default.conf new file mode 100644 index 0000000..79f0686 --- /dev/null +++ b/gateways/apps/tesrtuigfghjk/nginx/default.conf @@ -0,0 +1,246 @@ + + +upstream hd_upstream { + server hd:null; +} + +upstream customer-service_upstream { + server customer-service:9000; +} + +upstream product-service_upstream { + server product-service:9002; +} + +upstream rbac-service_upstream { + server rbac-service:9004; +} + +upstream payment-service_upstream { + server payment-service:9006; +} + +upstream notification-service_upstream { + server notification-service:9007; +} + +upstream email-service_upstream { + server email-service:9008; +} + +upstream cart-service_upstream { + server cart-service:9009; +} + +upstream cart_upstream { + server cart:9010; +} + +upstream user_upstream { + server user:9011; +} + +upstream customer_upstream { + server customer:9012; +} + +upstream email_upstream { + server email:9013; +} + +upstream notification_upstream { + server notification:9014; +} + +upstream payment_upstream { + server payment:9015; +} + +upstream product_upstream { + server product:9016; +} + +upstream rbac_upstream { + server rbac:9017; +} + +upstream supplier_upstream { + server supplier:9018; +} + +upstream upload_upstream { + server upload:9019; +} + +upstream th_upstream { + server th:9020; +} + +upstream kjhgf_upstream { + server kjhgf:9021; +} + +server { + listen 80; + + + location /api/v1/hds { + proxy_pass http://hd_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/customer-services { + proxy_pass http://customer-service_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/product-services { + proxy_pass http://product-service_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/rbac-services { + proxy_pass http://rbac-service_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/payment-services { + proxy_pass http://payment-service_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/notification-services { + proxy_pass http://notification-service_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/email-services { + proxy_pass http://email-service_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/cart-services { + proxy_pass http://cart-service_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/carts { + proxy_pass http://cart_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/users { + proxy_pass http://user_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/customers { + proxy_pass http://customer_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/emails { + proxy_pass http://email_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/notifications { + proxy_pass http://notification_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/payments { + proxy_pass http://payment_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/products { + proxy_pass http://product_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/rbacs { + proxy_pass http://rbac_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/suppliers { + proxy_pass http://supplier_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/uploads { + proxy_pass http://upload_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/ths { + proxy_pass http://th_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/kjhgfs { + proxy_pass http://kjhgf_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } +} \ No newline at end of file diff --git a/gateways/apps/test1/docker-compose.dev.yml b/gateways/apps/test1/docker-compose.dev.yml new file mode 100644 index 0000000..f5f52d5 --- /dev/null +++ b/gateways/apps/test1/docker-compose.dev.yml @@ -0,0 +1,353 @@ + +version: '3.8' +services: + + hd: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/hd + ports: + - "null:null" + volumes: + - /app/node_modules + - ../../../microservices/hd:/app + depends_on: + rabbitmq: + condition: service_healthy + + customer-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/customer-service + ports: + - "9000:9000" + volumes: + - /app/node_modules + - ../../../microservices/customer-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + product-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/product-service + ports: + - "9002:9002" + volumes: + - /app/node_modules + - ../../../microservices/product-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + rbac-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/rbac-service + ports: + - "9004:9004" + volumes: + - /app/node_modules + - ../../../microservices/rbac-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + payment-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/payment-service + ports: + - "9006:9006" + volumes: + - /app/node_modules + - ../../../microservices/payment-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + notification-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/notification-service + ports: + - "9007:9007" + volumes: + - /app/node_modules + - ../../../microservices/notification-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + email-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/email-service + ports: + - "9008:9008" + volumes: + - /app/node_modules + - ../../../microservices/email-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + cart-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/cart-service + ports: + - "9009:9009" + volumes: + - /app/node_modules + - ../../../microservices/cart-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + cart: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/cart + ports: + - "9010:9010" + volumes: + - /app/node_modules + - ../../../microservices/cart:/app + depends_on: + rabbitmq: + condition: service_healthy + + user: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/user + ports: + - "9011:9011" + volumes: + - /app/node_modules + - ../../../microservices/user:/app + depends_on: + rabbitmq: + condition: service_healthy + + customer: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/customer + ports: + - "9012:9012" + volumes: + - /app/node_modules + - ../../../microservices/customer:/app + depends_on: + rabbitmq: + condition: service_healthy + + email: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/email + ports: + - "9013:9013" + volumes: + - /app/node_modules + - ../../../microservices/email:/app + depends_on: + rabbitmq: + condition: service_healthy + + notification: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/notification + ports: + - "9014:9014" + volumes: + - /app/node_modules + - ../../../microservices/notification:/app + depends_on: + rabbitmq: + condition: service_healthy + + payment: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/payment + ports: + - "9015:9015" + volumes: + - /app/node_modules + - ../../../microservices/payment:/app + depends_on: + rabbitmq: + condition: service_healthy + + product: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/product + ports: + - "9016:9016" + volumes: + - /app/node_modules + - ../../../microservices/product:/app + depends_on: + rabbitmq: + condition: service_healthy + + rbac: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/rbac + ports: + - "9017:9017" + volumes: + - /app/node_modules + - ../../../microservices/rbac:/app + depends_on: + rabbitmq: + condition: service_healthy + + supplier: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/supplier + ports: + - "9018:9018" + volumes: + - /app/node_modules + - ../../../microservices/supplier:/app + depends_on: + rabbitmq: + condition: service_healthy + + upload: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/upload + ports: + - "9019:9019" + volumes: + - /app/node_modules + - ../../../microservices/upload:/app + depends_on: + rabbitmq: + condition: service_healthy + + th: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/th + ports: + - "9020:9020" + volumes: + - /app/node_modules + - ../../../microservices/th:/app + depends_on: + rabbitmq: + condition: service_healthy + + kjhgf: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/kjhgf + ports: + - "9021:9021" + volumes: + - /app/node_modules + - ../../../microservices/kjhgf:/app + depends_on: + rabbitmq: + condition: service_healthy + + hhgfdsdfghj: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/hhgfdsdfghj + ports: + - "9022:9022" + volumes: + - /app/node_modules + - ../../../microservices/hhgfdsdfghj:/app + depends_on: + rabbitmq: + condition: service_healthy + + ghjk: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/ghjk + ports: + - "9023:9023" + volumes: + - /app/node_modules + - ../../../microservices/ghjk:/app + depends_on: + rabbitmq: + condition: service_healthy + + nginx: + depends_on: + - hd + - customer-service + - product-service + - rbac-service + - payment-service + - notification-service + - email-service + - cart-service + - cart + - user + - customer + - email + - notification + - payment + - product + - rbac + - supplier + - upload + - th + - kjhgf + - hhgfdsdfghj + - ghjk + restart: always + build: + context: ./nginx + dockerfile: Dockerfile.dev + ports: + - '4000:80' + healthcheck: + test: ["CMD-SHELL", "curl -f http://localhost:80/health || exit 1"] + interval: 30s + timeout: 10s + retries: 3 + start_period: 40s + rabbitmq: + image: rabbitmq:3.13-management + container_name: rabbitmq + ports: + - '5672:5672' + - '15672:15672' + healthcheck: + test: ["CMD", "rabbitmq-diagnostics", "ping"] + interval: 30s + retries: 5 + mongodb: + image: mongo + ports: + - '27017:27017' + restart: always + volumes: + - type: bind + source: ./data + target: /data/db + krakend: + image: devopsfaith/krakend:2.7-watch + ports: + - '9004:9004' + - '8090:8090' + volumes: + - ./krakend/:/etc/krakend/ + command: ['run','-d','-c','/etc/krakend/krakend.json'] \ No newline at end of file diff --git a/gateways/apps/test1/docker-compose.yml b/gateways/apps/test1/docker-compose.yml new file mode 100644 index 0000000..bf4bad2 --- /dev/null +++ b/gateways/apps/test1/docker-compose.yml @@ -0,0 +1,353 @@ + +version: '3.8' +services: + + hd: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/hd + ports: + - "null:null" + volumes: + - /app/node_modules + - ../../../microservices/hd:/app + depends_on: + rabbitmq: + condition: service_healthy + + customer-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/customer-service + ports: + - "9000:9000" + volumes: + - /app/node_modules + - ../../../microservices/customer-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + product-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/product-service + ports: + - "9002:9002" + volumes: + - /app/node_modules + - ../../../microservices/product-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + rbac-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/rbac-service + ports: + - "9004:9004" + volumes: + - /app/node_modules + - ../../../microservices/rbac-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + payment-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/payment-service + ports: + - "9006:9006" + volumes: + - /app/node_modules + - ../../../microservices/payment-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + notification-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/notification-service + ports: + - "9007:9007" + volumes: + - /app/node_modules + - ../../../microservices/notification-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + email-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/email-service + ports: + - "9008:9008" + volumes: + - /app/node_modules + - ../../../microservices/email-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + cart-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/cart-service + ports: + - "9009:9009" + volumes: + - /app/node_modules + - ../../../microservices/cart-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + cart: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/cart + ports: + - "9010:9010" + volumes: + - /app/node_modules + - ../../../microservices/cart:/app + depends_on: + rabbitmq: + condition: service_healthy + + user: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/user + ports: + - "9011:9011" + volumes: + - /app/node_modules + - ../../../microservices/user:/app + depends_on: + rabbitmq: + condition: service_healthy + + customer: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/customer + ports: + - "9012:9012" + volumes: + - /app/node_modules + - ../../../microservices/customer:/app + depends_on: + rabbitmq: + condition: service_healthy + + email: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/email + ports: + - "9013:9013" + volumes: + - /app/node_modules + - ../../../microservices/email:/app + depends_on: + rabbitmq: + condition: service_healthy + + notification: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/notification + ports: + - "9014:9014" + volumes: + - /app/node_modules + - ../../../microservices/notification:/app + depends_on: + rabbitmq: + condition: service_healthy + + payment: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/payment + ports: + - "9015:9015" + volumes: + - /app/node_modules + - ../../../microservices/payment:/app + depends_on: + rabbitmq: + condition: service_healthy + + product: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/product + ports: + - "9016:9016" + volumes: + - /app/node_modules + - ../../../microservices/product:/app + depends_on: + rabbitmq: + condition: service_healthy + + rbac: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/rbac + ports: + - "9017:9017" + volumes: + - /app/node_modules + - ../../../microservices/rbac:/app + depends_on: + rabbitmq: + condition: service_healthy + + supplier: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/supplier + ports: + - "9018:9018" + volumes: + - /app/node_modules + - ../../../microservices/supplier:/app + depends_on: + rabbitmq: + condition: service_healthy + + upload: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/upload + ports: + - "9019:9019" + volumes: + - /app/node_modules + - ../../../microservices/upload:/app + depends_on: + rabbitmq: + condition: service_healthy + + th: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/th + ports: + - "9020:9020" + volumes: + - /app/node_modules + - ../../../microservices/th:/app + depends_on: + rabbitmq: + condition: service_healthy + + kjhgf: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/kjhgf + ports: + - "9021:9021" + volumes: + - /app/node_modules + - ../../../microservices/kjhgf:/app + depends_on: + rabbitmq: + condition: service_healthy + + hhgfdsdfghj: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/hhgfdsdfghj + ports: + - "9022:9022" + volumes: + - /app/node_modules + - ../../../microservices/hhgfdsdfghj:/app + depends_on: + rabbitmq: + condition: service_healthy + + ghjk: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/ghjk + ports: + - "9023:9023" + volumes: + - /app/node_modules + - ../../../microservices/ghjk:/app + depends_on: + rabbitmq: + condition: service_healthy + + nginx: + depends_on: + - hd + - customer-service + - product-service + - rbac-service + - payment-service + - notification-service + - email-service + - cart-service + - cart + - user + - customer + - email + - notification + - payment + - product + - rbac + - supplier + - upload + - th + - kjhgf + - hhgfdsdfghj + - ghjk + restart: always + build: + context: ./nginx + dockerfile: Dockerfile.dev + ports: + - '4000:80' + healthcheck: + test: ["CMD-SHELL", "curl -f http://localhost:80/health || exit 1"] + interval: 30s + timeout: 10s + retries: 3 + start_period: 40s + rabbitmq: + image: rabbitmq:3.13-management + container_name: rabbitmq + ports: + - '5672:5672' + - '15672:15672' + healthcheck: + test: ["CMD", "rabbitmq-diagnostics", "ping"] + interval: 30s + retries: 5 + mongodb: + image: mongo + ports: + - '27017:27017' + restart: always + volumes: + - type: bind + source: ./data + target: /data/db + krakend: + image: devopsfaith/krakend:2.7 + ports: + - '9004:9004' + - '8090:8090' + volumes: + - ./krakend/:/etc/krakend/ + command: ['run','-d','-c','/etc/krakend/krakend.json'] \ No newline at end of file diff --git a/gateways/apps/test1/krakend/krakend.json b/gateways/apps/test1/krakend/krakend.json new file mode 100644 index 0000000..c15eb82 --- /dev/null +++ b/gateways/apps/test1/krakend/krakend.json @@ -0,0 +1,386 @@ + +{ + "$schema": "https://www.krakend.io/schema/v2.5/krakend.json", + "version": 3, + "name": "Microservices-suite API Gateway", + "port": 9004, + "cache_ttl": "3600s", + "timeout": "300s", + "endpoints": [ + { + "@comment": "Check the health of all your APIs", + "endpoint": "/__suite_status", + "method": "GET", + "backend": [ + { + "host": ["http://hd:null"], + "url_pattern": "/", + "mapping": { + "message": "hd" + } + }, + + { + "host": ["http://customer-service:9000"], + "url_pattern": "/", + "mapping": { + "message": "customer-service" + } + }, + + { + "host": ["http://product-service:9002"], + "url_pattern": "/", + "mapping": { + "message": "product-service" + } + }, + + { + "host": ["http://rbac-service:9004"], + "url_pattern": "/", + "mapping": { + "message": "rbac-service" + } + }, + + { + "host": ["http://payment-service:9006"], + "url_pattern": "/", + "mapping": { + "message": "payment-service" + } + }, + + { + "host": ["http://notification-service:9007"], + "url_pattern": "/", + "mapping": { + "message": "notification-service" + } + }, + + { + "host": ["http://email-service:9008"], + "url_pattern": "/", + "mapping": { + "message": "email-service" + } + }, + + { + "host": ["http://cart-service:9009"], + "url_pattern": "/", + "mapping": { + "message": "cart-service" + } + }, + + { + "host": ["http://cart:9010"], + "url_pattern": "/", + "mapping": { + "message": "cart" + } + }, + + { + "host": ["http://user:9011"], + "url_pattern": "/", + "mapping": { + "message": "user" + } + }, + + { + "host": ["http://customer:9012"], + "url_pattern": "/", + "mapping": { + "message": "customer" + } + }, + + { + "host": ["http://email:9013"], + "url_pattern": "/", + "mapping": { + "message": "email" + } + }, + + { + "host": ["http://notification:9014"], + "url_pattern": "/", + "mapping": { + "message": "notification" + } + }, + + { + "host": ["http://payment:9015"], + "url_pattern": "/", + "mapping": { + "message": "payment" + } + }, + + { + "host": ["http://product:9016"], + "url_pattern": "/", + "mapping": { + "message": "product" + } + }, + + { + "host": ["http://rbac:9017"], + "url_pattern": "/", + "mapping": { + "message": "rbac" + } + }, + + { + "host": ["http://supplier:9018"], + "url_pattern": "/", + "mapping": { + "message": "supplier" + } + }, + + { + "host": ["http://upload:9019"], + "url_pattern": "/", + "mapping": { + "message": "upload" + } + }, + + { + "host": ["http://th:9020"], + "url_pattern": "/", + "mapping": { + "message": "th" + } + }, + + { + "host": ["http://kjhgf:9021"], + "url_pattern": "/", + "mapping": { + "message": "kjhgf" + } + }, + + { + "host": ["http://hhgfdsdfghj:9022"], + "url_pattern": "/", + "mapping": { + "message": "hhgfdsdfghj" + } + }, + + { + "host": ["http://ghjk:9023"], + "url_pattern": "/", + "mapping": { + "message": "ghjk" + } + }] + }, + { + "@comment": "Hit all API list endpoints simultaneously", + "endpoint": "/api/v1/", + "method": "GET", + "backend": [ + { + "host": ["http://hd:null"], + "url_pattern": "/api/v1/hds", + "mapping": { + "data": "hds" + } + }, + + { + "host": ["http://customer-service:9000"], + "url_pattern": "/api/v1/customer-services", + "mapping": { + "data": "customer-services" + } + }, + + { + "host": ["http://product-service:9002"], + "url_pattern": "/api/v1/product-services", + "mapping": { + "data": "product-services" + } + }, + + { + "host": ["http://rbac-service:9004"], + "url_pattern": "/api/v1/rbac-services", + "mapping": { + "data": "rbac-services" + } + }, + + { + "host": ["http://payment-service:9006"], + "url_pattern": "/api/v1/payment-services", + "mapping": { + "data": "payment-services" + } + }, + + { + "host": ["http://notification-service:9007"], + "url_pattern": "/api/v1/notification-services", + "mapping": { + "data": "notification-services" + } + }, + + { + "host": ["http://email-service:9008"], + "url_pattern": "/api/v1/email-services", + "mapping": { + "data": "email-services" + } + }, + + { + "host": ["http://cart-service:9009"], + "url_pattern": "/api/v1/cart-services", + "mapping": { + "data": "cart-services" + } + }, + + { + "host": ["http://cart:9010"], + "url_pattern": "/api/v1/carts", + "mapping": { + "data": "carts" + } + }, + + { + "host": ["http://user:9011"], + "url_pattern": "/api/v1/users", + "mapping": { + "data": "users" + } + }, + + { + "host": ["http://customer:9012"], + "url_pattern": "/api/v1/customers", + "mapping": { + "data": "customers" + } + }, + + { + "host": ["http://email:9013"], + "url_pattern": "/api/v1/emails", + "mapping": { + "data": "emails" + } + }, + + { + "host": ["http://notification:9014"], + "url_pattern": "/api/v1/notifications", + "mapping": { + "data": "notifications" + } + }, + + { + "host": ["http://payment:9015"], + "url_pattern": "/api/v1/payments", + "mapping": { + "data": "payments" + } + }, + + { + "host": ["http://product:9016"], + "url_pattern": "/api/v1/products", + "mapping": { + "data": "products" + } + }, + + { + "host": ["http://rbac:9017"], + "url_pattern": "/api/v1/rbacs", + "mapping": { + "data": "rbacs" + } + }, + + { + "host": ["http://supplier:9018"], + "url_pattern": "/api/v1/suppliers", + "mapping": { + "data": "suppliers" + } + }, + + { + "host": ["http://upload:9019"], + "url_pattern": "/api/v1/uploads", + "mapping": { + "data": "uploads" + } + }, + + { + "host": ["http://th:9020"], + "url_pattern": "/api/v1/ths", + "mapping": { + "data": "ths" + } + }, + + { + "host": ["http://kjhgf:9021"], + "url_pattern": "/api/v1/kjhgfs", + "mapping": { + "data": "kjhgfs" + } + }, + + { + "host": ["http://hhgfdsdfghj:9022"], + "url_pattern": "/api/v1/hhgfdsdfghjs", + "mapping": { + "data": "hhgfdsdfghjs" + } + }, + + { + "host": ["http://ghjk:9023"], + "url_pattern": "/api/v1/ghjks", + "mapping": { + "data": "ghjks" + } + }] + }, + { + "@comment": "Fetch all data from the hd service", + "endpoint": "/api/v1/hds", + "method": "GET", + "backend": [ + { + "host": ["http://hd:null"], + "url_pattern": "/api/v1/hds", + "mapping": { + "data": "hds" + } + }] + } + ] +} \ No newline at end of file diff --git a/gateways/apps/test1/nginx/Dockerfile b/gateways/apps/test1/nginx/Dockerfile new file mode 100644 index 0000000..ddf7281 --- /dev/null +++ b/gateways/apps/test1/nginx/Dockerfile @@ -0,0 +1,3 @@ + +FROM nginx +COPY ./default.conf /etc/nginx/conf.d/default.conf \ No newline at end of file diff --git a/gateways/apps/test1/nginx/Dockerfile.dev b/gateways/apps/test1/nginx/Dockerfile.dev new file mode 100644 index 0000000..ddf7281 --- /dev/null +++ b/gateways/apps/test1/nginx/Dockerfile.dev @@ -0,0 +1,3 @@ + +FROM nginx +COPY ./default.conf /etc/nginx/conf.d/default.conf \ No newline at end of file diff --git a/gateways/apps/test1/nginx/default.conf b/gateways/apps/test1/nginx/default.conf new file mode 100644 index 0000000..b25033b --- /dev/null +++ b/gateways/apps/test1/nginx/default.conf @@ -0,0 +1,270 @@ + + +upstream hd_upstream { + server hd:null; +} + +upstream customer-service_upstream { + server customer-service:9000; +} + +upstream product-service_upstream { + server product-service:9002; +} + +upstream rbac-service_upstream { + server rbac-service:9004; +} + +upstream payment-service_upstream { + server payment-service:9006; +} + +upstream notification-service_upstream { + server notification-service:9007; +} + +upstream email-service_upstream { + server email-service:9008; +} + +upstream cart-service_upstream { + server cart-service:9009; +} + +upstream cart_upstream { + server cart:9010; +} + +upstream user_upstream { + server user:9011; +} + +upstream customer_upstream { + server customer:9012; +} + +upstream email_upstream { + server email:9013; +} + +upstream notification_upstream { + server notification:9014; +} + +upstream payment_upstream { + server payment:9015; +} + +upstream product_upstream { + server product:9016; +} + +upstream rbac_upstream { + server rbac:9017; +} + +upstream supplier_upstream { + server supplier:9018; +} + +upstream upload_upstream { + server upload:9019; +} + +upstream th_upstream { + server th:9020; +} + +upstream kjhgf_upstream { + server kjhgf:9021; +} + +upstream hhgfdsdfghj_upstream { + server hhgfdsdfghj:9022; +} + +upstream ghjk_upstream { + server ghjk:9023; +} + +server { + listen 80; + + + location /api/v1/hds { + proxy_pass http://hd_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/customer-services { + proxy_pass http://customer-service_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/product-services { + proxy_pass http://product-service_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/rbac-services { + proxy_pass http://rbac-service_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/payment-services { + proxy_pass http://payment-service_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/notification-services { + proxy_pass http://notification-service_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/email-services { + proxy_pass http://email-service_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/cart-services { + proxy_pass http://cart-service_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/carts { + proxy_pass http://cart_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/users { + proxy_pass http://user_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/customers { + proxy_pass http://customer_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/emails { + proxy_pass http://email_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/notifications { + proxy_pass http://notification_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/payments { + proxy_pass http://payment_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/products { + proxy_pass http://product_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/rbacs { + proxy_pass http://rbac_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/suppliers { + proxy_pass http://supplier_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/uploads { + proxy_pass http://upload_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/ths { + proxy_pass http://th_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/kjhgfs { + proxy_pass http://kjhgf_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/hhgfdsdfghjs { + proxy_pass http://hhgfdsdfghj_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/ghjks { + proxy_pass http://ghjk_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } +} \ No newline at end of file diff --git a/gateways/apps/test2/docker-compose.dev.yml b/gateways/apps/test2/docker-compose.dev.yml new file mode 100644 index 0000000..a803a46 --- /dev/null +++ b/gateways/apps/test2/docker-compose.dev.yml @@ -0,0 +1,353 @@ + +version: '3.8' +services: + + hd: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/hd + ports: + - "null:null" + volumes: + - /app/node_modules + - ../../../microservices/hd:/app + depends_on: + rabbitmq: + condition: service_healthy + + customer-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/customer-service + ports: + - "9000:9000" + volumes: + - /app/node_modules + - ../../../microservices/customer-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + product-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/product-service + ports: + - "9002:9002" + volumes: + - /app/node_modules + - ../../../microservices/product-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + rbac-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/rbac-service + ports: + - "9004:9004" + volumes: + - /app/node_modules + - ../../../microservices/rbac-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + payment-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/payment-service + ports: + - "9006:9006" + volumes: + - /app/node_modules + - ../../../microservices/payment-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + notification-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/notification-service + ports: + - "9007:9007" + volumes: + - /app/node_modules + - ../../../microservices/notification-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + email-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/email-service + ports: + - "9008:9008" + volumes: + - /app/node_modules + - ../../../microservices/email-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + cart-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/cart-service + ports: + - "9009:9009" + volumes: + - /app/node_modules + - ../../../microservices/cart-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + cart: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/cart + ports: + - "9010:9010" + volumes: + - /app/node_modules + - ../../../microservices/cart:/app + depends_on: + rabbitmq: + condition: service_healthy + + user: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/user + ports: + - "9011:9011" + volumes: + - /app/node_modules + - ../../../microservices/user:/app + depends_on: + rabbitmq: + condition: service_healthy + + customer: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/customer + ports: + - "9012:9012" + volumes: + - /app/node_modules + - ../../../microservices/customer:/app + depends_on: + rabbitmq: + condition: service_healthy + + email: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/email + ports: + - "9013:9013" + volumes: + - /app/node_modules + - ../../../microservices/email:/app + depends_on: + rabbitmq: + condition: service_healthy + + notification: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/notification + ports: + - "9014:9014" + volumes: + - /app/node_modules + - ../../../microservices/notification:/app + depends_on: + rabbitmq: + condition: service_healthy + + payment: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/payment + ports: + - "9015:9015" + volumes: + - /app/node_modules + - ../../../microservices/payment:/app + depends_on: + rabbitmq: + condition: service_healthy + + product: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/product + ports: + - "9016:9016" + volumes: + - /app/node_modules + - ../../../microservices/product:/app + depends_on: + rabbitmq: + condition: service_healthy + + rbac: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/rbac + ports: + - "9017:9017" + volumes: + - /app/node_modules + - ../../../microservices/rbac:/app + depends_on: + rabbitmq: + condition: service_healthy + + supplier: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/supplier + ports: + - "9018:9018" + volumes: + - /app/node_modules + - ../../../microservices/supplier:/app + depends_on: + rabbitmq: + condition: service_healthy + + upload: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/upload + ports: + - "9019:9019" + volumes: + - /app/node_modules + - ../../../microservices/upload:/app + depends_on: + rabbitmq: + condition: service_healthy + + th: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/th + ports: + - "9020:9020" + volumes: + - /app/node_modules + - ../../../microservices/th:/app + depends_on: + rabbitmq: + condition: service_healthy + + kjhgf: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/kjhgf + ports: + - "9021:9021" + volumes: + - /app/node_modules + - ../../../microservices/kjhgf:/app + depends_on: + rabbitmq: + condition: service_healthy + + hhgfdsdfghj: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/hhgfdsdfghj + ports: + - "9022:9022" + volumes: + - /app/node_modules + - ../../../microservices/hhgfdsdfghj:/app + depends_on: + rabbitmq: + condition: service_healthy + + ghjk: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/ghjk + ports: + - "9023:9023" + volumes: + - /app/node_modules + - ../../../microservices/ghjk:/app + depends_on: + rabbitmq: + condition: service_healthy + + nginx: + depends_on: + - hd + - customer-service + - product-service + - rbac-service + - payment-service + - notification-service + - email-service + - cart-service + - cart + - user + - customer + - email + - notification + - payment + - product + - rbac + - supplier + - upload + - th + - kjhgf + - hhgfdsdfghj + - ghjk + restart: always + build: + context: ./nginx + dockerfile: Dockerfile.dev + ports: + - '4000:80' + healthcheck: + test: ["CMD-SHELL", "curl -f http://localhost:80/health || exit 1"] + interval: 30s + timeout: 10s + retries: 3 + start_period: 40s + rabbitmq: + image: rabbitmq:3.13-management + container_name: rabbitmq + ports: + - '5672:5672' + - '15672:15672' + healthcheck: + test: ["CMD", "rabbitmq-diagnostics", "ping"] + interval: 30s + retries: 5 + mongodb: + image: mongo + ports: + - '27017:27017' + restart: always + volumes: + - type: bind + source: ./data + target: /data/db + krakend: + image: devopsfaith/krakend:2.7-watch + ports: + - '9005:9005' + - '8090:8090' + volumes: + - ./krakend/:/etc/krakend/ + command: ['run','-d','-c','/etc/krakend/krakend.json'] \ No newline at end of file diff --git a/gateways/apps/test2/docker-compose.yml b/gateways/apps/test2/docker-compose.yml new file mode 100644 index 0000000..63730e5 --- /dev/null +++ b/gateways/apps/test2/docker-compose.yml @@ -0,0 +1,353 @@ + +version: '3.8' +services: + + hd: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/hd + ports: + - "null:null" + volumes: + - /app/node_modules + - ../../../microservices/hd:/app + depends_on: + rabbitmq: + condition: service_healthy + + customer-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/customer-service + ports: + - "9000:9000" + volumes: + - /app/node_modules + - ../../../microservices/customer-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + product-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/product-service + ports: + - "9002:9002" + volumes: + - /app/node_modules + - ../../../microservices/product-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + rbac-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/rbac-service + ports: + - "9004:9004" + volumes: + - /app/node_modules + - ../../../microservices/rbac-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + payment-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/payment-service + ports: + - "9006:9006" + volumes: + - /app/node_modules + - ../../../microservices/payment-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + notification-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/notification-service + ports: + - "9007:9007" + volumes: + - /app/node_modules + - ../../../microservices/notification-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + email-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/email-service + ports: + - "9008:9008" + volumes: + - /app/node_modules + - ../../../microservices/email-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + cart-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/cart-service + ports: + - "9009:9009" + volumes: + - /app/node_modules + - ../../../microservices/cart-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + cart: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/cart + ports: + - "9010:9010" + volumes: + - /app/node_modules + - ../../../microservices/cart:/app + depends_on: + rabbitmq: + condition: service_healthy + + user: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/user + ports: + - "9011:9011" + volumes: + - /app/node_modules + - ../../../microservices/user:/app + depends_on: + rabbitmq: + condition: service_healthy + + customer: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/customer + ports: + - "9012:9012" + volumes: + - /app/node_modules + - ../../../microservices/customer:/app + depends_on: + rabbitmq: + condition: service_healthy + + email: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/email + ports: + - "9013:9013" + volumes: + - /app/node_modules + - ../../../microservices/email:/app + depends_on: + rabbitmq: + condition: service_healthy + + notification: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/notification + ports: + - "9014:9014" + volumes: + - /app/node_modules + - ../../../microservices/notification:/app + depends_on: + rabbitmq: + condition: service_healthy + + payment: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/payment + ports: + - "9015:9015" + volumes: + - /app/node_modules + - ../../../microservices/payment:/app + depends_on: + rabbitmq: + condition: service_healthy + + product: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/product + ports: + - "9016:9016" + volumes: + - /app/node_modules + - ../../../microservices/product:/app + depends_on: + rabbitmq: + condition: service_healthy + + rbac: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/rbac + ports: + - "9017:9017" + volumes: + - /app/node_modules + - ../../../microservices/rbac:/app + depends_on: + rabbitmq: + condition: service_healthy + + supplier: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/supplier + ports: + - "9018:9018" + volumes: + - /app/node_modules + - ../../../microservices/supplier:/app + depends_on: + rabbitmq: + condition: service_healthy + + upload: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/upload + ports: + - "9019:9019" + volumes: + - /app/node_modules + - ../../../microservices/upload:/app + depends_on: + rabbitmq: + condition: service_healthy + + th: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/th + ports: + - "9020:9020" + volumes: + - /app/node_modules + - ../../../microservices/th:/app + depends_on: + rabbitmq: + condition: service_healthy + + kjhgf: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/kjhgf + ports: + - "9021:9021" + volumes: + - /app/node_modules + - ../../../microservices/kjhgf:/app + depends_on: + rabbitmq: + condition: service_healthy + + hhgfdsdfghj: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/hhgfdsdfghj + ports: + - "9022:9022" + volumes: + - /app/node_modules + - ../../../microservices/hhgfdsdfghj:/app + depends_on: + rabbitmq: + condition: service_healthy + + ghjk: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/ghjk + ports: + - "9023:9023" + volumes: + - /app/node_modules + - ../../../microservices/ghjk:/app + depends_on: + rabbitmq: + condition: service_healthy + + nginx: + depends_on: + - hd + - customer-service + - product-service + - rbac-service + - payment-service + - notification-service + - email-service + - cart-service + - cart + - user + - customer + - email + - notification + - payment + - product + - rbac + - supplier + - upload + - th + - kjhgf + - hhgfdsdfghj + - ghjk + restart: always + build: + context: ./nginx + dockerfile: Dockerfile.dev + ports: + - '4000:80' + healthcheck: + test: ["CMD-SHELL", "curl -f http://localhost:80/health || exit 1"] + interval: 30s + timeout: 10s + retries: 3 + start_period: 40s + rabbitmq: + image: rabbitmq:3.13-management + container_name: rabbitmq + ports: + - '5672:5672' + - '15672:15672' + healthcheck: + test: ["CMD", "rabbitmq-diagnostics", "ping"] + interval: 30s + retries: 5 + mongodb: + image: mongo + ports: + - '27017:27017' + restart: always + volumes: + - type: bind + source: ./data + target: /data/db + krakend: + image: devopsfaith/krakend:2.7 + ports: + - '9005:9005' + - '8090:8090' + volumes: + - ./krakend/:/etc/krakend/ + command: ['run','-d','-c','/etc/krakend/krakend.json'] \ No newline at end of file diff --git a/gateways/apps/test2/krakend/krakend.json b/gateways/apps/test2/krakend/krakend.json new file mode 100644 index 0000000..e991121 --- /dev/null +++ b/gateways/apps/test2/krakend/krakend.json @@ -0,0 +1,386 @@ + +{ + "$schema": "https://www.krakend.io/schema/v2.5/krakend.json", + "version": 3, + "name": "Microservices-suite API Gateway", + "port": 9005, + "cache_ttl": "3600s", + "timeout": "300s", + "endpoints": [ + { + "@comment": "Check the health of all your APIs", + "endpoint": "/__suite_status", + "method": "GET", + "backend": [ + { + "host": ["http://hd:null"], + "url_pattern": "/", + "mapping": { + "message": "hd" + } + }, + + { + "host": ["http://customer-service:9000"], + "url_pattern": "/", + "mapping": { + "message": "customer-service" + } + }, + + { + "host": ["http://product-service:9002"], + "url_pattern": "/", + "mapping": { + "message": "product-service" + } + }, + + { + "host": ["http://rbac-service:9004"], + "url_pattern": "/", + "mapping": { + "message": "rbac-service" + } + }, + + { + "host": ["http://payment-service:9006"], + "url_pattern": "/", + "mapping": { + "message": "payment-service" + } + }, + + { + "host": ["http://notification-service:9007"], + "url_pattern": "/", + "mapping": { + "message": "notification-service" + } + }, + + { + "host": ["http://email-service:9008"], + "url_pattern": "/", + "mapping": { + "message": "email-service" + } + }, + + { + "host": ["http://cart-service:9009"], + "url_pattern": "/", + "mapping": { + "message": "cart-service" + } + }, + + { + "host": ["http://cart:9010"], + "url_pattern": "/", + "mapping": { + "message": "cart" + } + }, + + { + "host": ["http://user:9011"], + "url_pattern": "/", + "mapping": { + "message": "user" + } + }, + + { + "host": ["http://customer:9012"], + "url_pattern": "/", + "mapping": { + "message": "customer" + } + }, + + { + "host": ["http://email:9013"], + "url_pattern": "/", + "mapping": { + "message": "email" + } + }, + + { + "host": ["http://notification:9014"], + "url_pattern": "/", + "mapping": { + "message": "notification" + } + }, + + { + "host": ["http://payment:9015"], + "url_pattern": "/", + "mapping": { + "message": "payment" + } + }, + + { + "host": ["http://product:9016"], + "url_pattern": "/", + "mapping": { + "message": "product" + } + }, + + { + "host": ["http://rbac:9017"], + "url_pattern": "/", + "mapping": { + "message": "rbac" + } + }, + + { + "host": ["http://supplier:9018"], + "url_pattern": "/", + "mapping": { + "message": "supplier" + } + }, + + { + "host": ["http://upload:9019"], + "url_pattern": "/", + "mapping": { + "message": "upload" + } + }, + + { + "host": ["http://th:9020"], + "url_pattern": "/", + "mapping": { + "message": "th" + } + }, + + { + "host": ["http://kjhgf:9021"], + "url_pattern": "/", + "mapping": { + "message": "kjhgf" + } + }, + + { + "host": ["http://hhgfdsdfghj:9022"], + "url_pattern": "/", + "mapping": { + "message": "hhgfdsdfghj" + } + }, + + { + "host": ["http://ghjk:9023"], + "url_pattern": "/", + "mapping": { + "message": "ghjk" + } + }] + }, + { + "@comment": "Hit all API list endpoints simultaneously", + "endpoint": "/api/v1/", + "method": "GET", + "backend": [ + { + "host": ["http://hd:null"], + "url_pattern": "/api/v1/hds", + "mapping": { + "data": "hds" + } + }, + + { + "host": ["http://customer-service:9000"], + "url_pattern": "/api/v1/customer-services", + "mapping": { + "data": "customer-services" + } + }, + + { + "host": ["http://product-service:9002"], + "url_pattern": "/api/v1/product-services", + "mapping": { + "data": "product-services" + } + }, + + { + "host": ["http://rbac-service:9004"], + "url_pattern": "/api/v1/rbac-services", + "mapping": { + "data": "rbac-services" + } + }, + + { + "host": ["http://payment-service:9006"], + "url_pattern": "/api/v1/payment-services", + "mapping": { + "data": "payment-services" + } + }, + + { + "host": ["http://notification-service:9007"], + "url_pattern": "/api/v1/notification-services", + "mapping": { + "data": "notification-services" + } + }, + + { + "host": ["http://email-service:9008"], + "url_pattern": "/api/v1/email-services", + "mapping": { + "data": "email-services" + } + }, + + { + "host": ["http://cart-service:9009"], + "url_pattern": "/api/v1/cart-services", + "mapping": { + "data": "cart-services" + } + }, + + { + "host": ["http://cart:9010"], + "url_pattern": "/api/v1/carts", + "mapping": { + "data": "carts" + } + }, + + { + "host": ["http://user:9011"], + "url_pattern": "/api/v1/users", + "mapping": { + "data": "users" + } + }, + + { + "host": ["http://customer:9012"], + "url_pattern": "/api/v1/customers", + "mapping": { + "data": "customers" + } + }, + + { + "host": ["http://email:9013"], + "url_pattern": "/api/v1/emails", + "mapping": { + "data": "emails" + } + }, + + { + "host": ["http://notification:9014"], + "url_pattern": "/api/v1/notifications", + "mapping": { + "data": "notifications" + } + }, + + { + "host": ["http://payment:9015"], + "url_pattern": "/api/v1/payments", + "mapping": { + "data": "payments" + } + }, + + { + "host": ["http://product:9016"], + "url_pattern": "/api/v1/products", + "mapping": { + "data": "products" + } + }, + + { + "host": ["http://rbac:9017"], + "url_pattern": "/api/v1/rbacs", + "mapping": { + "data": "rbacs" + } + }, + + { + "host": ["http://supplier:9018"], + "url_pattern": "/api/v1/suppliers", + "mapping": { + "data": "suppliers" + } + }, + + { + "host": ["http://upload:9019"], + "url_pattern": "/api/v1/uploads", + "mapping": { + "data": "uploads" + } + }, + + { + "host": ["http://th:9020"], + "url_pattern": "/api/v1/ths", + "mapping": { + "data": "ths" + } + }, + + { + "host": ["http://kjhgf:9021"], + "url_pattern": "/api/v1/kjhgfs", + "mapping": { + "data": "kjhgfs" + } + }, + + { + "host": ["http://hhgfdsdfghj:9022"], + "url_pattern": "/api/v1/hhgfdsdfghjs", + "mapping": { + "data": "hhgfdsdfghjs" + } + }, + + { + "host": ["http://ghjk:9023"], + "url_pattern": "/api/v1/ghjks", + "mapping": { + "data": "ghjks" + } + }] + }, + { + "@comment": "Fetch all data from the hd service", + "endpoint": "/api/v1/hds", + "method": "GET", + "backend": [ + { + "host": ["http://hd:null"], + "url_pattern": "/api/v1/hds", + "mapping": { + "data": "hds" + } + }] + } + ] +} \ No newline at end of file diff --git a/gateways/apps/test2/nginx/Dockerfile b/gateways/apps/test2/nginx/Dockerfile new file mode 100644 index 0000000..ddf7281 --- /dev/null +++ b/gateways/apps/test2/nginx/Dockerfile @@ -0,0 +1,3 @@ + +FROM nginx +COPY ./default.conf /etc/nginx/conf.d/default.conf \ No newline at end of file diff --git a/gateways/apps/test2/nginx/Dockerfile.dev b/gateways/apps/test2/nginx/Dockerfile.dev new file mode 100644 index 0000000..ddf7281 --- /dev/null +++ b/gateways/apps/test2/nginx/Dockerfile.dev @@ -0,0 +1,3 @@ + +FROM nginx +COPY ./default.conf /etc/nginx/conf.d/default.conf \ No newline at end of file diff --git a/gateways/apps/test2/nginx/default.conf b/gateways/apps/test2/nginx/default.conf new file mode 100644 index 0000000..b25033b --- /dev/null +++ b/gateways/apps/test2/nginx/default.conf @@ -0,0 +1,270 @@ + + +upstream hd_upstream { + server hd:null; +} + +upstream customer-service_upstream { + server customer-service:9000; +} + +upstream product-service_upstream { + server product-service:9002; +} + +upstream rbac-service_upstream { + server rbac-service:9004; +} + +upstream payment-service_upstream { + server payment-service:9006; +} + +upstream notification-service_upstream { + server notification-service:9007; +} + +upstream email-service_upstream { + server email-service:9008; +} + +upstream cart-service_upstream { + server cart-service:9009; +} + +upstream cart_upstream { + server cart:9010; +} + +upstream user_upstream { + server user:9011; +} + +upstream customer_upstream { + server customer:9012; +} + +upstream email_upstream { + server email:9013; +} + +upstream notification_upstream { + server notification:9014; +} + +upstream payment_upstream { + server payment:9015; +} + +upstream product_upstream { + server product:9016; +} + +upstream rbac_upstream { + server rbac:9017; +} + +upstream supplier_upstream { + server supplier:9018; +} + +upstream upload_upstream { + server upload:9019; +} + +upstream th_upstream { + server th:9020; +} + +upstream kjhgf_upstream { + server kjhgf:9021; +} + +upstream hhgfdsdfghj_upstream { + server hhgfdsdfghj:9022; +} + +upstream ghjk_upstream { + server ghjk:9023; +} + +server { + listen 80; + + + location /api/v1/hds { + proxy_pass http://hd_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/customer-services { + proxy_pass http://customer-service_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/product-services { + proxy_pass http://product-service_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/rbac-services { + proxy_pass http://rbac-service_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/payment-services { + proxy_pass http://payment-service_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/notification-services { + proxy_pass http://notification-service_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/email-services { + proxy_pass http://email-service_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/cart-services { + proxy_pass http://cart-service_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/carts { + proxy_pass http://cart_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/users { + proxy_pass http://user_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/customers { + proxy_pass http://customer_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/emails { + proxy_pass http://email_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/notifications { + proxy_pass http://notification_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/payments { + proxy_pass http://payment_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/products { + proxy_pass http://product_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/rbacs { + proxy_pass http://rbac_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/suppliers { + proxy_pass http://supplier_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/uploads { + proxy_pass http://upload_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/ths { + proxy_pass http://th_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/kjhgfs { + proxy_pass http://kjhgf_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/hhgfdsdfghjs { + proxy_pass http://hhgfdsdfghj_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/ghjks { + proxy_pass http://ghjk_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } +} \ No newline at end of file diff --git a/gateways/apps/test3/docker-compose.dev.yml b/gateways/apps/test3/docker-compose.dev.yml new file mode 100644 index 0000000..2e403c2 --- /dev/null +++ b/gateways/apps/test3/docker-compose.dev.yml @@ -0,0 +1,367 @@ + +version: '3.8' +services: + + hd: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/hd + ports: + - "null:null" + volumes: + - /app/node_modules + - ../../../microservices/hd:/app + depends_on: + rabbitmq: + condition: service_healthy + + customer-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/customer-service + ports: + - "9000:9000" + volumes: + - /app/node_modules + - ../../../microservices/customer-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + product-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/product-service + ports: + - "9002:9002" + volumes: + - /app/node_modules + - ../../../microservices/product-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + rbac-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/rbac-service + ports: + - "9004:9004" + volumes: + - /app/node_modules + - ../../../microservices/rbac-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + payment-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/payment-service + ports: + - "9006:9006" + volumes: + - /app/node_modules + - ../../../microservices/payment-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + notification-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/notification-service + ports: + - "9007:9007" + volumes: + - /app/node_modules + - ../../../microservices/notification-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + email-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/email-service + ports: + - "9008:9008" + volumes: + - /app/node_modules + - ../../../microservices/email-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + cart-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/cart-service + ports: + - "9009:9009" + volumes: + - /app/node_modules + - ../../../microservices/cart-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + cart: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/cart + ports: + - "9010:9010" + volumes: + - /app/node_modules + - ../../../microservices/cart:/app + depends_on: + rabbitmq: + condition: service_healthy + + user: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/user + ports: + - "9011:9011" + volumes: + - /app/node_modules + - ../../../microservices/user:/app + depends_on: + rabbitmq: + condition: service_healthy + + customer: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/customer + ports: + - "9012:9012" + volumes: + - /app/node_modules + - ../../../microservices/customer:/app + depends_on: + rabbitmq: + condition: service_healthy + + email: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/email + ports: + - "9013:9013" + volumes: + - /app/node_modules + - ../../../microservices/email:/app + depends_on: + rabbitmq: + condition: service_healthy + + notification: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/notification + ports: + - "9014:9014" + volumes: + - /app/node_modules + - ../../../microservices/notification:/app + depends_on: + rabbitmq: + condition: service_healthy + + payment: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/payment + ports: + - "9015:9015" + volumes: + - /app/node_modules + - ../../../microservices/payment:/app + depends_on: + rabbitmq: + condition: service_healthy + + product: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/product + ports: + - "9016:9016" + volumes: + - /app/node_modules + - ../../../microservices/product:/app + depends_on: + rabbitmq: + condition: service_healthy + + rbac: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/rbac + ports: + - "9017:9017" + volumes: + - /app/node_modules + - ../../../microservices/rbac:/app + depends_on: + rabbitmq: + condition: service_healthy + + supplier: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/supplier + ports: + - "9018:9018" + volumes: + - /app/node_modules + - ../../../microservices/supplier:/app + depends_on: + rabbitmq: + condition: service_healthy + + upload: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/upload + ports: + - "9019:9019" + volumes: + - /app/node_modules + - ../../../microservices/upload:/app + depends_on: + rabbitmq: + condition: service_healthy + + th: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/th + ports: + - "9020:9020" + volumes: + - /app/node_modules + - ../../../microservices/th:/app + depends_on: + rabbitmq: + condition: service_healthy + + kjhgf: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/kjhgf + ports: + - "9021:9021" + volumes: + - /app/node_modules + - ../../../microservices/kjhgf:/app + depends_on: + rabbitmq: + condition: service_healthy + + hhgfdsdfghj: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/hhgfdsdfghj + ports: + - "9022:9022" + volumes: + - /app/node_modules + - ../../../microservices/hhgfdsdfghj:/app + depends_on: + rabbitmq: + condition: service_healthy + + ghjk: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/ghjk + ports: + - "9023:9023" + volumes: + - /app/node_modules + - ../../../microservices/ghjk:/app + depends_on: + rabbitmq: + condition: service_healthy + + shjksgd: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/shjksgd + ports: + - "30067:30067" + volumes: + - /app/node_modules + - ../../../microservices/shjksgd:/app + depends_on: + rabbitmq: + condition: service_healthy + + nginx: + depends_on: + - hd + - customer-service + - product-service + - rbac-service + - payment-service + - notification-service + - email-service + - cart-service + - cart + - user + - customer + - email + - notification + - payment + - product + - rbac + - supplier + - upload + - th + - kjhgf + - hhgfdsdfghj + - ghjk + - shjksgd + restart: always + build: + context: ./nginx + dockerfile: Dockerfile.dev + ports: + - '4000:80' + healthcheck: + test: ["CMD-SHELL", "curl -f http://localhost:80/health || exit 1"] + interval: 30s + timeout: 10s + retries: 3 + start_period: 40s + rabbitmq: + image: rabbitmq:3.13-management + container_name: rabbitmq + ports: + - '5672:5672' + - '15672:15672' + healthcheck: + test: ["CMD", "rabbitmq-diagnostics", "ping"] + interval: 30s + retries: 5 + mongodb: + image: mongo + ports: + - '27017:27017' + restart: always + volumes: + - type: bind + source: ./data + target: /data/db + krakend: + image: devopsfaith/krakend:2.7-watch + ports: + - '9000:9000' + - '8090:8090' + volumes: + - ./krakend/:/etc/krakend/ + command: ['run','-d','-c','/etc/krakend/krakend.json'] \ No newline at end of file diff --git a/gateways/apps/test3/docker-compose.yml b/gateways/apps/test3/docker-compose.yml new file mode 100644 index 0000000..f33baeb --- /dev/null +++ b/gateways/apps/test3/docker-compose.yml @@ -0,0 +1,367 @@ + +version: '3.8' +services: + + hd: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/hd + ports: + - "null:null" + volumes: + - /app/node_modules + - ../../../microservices/hd:/app + depends_on: + rabbitmq: + condition: service_healthy + + customer-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/customer-service + ports: + - "9000:9000" + volumes: + - /app/node_modules + - ../../../microservices/customer-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + product-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/product-service + ports: + - "9002:9002" + volumes: + - /app/node_modules + - ../../../microservices/product-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + rbac-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/rbac-service + ports: + - "9004:9004" + volumes: + - /app/node_modules + - ../../../microservices/rbac-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + payment-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/payment-service + ports: + - "9006:9006" + volumes: + - /app/node_modules + - ../../../microservices/payment-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + notification-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/notification-service + ports: + - "9007:9007" + volumes: + - /app/node_modules + - ../../../microservices/notification-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + email-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/email-service + ports: + - "9008:9008" + volumes: + - /app/node_modules + - ../../../microservices/email-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + cart-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/cart-service + ports: + - "9009:9009" + volumes: + - /app/node_modules + - ../../../microservices/cart-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + cart: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/cart + ports: + - "9010:9010" + volumes: + - /app/node_modules + - ../../../microservices/cart:/app + depends_on: + rabbitmq: + condition: service_healthy + + user: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/user + ports: + - "9011:9011" + volumes: + - /app/node_modules + - ../../../microservices/user:/app + depends_on: + rabbitmq: + condition: service_healthy + + customer: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/customer + ports: + - "9012:9012" + volumes: + - /app/node_modules + - ../../../microservices/customer:/app + depends_on: + rabbitmq: + condition: service_healthy + + email: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/email + ports: + - "9013:9013" + volumes: + - /app/node_modules + - ../../../microservices/email:/app + depends_on: + rabbitmq: + condition: service_healthy + + notification: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/notification + ports: + - "9014:9014" + volumes: + - /app/node_modules + - ../../../microservices/notification:/app + depends_on: + rabbitmq: + condition: service_healthy + + payment: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/payment + ports: + - "9015:9015" + volumes: + - /app/node_modules + - ../../../microservices/payment:/app + depends_on: + rabbitmq: + condition: service_healthy + + product: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/product + ports: + - "9016:9016" + volumes: + - /app/node_modules + - ../../../microservices/product:/app + depends_on: + rabbitmq: + condition: service_healthy + + rbac: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/rbac + ports: + - "9017:9017" + volumes: + - /app/node_modules + - ../../../microservices/rbac:/app + depends_on: + rabbitmq: + condition: service_healthy + + supplier: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/supplier + ports: + - "9018:9018" + volumes: + - /app/node_modules + - ../../../microservices/supplier:/app + depends_on: + rabbitmq: + condition: service_healthy + + upload: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/upload + ports: + - "9019:9019" + volumes: + - /app/node_modules + - ../../../microservices/upload:/app + depends_on: + rabbitmq: + condition: service_healthy + + th: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/th + ports: + - "9020:9020" + volumes: + - /app/node_modules + - ../../../microservices/th:/app + depends_on: + rabbitmq: + condition: service_healthy + + kjhgf: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/kjhgf + ports: + - "9021:9021" + volumes: + - /app/node_modules + - ../../../microservices/kjhgf:/app + depends_on: + rabbitmq: + condition: service_healthy + + hhgfdsdfghj: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/hhgfdsdfghj + ports: + - "9022:9022" + volumes: + - /app/node_modules + - ../../../microservices/hhgfdsdfghj:/app + depends_on: + rabbitmq: + condition: service_healthy + + ghjk: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/ghjk + ports: + - "9023:9023" + volumes: + - /app/node_modules + - ../../../microservices/ghjk:/app + depends_on: + rabbitmq: + condition: service_healthy + + shjksgd: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/shjksgd + ports: + - "30067:30067" + volumes: + - /app/node_modules + - ../../../microservices/shjksgd:/app + depends_on: + rabbitmq: + condition: service_healthy + + nginx: + depends_on: + - hd + - customer-service + - product-service + - rbac-service + - payment-service + - notification-service + - email-service + - cart-service + - cart + - user + - customer + - email + - notification + - payment + - product + - rbac + - supplier + - upload + - th + - kjhgf + - hhgfdsdfghj + - ghjk + - shjksgd + restart: always + build: + context: ./nginx + dockerfile: Dockerfile.dev + ports: + - '4000:80' + healthcheck: + test: ["CMD-SHELL", "curl -f http://localhost:80/health || exit 1"] + interval: 30s + timeout: 10s + retries: 3 + start_period: 40s + rabbitmq: + image: rabbitmq:3.13-management + container_name: rabbitmq + ports: + - '5672:5672' + - '15672:15672' + healthcheck: + test: ["CMD", "rabbitmq-diagnostics", "ping"] + interval: 30s + retries: 5 + mongodb: + image: mongo + ports: + - '27017:27017' + restart: always + volumes: + - type: bind + source: ./data + target: /data/db + krakend: + image: devopsfaith/krakend:2.7 + ports: + - '9000:9000' + - '8090:8090' + volumes: + - ./krakend/:/etc/krakend/ + command: ['run','-d','-c','/etc/krakend/krakend.json'] \ No newline at end of file diff --git a/gateways/apps/test3/krakend/krakend.json b/gateways/apps/test3/krakend/krakend.json new file mode 100644 index 0000000..5e3320a --- /dev/null +++ b/gateways/apps/test3/krakend/krakend.json @@ -0,0 +1,402 @@ + +{ + "$schema": "https://www.krakend.io/schema/v2.5/krakend.json", + "version": 3, + "name": "Microservices-suite API Gateway", + "port": 9000, + "cache_ttl": "3600s", + "timeout": "300s", + "endpoints": [ + { + "@comment": "Check the health of all your APIs", + "endpoint": "/__suite_status", + "method": "GET", + "backend": [ + { + "host": ["http://hd:null"], + "url_pattern": "/", + "mapping": { + "message": "hd" + } + }, + + { + "host": ["http://customer-service:9000"], + "url_pattern": "/", + "mapping": { + "message": "customer-service" + } + }, + + { + "host": ["http://product-service:9002"], + "url_pattern": "/", + "mapping": { + "message": "product-service" + } + }, + + { + "host": ["http://rbac-service:9004"], + "url_pattern": "/", + "mapping": { + "message": "rbac-service" + } + }, + + { + "host": ["http://payment-service:9006"], + "url_pattern": "/", + "mapping": { + "message": "payment-service" + } + }, + + { + "host": ["http://notification-service:9007"], + "url_pattern": "/", + "mapping": { + "message": "notification-service" + } + }, + + { + "host": ["http://email-service:9008"], + "url_pattern": "/", + "mapping": { + "message": "email-service" + } + }, + + { + "host": ["http://cart-service:9009"], + "url_pattern": "/", + "mapping": { + "message": "cart-service" + } + }, + + { + "host": ["http://cart:9010"], + "url_pattern": "/", + "mapping": { + "message": "cart" + } + }, + + { + "host": ["http://user:9011"], + "url_pattern": "/", + "mapping": { + "message": "user" + } + }, + + { + "host": ["http://customer:9012"], + "url_pattern": "/", + "mapping": { + "message": "customer" + } + }, + + { + "host": ["http://email:9013"], + "url_pattern": "/", + "mapping": { + "message": "email" + } + }, + + { + "host": ["http://notification:9014"], + "url_pattern": "/", + "mapping": { + "message": "notification" + } + }, + + { + "host": ["http://payment:9015"], + "url_pattern": "/", + "mapping": { + "message": "payment" + } + }, + + { + "host": ["http://product:9016"], + "url_pattern": "/", + "mapping": { + "message": "product" + } + }, + + { + "host": ["http://rbac:9017"], + "url_pattern": "/", + "mapping": { + "message": "rbac" + } + }, + + { + "host": ["http://supplier:9018"], + "url_pattern": "/", + "mapping": { + "message": "supplier" + } + }, + + { + "host": ["http://upload:9019"], + "url_pattern": "/", + "mapping": { + "message": "upload" + } + }, + + { + "host": ["http://th:9020"], + "url_pattern": "/", + "mapping": { + "message": "th" + } + }, + + { + "host": ["http://kjhgf:9021"], + "url_pattern": "/", + "mapping": { + "message": "kjhgf" + } + }, + + { + "host": ["http://hhgfdsdfghj:9022"], + "url_pattern": "/", + "mapping": { + "message": "hhgfdsdfghj" + } + }, + + { + "host": ["http://ghjk:9023"], + "url_pattern": "/", + "mapping": { + "message": "ghjk" + } + }, + + { + "host": ["http://shjksgd:30067"], + "url_pattern": "/", + "mapping": { + "message": "shjksgd" + } + }] + }, + { + "@comment": "Hit all API list endpoints simultaneously", + "endpoint": "/api/v1/", + "method": "GET", + "backend": [ + { + "host": ["http://hd:null"], + "url_pattern": "/api/v1/hds", + "mapping": { + "data": "hds" + } + }, + + { + "host": ["http://customer-service:9000"], + "url_pattern": "/api/v1/customer-services", + "mapping": { + "data": "customer-services" + } + }, + + { + "host": ["http://product-service:9002"], + "url_pattern": "/api/v1/product-services", + "mapping": { + "data": "product-services" + } + }, + + { + "host": ["http://rbac-service:9004"], + "url_pattern": "/api/v1/rbac-services", + "mapping": { + "data": "rbac-services" + } + }, + + { + "host": ["http://payment-service:9006"], + "url_pattern": "/api/v1/payment-services", + "mapping": { + "data": "payment-services" + } + }, + + { + "host": ["http://notification-service:9007"], + "url_pattern": "/api/v1/notification-services", + "mapping": { + "data": "notification-services" + } + }, + + { + "host": ["http://email-service:9008"], + "url_pattern": "/api/v1/email-services", + "mapping": { + "data": "email-services" + } + }, + + { + "host": ["http://cart-service:9009"], + "url_pattern": "/api/v1/cart-services", + "mapping": { + "data": "cart-services" + } + }, + + { + "host": ["http://cart:9010"], + "url_pattern": "/api/v1/carts", + "mapping": { + "data": "carts" + } + }, + + { + "host": ["http://user:9011"], + "url_pattern": "/api/v1/users", + "mapping": { + "data": "users" + } + }, + + { + "host": ["http://customer:9012"], + "url_pattern": "/api/v1/customers", + "mapping": { + "data": "customers" + } + }, + + { + "host": ["http://email:9013"], + "url_pattern": "/api/v1/emails", + "mapping": { + "data": "emails" + } + }, + + { + "host": ["http://notification:9014"], + "url_pattern": "/api/v1/notifications", + "mapping": { + "data": "notifications" + } + }, + + { + "host": ["http://payment:9015"], + "url_pattern": "/api/v1/payments", + "mapping": { + "data": "payments" + } + }, + + { + "host": ["http://product:9016"], + "url_pattern": "/api/v1/products", + "mapping": { + "data": "products" + } + }, + + { + "host": ["http://rbac:9017"], + "url_pattern": "/api/v1/rbacs", + "mapping": { + "data": "rbacs" + } + }, + + { + "host": ["http://supplier:9018"], + "url_pattern": "/api/v1/suppliers", + "mapping": { + "data": "suppliers" + } + }, + + { + "host": ["http://upload:9019"], + "url_pattern": "/api/v1/uploads", + "mapping": { + "data": "uploads" + } + }, + + { + "host": ["http://th:9020"], + "url_pattern": "/api/v1/ths", + "mapping": { + "data": "ths" + } + }, + + { + "host": ["http://kjhgf:9021"], + "url_pattern": "/api/v1/kjhgfs", + "mapping": { + "data": "kjhgfs" + } + }, + + { + "host": ["http://hhgfdsdfghj:9022"], + "url_pattern": "/api/v1/hhgfdsdfghjs", + "mapping": { + "data": "hhgfdsdfghjs" + } + }, + + { + "host": ["http://ghjk:9023"], + "url_pattern": "/api/v1/ghjks", + "mapping": { + "data": "ghjks" + } + }, + + { + "host": ["http://shjksgd:30067"], + "url_pattern": "/api/v1/shjksgds", + "mapping": { + "data": "shjksgds" + } + }] + }, + { + "@comment": "Fetch all data from the hd service", + "endpoint": "/api/v1/hds", + "method": "GET", + "backend": [ + { + "host": ["http://hd:null"], + "url_pattern": "/api/v1/hds", + "mapping": { + "data": "hds" + } + }] + } + ] +} \ No newline at end of file diff --git a/gateways/apps/test3/nginx/Dockerfile b/gateways/apps/test3/nginx/Dockerfile new file mode 100644 index 0000000..ddf7281 --- /dev/null +++ b/gateways/apps/test3/nginx/Dockerfile @@ -0,0 +1,3 @@ + +FROM nginx +COPY ./default.conf /etc/nginx/conf.d/default.conf \ No newline at end of file diff --git a/gateways/apps/test3/nginx/Dockerfile.dev b/gateways/apps/test3/nginx/Dockerfile.dev new file mode 100644 index 0000000..ddf7281 --- /dev/null +++ b/gateways/apps/test3/nginx/Dockerfile.dev @@ -0,0 +1,3 @@ + +FROM nginx +COPY ./default.conf /etc/nginx/conf.d/default.conf \ No newline at end of file diff --git a/gateways/apps/test3/nginx/default.conf b/gateways/apps/test3/nginx/default.conf new file mode 100644 index 0000000..d4dace0 --- /dev/null +++ b/gateways/apps/test3/nginx/default.conf @@ -0,0 +1,282 @@ + + +upstream hd_upstream { + server hd:null; +} + +upstream customer-service_upstream { + server customer-service:9000; +} + +upstream product-service_upstream { + server product-service:9002; +} + +upstream rbac-service_upstream { + server rbac-service:9004; +} + +upstream payment-service_upstream { + server payment-service:9006; +} + +upstream notification-service_upstream { + server notification-service:9007; +} + +upstream email-service_upstream { + server email-service:9008; +} + +upstream cart-service_upstream { + server cart-service:9009; +} + +upstream cart_upstream { + server cart:9010; +} + +upstream user_upstream { + server user:9011; +} + +upstream customer_upstream { + server customer:9012; +} + +upstream email_upstream { + server email:9013; +} + +upstream notification_upstream { + server notification:9014; +} + +upstream payment_upstream { + server payment:9015; +} + +upstream product_upstream { + server product:9016; +} + +upstream rbac_upstream { + server rbac:9017; +} + +upstream supplier_upstream { + server supplier:9018; +} + +upstream upload_upstream { + server upload:9019; +} + +upstream th_upstream { + server th:9020; +} + +upstream kjhgf_upstream { + server kjhgf:9021; +} + +upstream hhgfdsdfghj_upstream { + server hhgfdsdfghj:9022; +} + +upstream ghjk_upstream { + server ghjk:9023; +} + +upstream shjksgd_upstream { + server shjksgd:30067; +} + +server { + listen 80; + + + location /api/v1/hds { + proxy_pass http://hd_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/customer-services { + proxy_pass http://customer-service_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/product-services { + proxy_pass http://product-service_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/rbac-services { + proxy_pass http://rbac-service_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/payment-services { + proxy_pass http://payment-service_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/notification-services { + proxy_pass http://notification-service_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/email-services { + proxy_pass http://email-service_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/cart-services { + proxy_pass http://cart-service_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/carts { + proxy_pass http://cart_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/users { + proxy_pass http://user_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/customers { + proxy_pass http://customer_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/emails { + proxy_pass http://email_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/notifications { + proxy_pass http://notification_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/payments { + proxy_pass http://payment_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/products { + proxy_pass http://product_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/rbacs { + proxy_pass http://rbac_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/suppliers { + proxy_pass http://supplier_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/uploads { + proxy_pass http://upload_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/ths { + proxy_pass http://th_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/kjhgfs { + proxy_pass http://kjhgf_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/hhgfdsdfghjs { + proxy_pass http://hhgfdsdfghj_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/ghjks { + proxy_pass http://ghjk_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/shjksgds { + proxy_pass http://shjksgd_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } +} \ No newline at end of file diff --git a/gateways/apps/testapp/docker-compose.dev.yml b/gateways/apps/testapp/docker-compose.dev.yml new file mode 100644 index 0000000..03a3b30 --- /dev/null +++ b/gateways/apps/testapp/docker-compose.dev.yml @@ -0,0 +1,353 @@ + +version: '3.8' +services: + + hd: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/hd + ports: + - "null:null" + volumes: + - /app/node_modules + - ../../../microservices/hd:/app + depends_on: + rabbitmq: + condition: service_healthy + + customer-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/customer-service + ports: + - "9000:9000" + volumes: + - /app/node_modules + - ../../../microservices/customer-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + product-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/product-service + ports: + - "9002:9002" + volumes: + - /app/node_modules + - ../../../microservices/product-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + rbac-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/rbac-service + ports: + - "9004:9004" + volumes: + - /app/node_modules + - ../../../microservices/rbac-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + payment-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/payment-service + ports: + - "9006:9006" + volumes: + - /app/node_modules + - ../../../microservices/payment-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + notification-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/notification-service + ports: + - "9007:9007" + volumes: + - /app/node_modules + - ../../../microservices/notification-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + email-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/email-service + ports: + - "9008:9008" + volumes: + - /app/node_modules + - ../../../microservices/email-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + cart-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/cart-service + ports: + - "9009:9009" + volumes: + - /app/node_modules + - ../../../microservices/cart-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + cart: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/cart + ports: + - "9010:9010" + volumes: + - /app/node_modules + - ../../../microservices/cart:/app + depends_on: + rabbitmq: + condition: service_healthy + + user: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/user + ports: + - "9011:9011" + volumes: + - /app/node_modules + - ../../../microservices/user:/app + depends_on: + rabbitmq: + condition: service_healthy + + customer: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/customer + ports: + - "9012:9012" + volumes: + - /app/node_modules + - ../../../microservices/customer:/app + depends_on: + rabbitmq: + condition: service_healthy + + email: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/email + ports: + - "9013:9013" + volumes: + - /app/node_modules + - ../../../microservices/email:/app + depends_on: + rabbitmq: + condition: service_healthy + + notification: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/notification + ports: + - "9014:9014" + volumes: + - /app/node_modules + - ../../../microservices/notification:/app + depends_on: + rabbitmq: + condition: service_healthy + + payment: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/payment + ports: + - "9015:9015" + volumes: + - /app/node_modules + - ../../../microservices/payment:/app + depends_on: + rabbitmq: + condition: service_healthy + + product: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/product + ports: + - "9016:9016" + volumes: + - /app/node_modules + - ../../../microservices/product:/app + depends_on: + rabbitmq: + condition: service_healthy + + rbac: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/rbac + ports: + - "9017:9017" + volumes: + - /app/node_modules + - ../../../microservices/rbac:/app + depends_on: + rabbitmq: + condition: service_healthy + + supplier: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/supplier + ports: + - "9018:9018" + volumes: + - /app/node_modules + - ../../../microservices/supplier:/app + depends_on: + rabbitmq: + condition: service_healthy + + upload: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/upload + ports: + - "9019:9019" + volumes: + - /app/node_modules + - ../../../microservices/upload:/app + depends_on: + rabbitmq: + condition: service_healthy + + th: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/th + ports: + - "9020:9020" + volumes: + - /app/node_modules + - ../../../microservices/th:/app + depends_on: + rabbitmq: + condition: service_healthy + + kjhgf: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/kjhgf + ports: + - "9021:9021" + volumes: + - /app/node_modules + - ../../../microservices/kjhgf:/app + depends_on: + rabbitmq: + condition: service_healthy + + hhgfdsdfghj: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/hhgfdsdfghj + ports: + - "9022:9022" + volumes: + - /app/node_modules + - ../../../microservices/hhgfdsdfghj:/app + depends_on: + rabbitmq: + condition: service_healthy + + ghjk: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/ghjk + ports: + - "9023:9023" + volumes: + - /app/node_modules + - ../../../microservices/ghjk:/app + depends_on: + rabbitmq: + condition: service_healthy + + nginx: + depends_on: + - hd + - customer-service + - product-service + - rbac-service + - payment-service + - notification-service + - email-service + - cart-service + - cart + - user + - customer + - email + - notification + - payment + - product + - rbac + - supplier + - upload + - th + - kjhgf + - hhgfdsdfghj + - ghjk + restart: always + build: + context: ./nginx + dockerfile: Dockerfile.dev + ports: + - '4000:80' + healthcheck: + test: ["CMD-SHELL", "curl -f http://localhost:80/health || exit 1"] + interval: 30s + timeout: 10s + retries: 3 + start_period: 40s + rabbitmq: + image: rabbitmq:3.13-management + container_name: rabbitmq + ports: + - '5672:5672' + - '15672:15672' + healthcheck: + test: ["CMD", "rabbitmq-diagnostics", "ping"] + interval: 30s + retries: 5 + mongodb: + image: mongo + ports: + - '27017:27017' + restart: always + volumes: + - type: bind + source: ./data + target: /data/db + krakend: + image: devopsfaith/krakend:2.7-watch + ports: + - '9001:9001' + - '8090:8090' + volumes: + - ./krakend/:/etc/krakend/ + command: ['run','-d','-c','/etc/krakend/krakend.json'] \ No newline at end of file diff --git a/gateways/apps/testapp/docker-compose.yml b/gateways/apps/testapp/docker-compose.yml new file mode 100644 index 0000000..f11f17d --- /dev/null +++ b/gateways/apps/testapp/docker-compose.yml @@ -0,0 +1,353 @@ + +version: '3.8' +services: + + hd: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/hd + ports: + - "null:null" + volumes: + - /app/node_modules + - ../../../microservices/hd:/app + depends_on: + rabbitmq: + condition: service_healthy + + customer-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/customer-service + ports: + - "9000:9000" + volumes: + - /app/node_modules + - ../../../microservices/customer-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + product-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/product-service + ports: + - "9002:9002" + volumes: + - /app/node_modules + - ../../../microservices/product-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + rbac-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/rbac-service + ports: + - "9004:9004" + volumes: + - /app/node_modules + - ../../../microservices/rbac-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + payment-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/payment-service + ports: + - "9006:9006" + volumes: + - /app/node_modules + - ../../../microservices/payment-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + notification-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/notification-service + ports: + - "9007:9007" + volumes: + - /app/node_modules + - ../../../microservices/notification-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + email-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/email-service + ports: + - "9008:9008" + volumes: + - /app/node_modules + - ../../../microservices/email-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + cart-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/cart-service + ports: + - "9009:9009" + volumes: + - /app/node_modules + - ../../../microservices/cart-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + cart: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/cart + ports: + - "9010:9010" + volumes: + - /app/node_modules + - ../../../microservices/cart:/app + depends_on: + rabbitmq: + condition: service_healthy + + user: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/user + ports: + - "9011:9011" + volumes: + - /app/node_modules + - ../../../microservices/user:/app + depends_on: + rabbitmq: + condition: service_healthy + + customer: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/customer + ports: + - "9012:9012" + volumes: + - /app/node_modules + - ../../../microservices/customer:/app + depends_on: + rabbitmq: + condition: service_healthy + + email: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/email + ports: + - "9013:9013" + volumes: + - /app/node_modules + - ../../../microservices/email:/app + depends_on: + rabbitmq: + condition: service_healthy + + notification: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/notification + ports: + - "9014:9014" + volumes: + - /app/node_modules + - ../../../microservices/notification:/app + depends_on: + rabbitmq: + condition: service_healthy + + payment: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/payment + ports: + - "9015:9015" + volumes: + - /app/node_modules + - ../../../microservices/payment:/app + depends_on: + rabbitmq: + condition: service_healthy + + product: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/product + ports: + - "9016:9016" + volumes: + - /app/node_modules + - ../../../microservices/product:/app + depends_on: + rabbitmq: + condition: service_healthy + + rbac: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/rbac + ports: + - "9017:9017" + volumes: + - /app/node_modules + - ../../../microservices/rbac:/app + depends_on: + rabbitmq: + condition: service_healthy + + supplier: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/supplier + ports: + - "9018:9018" + volumes: + - /app/node_modules + - ../../../microservices/supplier:/app + depends_on: + rabbitmq: + condition: service_healthy + + upload: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/upload + ports: + - "9019:9019" + volumes: + - /app/node_modules + - ../../../microservices/upload:/app + depends_on: + rabbitmq: + condition: service_healthy + + th: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/th + ports: + - "9020:9020" + volumes: + - /app/node_modules + - ../../../microservices/th:/app + depends_on: + rabbitmq: + condition: service_healthy + + kjhgf: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/kjhgf + ports: + - "9021:9021" + volumes: + - /app/node_modules + - ../../../microservices/kjhgf:/app + depends_on: + rabbitmq: + condition: service_healthy + + hhgfdsdfghj: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/hhgfdsdfghj + ports: + - "9022:9022" + volumes: + - /app/node_modules + - ../../../microservices/hhgfdsdfghj:/app + depends_on: + rabbitmq: + condition: service_healthy + + ghjk: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/ghjk + ports: + - "9023:9023" + volumes: + - /app/node_modules + - ../../../microservices/ghjk:/app + depends_on: + rabbitmq: + condition: service_healthy + + nginx: + depends_on: + - hd + - customer-service + - product-service + - rbac-service + - payment-service + - notification-service + - email-service + - cart-service + - cart + - user + - customer + - email + - notification + - payment + - product + - rbac + - supplier + - upload + - th + - kjhgf + - hhgfdsdfghj + - ghjk + restart: always + build: + context: ./nginx + dockerfile: Dockerfile.dev + ports: + - '4000:80' + healthcheck: + test: ["CMD-SHELL", "curl -f http://localhost:80/health || exit 1"] + interval: 30s + timeout: 10s + retries: 3 + start_period: 40s + rabbitmq: + image: rabbitmq:3.13-management + container_name: rabbitmq + ports: + - '5672:5672' + - '15672:15672' + healthcheck: + test: ["CMD", "rabbitmq-diagnostics", "ping"] + interval: 30s + retries: 5 + mongodb: + image: mongo + ports: + - '27017:27017' + restart: always + volumes: + - type: bind + source: ./data + target: /data/db + krakend: + image: devopsfaith/krakend:2.7 + ports: + - '9001:9001' + - '8090:8090' + volumes: + - ./krakend/:/etc/krakend/ + command: ['run','-d','-c','/etc/krakend/krakend.json'] \ No newline at end of file diff --git a/gateways/apps/testapp/krakend/krakend.json b/gateways/apps/testapp/krakend/krakend.json new file mode 100644 index 0000000..bb3daec --- /dev/null +++ b/gateways/apps/testapp/krakend/krakend.json @@ -0,0 +1,386 @@ + +{ + "$schema": "https://www.krakend.io/schema/v2.5/krakend.json", + "version": 3, + "name": "Microservices-suite API Gateway", + "port": 9001, + "cache_ttl": "3600s", + "timeout": "300s", + "endpoints": [ + { + "@comment": "Check the health of all your APIs", + "endpoint": "/__suite_status", + "method": "GET", + "backend": [ + { + "host": ["http://hd:null"], + "url_pattern": "/", + "mapping": { + "message": "hd" + } + }, + + { + "host": ["http://customer-service:9000"], + "url_pattern": "/", + "mapping": { + "message": "customer-service" + } + }, + + { + "host": ["http://product-service:9002"], + "url_pattern": "/", + "mapping": { + "message": "product-service" + } + }, + + { + "host": ["http://rbac-service:9004"], + "url_pattern": "/", + "mapping": { + "message": "rbac-service" + } + }, + + { + "host": ["http://payment-service:9006"], + "url_pattern": "/", + "mapping": { + "message": "payment-service" + } + }, + + { + "host": ["http://notification-service:9007"], + "url_pattern": "/", + "mapping": { + "message": "notification-service" + } + }, + + { + "host": ["http://email-service:9008"], + "url_pattern": "/", + "mapping": { + "message": "email-service" + } + }, + + { + "host": ["http://cart-service:9009"], + "url_pattern": "/", + "mapping": { + "message": "cart-service" + } + }, + + { + "host": ["http://cart:9010"], + "url_pattern": "/", + "mapping": { + "message": "cart" + } + }, + + { + "host": ["http://user:9011"], + "url_pattern": "/", + "mapping": { + "message": "user" + } + }, + + { + "host": ["http://customer:9012"], + "url_pattern": "/", + "mapping": { + "message": "customer" + } + }, + + { + "host": ["http://email:9013"], + "url_pattern": "/", + "mapping": { + "message": "email" + } + }, + + { + "host": ["http://notification:9014"], + "url_pattern": "/", + "mapping": { + "message": "notification" + } + }, + + { + "host": ["http://payment:9015"], + "url_pattern": "/", + "mapping": { + "message": "payment" + } + }, + + { + "host": ["http://product:9016"], + "url_pattern": "/", + "mapping": { + "message": "product" + } + }, + + { + "host": ["http://rbac:9017"], + "url_pattern": "/", + "mapping": { + "message": "rbac" + } + }, + + { + "host": ["http://supplier:9018"], + "url_pattern": "/", + "mapping": { + "message": "supplier" + } + }, + + { + "host": ["http://upload:9019"], + "url_pattern": "/", + "mapping": { + "message": "upload" + } + }, + + { + "host": ["http://th:9020"], + "url_pattern": "/", + "mapping": { + "message": "th" + } + }, + + { + "host": ["http://kjhgf:9021"], + "url_pattern": "/", + "mapping": { + "message": "kjhgf" + } + }, + + { + "host": ["http://hhgfdsdfghj:9022"], + "url_pattern": "/", + "mapping": { + "message": "hhgfdsdfghj" + } + }, + + { + "host": ["http://ghjk:9023"], + "url_pattern": "/", + "mapping": { + "message": "ghjk" + } + }] + }, + { + "@comment": "Hit all API list endpoints simultaneously", + "endpoint": "/api/v1/", + "method": "GET", + "backend": [ + { + "host": ["http://hd:null"], + "url_pattern": "/api/v1/hds", + "mapping": { + "data": "hds" + } + }, + + { + "host": ["http://customer-service:9000"], + "url_pattern": "/api/v1/customer-services", + "mapping": { + "data": "customer-services" + } + }, + + { + "host": ["http://product-service:9002"], + "url_pattern": "/api/v1/product-services", + "mapping": { + "data": "product-services" + } + }, + + { + "host": ["http://rbac-service:9004"], + "url_pattern": "/api/v1/rbac-services", + "mapping": { + "data": "rbac-services" + } + }, + + { + "host": ["http://payment-service:9006"], + "url_pattern": "/api/v1/payment-services", + "mapping": { + "data": "payment-services" + } + }, + + { + "host": ["http://notification-service:9007"], + "url_pattern": "/api/v1/notification-services", + "mapping": { + "data": "notification-services" + } + }, + + { + "host": ["http://email-service:9008"], + "url_pattern": "/api/v1/email-services", + "mapping": { + "data": "email-services" + } + }, + + { + "host": ["http://cart-service:9009"], + "url_pattern": "/api/v1/cart-services", + "mapping": { + "data": "cart-services" + } + }, + + { + "host": ["http://cart:9010"], + "url_pattern": "/api/v1/carts", + "mapping": { + "data": "carts" + } + }, + + { + "host": ["http://user:9011"], + "url_pattern": "/api/v1/users", + "mapping": { + "data": "users" + } + }, + + { + "host": ["http://customer:9012"], + "url_pattern": "/api/v1/customers", + "mapping": { + "data": "customers" + } + }, + + { + "host": ["http://email:9013"], + "url_pattern": "/api/v1/emails", + "mapping": { + "data": "emails" + } + }, + + { + "host": ["http://notification:9014"], + "url_pattern": "/api/v1/notifications", + "mapping": { + "data": "notifications" + } + }, + + { + "host": ["http://payment:9015"], + "url_pattern": "/api/v1/payments", + "mapping": { + "data": "payments" + } + }, + + { + "host": ["http://product:9016"], + "url_pattern": "/api/v1/products", + "mapping": { + "data": "products" + } + }, + + { + "host": ["http://rbac:9017"], + "url_pattern": "/api/v1/rbacs", + "mapping": { + "data": "rbacs" + } + }, + + { + "host": ["http://supplier:9018"], + "url_pattern": "/api/v1/suppliers", + "mapping": { + "data": "suppliers" + } + }, + + { + "host": ["http://upload:9019"], + "url_pattern": "/api/v1/uploads", + "mapping": { + "data": "uploads" + } + }, + + { + "host": ["http://th:9020"], + "url_pattern": "/api/v1/ths", + "mapping": { + "data": "ths" + } + }, + + { + "host": ["http://kjhgf:9021"], + "url_pattern": "/api/v1/kjhgfs", + "mapping": { + "data": "kjhgfs" + } + }, + + { + "host": ["http://hhgfdsdfghj:9022"], + "url_pattern": "/api/v1/hhgfdsdfghjs", + "mapping": { + "data": "hhgfdsdfghjs" + } + }, + + { + "host": ["http://ghjk:9023"], + "url_pattern": "/api/v1/ghjks", + "mapping": { + "data": "ghjks" + } + }] + }, + { + "@comment": "Fetch all data from the hd service", + "endpoint": "/api/v1/hds", + "method": "GET", + "backend": [ + { + "host": ["http://hd:null"], + "url_pattern": "/api/v1/hds", + "mapping": { + "data": "hds" + } + }] + } + ] +} \ No newline at end of file diff --git a/gateways/apps/testapp/nginx/Dockerfile b/gateways/apps/testapp/nginx/Dockerfile new file mode 100644 index 0000000..ddf7281 --- /dev/null +++ b/gateways/apps/testapp/nginx/Dockerfile @@ -0,0 +1,3 @@ + +FROM nginx +COPY ./default.conf /etc/nginx/conf.d/default.conf \ No newline at end of file diff --git a/gateways/apps/testapp/nginx/Dockerfile.dev b/gateways/apps/testapp/nginx/Dockerfile.dev new file mode 100644 index 0000000..ddf7281 --- /dev/null +++ b/gateways/apps/testapp/nginx/Dockerfile.dev @@ -0,0 +1,3 @@ + +FROM nginx +COPY ./default.conf /etc/nginx/conf.d/default.conf \ No newline at end of file diff --git a/gateways/apps/testapp/nginx/default.conf b/gateways/apps/testapp/nginx/default.conf new file mode 100644 index 0000000..b25033b --- /dev/null +++ b/gateways/apps/testapp/nginx/default.conf @@ -0,0 +1,270 @@ + + +upstream hd_upstream { + server hd:null; +} + +upstream customer-service_upstream { + server customer-service:9000; +} + +upstream product-service_upstream { + server product-service:9002; +} + +upstream rbac-service_upstream { + server rbac-service:9004; +} + +upstream payment-service_upstream { + server payment-service:9006; +} + +upstream notification-service_upstream { + server notification-service:9007; +} + +upstream email-service_upstream { + server email-service:9008; +} + +upstream cart-service_upstream { + server cart-service:9009; +} + +upstream cart_upstream { + server cart:9010; +} + +upstream user_upstream { + server user:9011; +} + +upstream customer_upstream { + server customer:9012; +} + +upstream email_upstream { + server email:9013; +} + +upstream notification_upstream { + server notification:9014; +} + +upstream payment_upstream { + server payment:9015; +} + +upstream product_upstream { + server product:9016; +} + +upstream rbac_upstream { + server rbac:9017; +} + +upstream supplier_upstream { + server supplier:9018; +} + +upstream upload_upstream { + server upload:9019; +} + +upstream th_upstream { + server th:9020; +} + +upstream kjhgf_upstream { + server kjhgf:9021; +} + +upstream hhgfdsdfghj_upstream { + server hhgfdsdfghj:9022; +} + +upstream ghjk_upstream { + server ghjk:9023; +} + +server { + listen 80; + + + location /api/v1/hds { + proxy_pass http://hd_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/customer-services { + proxy_pass http://customer-service_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/product-services { + proxy_pass http://product-service_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/rbac-services { + proxy_pass http://rbac-service_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/payment-services { + proxy_pass http://payment-service_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/notification-services { + proxy_pass http://notification-service_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/email-services { + proxy_pass http://email-service_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/cart-services { + proxy_pass http://cart-service_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/carts { + proxy_pass http://cart_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/users { + proxy_pass http://user_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/customers { + proxy_pass http://customer_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/emails { + proxy_pass http://email_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/notifications { + proxy_pass http://notification_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/payments { + proxy_pass http://payment_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/products { + proxy_pass http://product_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/rbacs { + proxy_pass http://rbac_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/suppliers { + proxy_pass http://supplier_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/uploads { + proxy_pass http://upload_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/ths { + proxy_pass http://th_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/kjhgfs { + proxy_pass http://kjhgf_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/hhgfdsdfghjs { + proxy_pass http://hhgfdsdfghj_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/ghjks { + proxy_pass http://ghjk_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } +} \ No newline at end of file diff --git a/gateways/apps/testapp1/docker-compose.dev.yml b/gateways/apps/testapp1/docker-compose.dev.yml new file mode 100644 index 0000000..deb401b --- /dev/null +++ b/gateways/apps/testapp1/docker-compose.dev.yml @@ -0,0 +1,325 @@ + +version: '3.8' +services: + + hd: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/hd + ports: + - "null:null" + volumes: + - /app/node_modules + - ../../../microservices/hd:/app + depends_on: + rabbitmq: + condition: service_healthy + + customer-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/customer-service + ports: + - "9000:9000" + volumes: + - /app/node_modules + - ../../../microservices/customer-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + product-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/product-service + ports: + - "9002:9002" + volumes: + - /app/node_modules + - ../../../microservices/product-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + rbac-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/rbac-service + ports: + - "9004:9004" + volumes: + - /app/node_modules + - ../../../microservices/rbac-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + payment-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/payment-service + ports: + - "9006:9006" + volumes: + - /app/node_modules + - ../../../microservices/payment-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + notification-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/notification-service + ports: + - "9007:9007" + volumes: + - /app/node_modules + - ../../../microservices/notification-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + email-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/email-service + ports: + - "9008:9008" + volumes: + - /app/node_modules + - ../../../microservices/email-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + cart-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/cart-service + ports: + - "9009:9009" + volumes: + - /app/node_modules + - ../../../microservices/cart-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + cart: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/cart + ports: + - "9010:9010" + volumes: + - /app/node_modules + - ../../../microservices/cart:/app + depends_on: + rabbitmq: + condition: service_healthy + + user: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/user + ports: + - "9011:9011" + volumes: + - /app/node_modules + - ../../../microservices/user:/app + depends_on: + rabbitmq: + condition: service_healthy + + customer: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/customer + ports: + - "9012:9012" + volumes: + - /app/node_modules + - ../../../microservices/customer:/app + depends_on: + rabbitmq: + condition: service_healthy + + email: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/email + ports: + - "9013:9013" + volumes: + - /app/node_modules + - ../../../microservices/email:/app + depends_on: + rabbitmq: + condition: service_healthy + + notification: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/notification + ports: + - "9014:9014" + volumes: + - /app/node_modules + - ../../../microservices/notification:/app + depends_on: + rabbitmq: + condition: service_healthy + + payment: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/payment + ports: + - "9015:9015" + volumes: + - /app/node_modules + - ../../../microservices/payment:/app + depends_on: + rabbitmq: + condition: service_healthy + + product: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/product + ports: + - "9016:9016" + volumes: + - /app/node_modules + - ../../../microservices/product:/app + depends_on: + rabbitmq: + condition: service_healthy + + rbac: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/rbac + ports: + - "9017:9017" + volumes: + - /app/node_modules + - ../../../microservices/rbac:/app + depends_on: + rabbitmq: + condition: service_healthy + + supplier: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/supplier + ports: + - "9018:9018" + volumes: + - /app/node_modules + - ../../../microservices/supplier:/app + depends_on: + rabbitmq: + condition: service_healthy + + upload: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/upload + ports: + - "9019:9019" + volumes: + - /app/node_modules + - ../../../microservices/upload:/app + depends_on: + rabbitmq: + condition: service_healthy + + th: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/th + ports: + - "9020:9020" + volumes: + - /app/node_modules + - ../../../microservices/th:/app + depends_on: + rabbitmq: + condition: service_healthy + + kjhgf: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/kjhgf + ports: + - "9021:9021" + volumes: + - /app/node_modules + - ../../../microservices/kjhgf:/app + depends_on: + rabbitmq: + condition: service_healthy + + nginx: + depends_on: + - hd + - customer-service + - product-service + - rbac-service + - payment-service + - notification-service + - email-service + - cart-service + - cart + - user + - customer + - email + - notification + - payment + - product + - rbac + - supplier + - upload + - th + - kjhgf + restart: always + build: + context: ./nginx + dockerfile: Dockerfile.dev + ports: + - '4000:80' + healthcheck: + test: ["CMD-SHELL", "curl -f http://localhost:80/health || exit 1"] + interval: 30s + timeout: 10s + retries: 3 + start_period: 40s + rabbitmq: + image: rabbitmq:3.13-management + container_name: rabbitmq + ports: + - '5672:5672' + - '15672:15672' + healthcheck: + test: ["CMD", "rabbitmq-diagnostics", "ping"] + interval: 30s + retries: 5 + mongodb: + image: mongo + ports: + - '27017:27017' + restart: always + volumes: + - type: bind + source: ./data + target: /data/db + krakend: + image: devopsfaith/krakend:2.7-watch + ports: + - '9001:9001' + - '8090:8090' + volumes: + - ./krakend/:/etc/krakend/ + command: ['run','-d','-c','/etc/krakend/krakend.json'] \ No newline at end of file diff --git a/gateways/apps/testapp1/docker-compose.yml b/gateways/apps/testapp1/docker-compose.yml new file mode 100644 index 0000000..be77908 --- /dev/null +++ b/gateways/apps/testapp1/docker-compose.yml @@ -0,0 +1,325 @@ + +version: '3.8' +services: + + hd: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/hd + ports: + - "null:null" + volumes: + - /app/node_modules + - ../../../microservices/hd:/app + depends_on: + rabbitmq: + condition: service_healthy + + customer-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/customer-service + ports: + - "9000:9000" + volumes: + - /app/node_modules + - ../../../microservices/customer-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + product-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/product-service + ports: + - "9002:9002" + volumes: + - /app/node_modules + - ../../../microservices/product-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + rbac-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/rbac-service + ports: + - "9004:9004" + volumes: + - /app/node_modules + - ../../../microservices/rbac-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + payment-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/payment-service + ports: + - "9006:9006" + volumes: + - /app/node_modules + - ../../../microservices/payment-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + notification-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/notification-service + ports: + - "9007:9007" + volumes: + - /app/node_modules + - ../../../microservices/notification-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + email-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/email-service + ports: + - "9008:9008" + volumes: + - /app/node_modules + - ../../../microservices/email-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + cart-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/cart-service + ports: + - "9009:9009" + volumes: + - /app/node_modules + - ../../../microservices/cart-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + cart: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/cart + ports: + - "9010:9010" + volumes: + - /app/node_modules + - ../../../microservices/cart:/app + depends_on: + rabbitmq: + condition: service_healthy + + user: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/user + ports: + - "9011:9011" + volumes: + - /app/node_modules + - ../../../microservices/user:/app + depends_on: + rabbitmq: + condition: service_healthy + + customer: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/customer + ports: + - "9012:9012" + volumes: + - /app/node_modules + - ../../../microservices/customer:/app + depends_on: + rabbitmq: + condition: service_healthy + + email: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/email + ports: + - "9013:9013" + volumes: + - /app/node_modules + - ../../../microservices/email:/app + depends_on: + rabbitmq: + condition: service_healthy + + notification: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/notification + ports: + - "9014:9014" + volumes: + - /app/node_modules + - ../../../microservices/notification:/app + depends_on: + rabbitmq: + condition: service_healthy + + payment: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/payment + ports: + - "9015:9015" + volumes: + - /app/node_modules + - ../../../microservices/payment:/app + depends_on: + rabbitmq: + condition: service_healthy + + product: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/product + ports: + - "9016:9016" + volumes: + - /app/node_modules + - ../../../microservices/product:/app + depends_on: + rabbitmq: + condition: service_healthy + + rbac: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/rbac + ports: + - "9017:9017" + volumes: + - /app/node_modules + - ../../../microservices/rbac:/app + depends_on: + rabbitmq: + condition: service_healthy + + supplier: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/supplier + ports: + - "9018:9018" + volumes: + - /app/node_modules + - ../../../microservices/supplier:/app + depends_on: + rabbitmq: + condition: service_healthy + + upload: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/upload + ports: + - "9019:9019" + volumes: + - /app/node_modules + - ../../../microservices/upload:/app + depends_on: + rabbitmq: + condition: service_healthy + + th: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/th + ports: + - "9020:9020" + volumes: + - /app/node_modules + - ../../../microservices/th:/app + depends_on: + rabbitmq: + condition: service_healthy + + kjhgf: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/kjhgf + ports: + - "9021:9021" + volumes: + - /app/node_modules + - ../../../microservices/kjhgf:/app + depends_on: + rabbitmq: + condition: service_healthy + + nginx: + depends_on: + - hd + - customer-service + - product-service + - rbac-service + - payment-service + - notification-service + - email-service + - cart-service + - cart + - user + - customer + - email + - notification + - payment + - product + - rbac + - supplier + - upload + - th + - kjhgf + restart: always + build: + context: ./nginx + dockerfile: Dockerfile.dev + ports: + - '4000:80' + healthcheck: + test: ["CMD-SHELL", "curl -f http://localhost:80/health || exit 1"] + interval: 30s + timeout: 10s + retries: 3 + start_period: 40s + rabbitmq: + image: rabbitmq:3.13-management + container_name: rabbitmq + ports: + - '5672:5672' + - '15672:15672' + healthcheck: + test: ["CMD", "rabbitmq-diagnostics", "ping"] + interval: 30s + retries: 5 + mongodb: + image: mongo + ports: + - '27017:27017' + restart: always + volumes: + - type: bind + source: ./data + target: /data/db + krakend: + image: devopsfaith/krakend:2.7 + ports: + - '9001:9001' + - '8090:8090' + volumes: + - ./krakend/:/etc/krakend/ + command: ['run','-d','-c','/etc/krakend/krakend.json'] \ No newline at end of file diff --git a/gateways/apps/testapp1/krakend/krakend.json b/gateways/apps/testapp1/krakend/krakend.json new file mode 100644 index 0000000..7038925 --- /dev/null +++ b/gateways/apps/testapp1/krakend/krakend.json @@ -0,0 +1,354 @@ + +{ + "$schema": "https://www.krakend.io/schema/v2.5/krakend.json", + "version": 3, + "name": "Microservices-suite API Gateway", + "port": 9001, + "cache_ttl": "3600s", + "timeout": "300s", + "endpoints": [ + { + "@comment": "Check the health of all your APIs", + "endpoint": "/__suite_status", + "method": "GET", + "backend": [ + { + "host": ["http://hd:null"], + "url_pattern": "/", + "mapping": { + "message": "hd" + } + }, + + { + "host": ["http://customer-service:9000"], + "url_pattern": "/", + "mapping": { + "message": "customer-service" + } + }, + + { + "host": ["http://product-service:9002"], + "url_pattern": "/", + "mapping": { + "message": "product-service" + } + }, + + { + "host": ["http://rbac-service:9004"], + "url_pattern": "/", + "mapping": { + "message": "rbac-service" + } + }, + + { + "host": ["http://payment-service:9006"], + "url_pattern": "/", + "mapping": { + "message": "payment-service" + } + }, + + { + "host": ["http://notification-service:9007"], + "url_pattern": "/", + "mapping": { + "message": "notification-service" + } + }, + + { + "host": ["http://email-service:9008"], + "url_pattern": "/", + "mapping": { + "message": "email-service" + } + }, + + { + "host": ["http://cart-service:9009"], + "url_pattern": "/", + "mapping": { + "message": "cart-service" + } + }, + + { + "host": ["http://cart:9010"], + "url_pattern": "/", + "mapping": { + "message": "cart" + } + }, + + { + "host": ["http://user:9011"], + "url_pattern": "/", + "mapping": { + "message": "user" + } + }, + + { + "host": ["http://customer:9012"], + "url_pattern": "/", + "mapping": { + "message": "customer" + } + }, + + { + "host": ["http://email:9013"], + "url_pattern": "/", + "mapping": { + "message": "email" + } + }, + + { + "host": ["http://notification:9014"], + "url_pattern": "/", + "mapping": { + "message": "notification" + } + }, + + { + "host": ["http://payment:9015"], + "url_pattern": "/", + "mapping": { + "message": "payment" + } + }, + + { + "host": ["http://product:9016"], + "url_pattern": "/", + "mapping": { + "message": "product" + } + }, + + { + "host": ["http://rbac:9017"], + "url_pattern": "/", + "mapping": { + "message": "rbac" + } + }, + + { + "host": ["http://supplier:9018"], + "url_pattern": "/", + "mapping": { + "message": "supplier" + } + }, + + { + "host": ["http://upload:9019"], + "url_pattern": "/", + "mapping": { + "message": "upload" + } + }, + + { + "host": ["http://th:9020"], + "url_pattern": "/", + "mapping": { + "message": "th" + } + }, + + { + "host": ["http://kjhgf:9021"], + "url_pattern": "/", + "mapping": { + "message": "kjhgf" + } + }] + }, + { + "@comment": "Hit all API list endpoints simultaneously", + "endpoint": "/api/v1/", + "method": "GET", + "backend": [ + { + "host": ["http://hd:null"], + "url_pattern": "/api/v1/hds", + "mapping": { + "data": "hds" + } + }, + + { + "host": ["http://customer-service:9000"], + "url_pattern": "/api/v1/customer-services", + "mapping": { + "data": "customer-services" + } + }, + + { + "host": ["http://product-service:9002"], + "url_pattern": "/api/v1/product-services", + "mapping": { + "data": "product-services" + } + }, + + { + "host": ["http://rbac-service:9004"], + "url_pattern": "/api/v1/rbac-services", + "mapping": { + "data": "rbac-services" + } + }, + + { + "host": ["http://payment-service:9006"], + "url_pattern": "/api/v1/payment-services", + "mapping": { + "data": "payment-services" + } + }, + + { + "host": ["http://notification-service:9007"], + "url_pattern": "/api/v1/notification-services", + "mapping": { + "data": "notification-services" + } + }, + + { + "host": ["http://email-service:9008"], + "url_pattern": "/api/v1/email-services", + "mapping": { + "data": "email-services" + } + }, + + { + "host": ["http://cart-service:9009"], + "url_pattern": "/api/v1/cart-services", + "mapping": { + "data": "cart-services" + } + }, + + { + "host": ["http://cart:9010"], + "url_pattern": "/api/v1/carts", + "mapping": { + "data": "carts" + } + }, + + { + "host": ["http://user:9011"], + "url_pattern": "/api/v1/users", + "mapping": { + "data": "users" + } + }, + + { + "host": ["http://customer:9012"], + "url_pattern": "/api/v1/customers", + "mapping": { + "data": "customers" + } + }, + + { + "host": ["http://email:9013"], + "url_pattern": "/api/v1/emails", + "mapping": { + "data": "emails" + } + }, + + { + "host": ["http://notification:9014"], + "url_pattern": "/api/v1/notifications", + "mapping": { + "data": "notifications" + } + }, + + { + "host": ["http://payment:9015"], + "url_pattern": "/api/v1/payments", + "mapping": { + "data": "payments" + } + }, + + { + "host": ["http://product:9016"], + "url_pattern": "/api/v1/products", + "mapping": { + "data": "products" + } + }, + + { + "host": ["http://rbac:9017"], + "url_pattern": "/api/v1/rbacs", + "mapping": { + "data": "rbacs" + } + }, + + { + "host": ["http://supplier:9018"], + "url_pattern": "/api/v1/suppliers", + "mapping": { + "data": "suppliers" + } + }, + + { + "host": ["http://upload:9019"], + "url_pattern": "/api/v1/uploads", + "mapping": { + "data": "uploads" + } + }, + + { + "host": ["http://th:9020"], + "url_pattern": "/api/v1/ths", + "mapping": { + "data": "ths" + } + }, + + { + "host": ["http://kjhgf:9021"], + "url_pattern": "/api/v1/kjhgfs", + "mapping": { + "data": "kjhgfs" + } + }] + }, + { + "@comment": "Fetch all data from the hd service", + "endpoint": "/api/v1/hds", + "method": "GET", + "backend": [ + { + "host": ["http://hd:null"], + "url_pattern": "/api/v1/hds", + "mapping": { + "data": "hds" + } + }] + } + ] +} \ No newline at end of file diff --git a/gateways/apps/testapp1/nginx/Dockerfile b/gateways/apps/testapp1/nginx/Dockerfile new file mode 100644 index 0000000..ddf7281 --- /dev/null +++ b/gateways/apps/testapp1/nginx/Dockerfile @@ -0,0 +1,3 @@ + +FROM nginx +COPY ./default.conf /etc/nginx/conf.d/default.conf \ No newline at end of file diff --git a/gateways/apps/testapp1/nginx/Dockerfile.dev b/gateways/apps/testapp1/nginx/Dockerfile.dev new file mode 100644 index 0000000..ddf7281 --- /dev/null +++ b/gateways/apps/testapp1/nginx/Dockerfile.dev @@ -0,0 +1,3 @@ + +FROM nginx +COPY ./default.conf /etc/nginx/conf.d/default.conf \ No newline at end of file diff --git a/gateways/apps/testapp1/nginx/default.conf b/gateways/apps/testapp1/nginx/default.conf new file mode 100644 index 0000000..79f0686 --- /dev/null +++ b/gateways/apps/testapp1/nginx/default.conf @@ -0,0 +1,246 @@ + + +upstream hd_upstream { + server hd:null; +} + +upstream customer-service_upstream { + server customer-service:9000; +} + +upstream product-service_upstream { + server product-service:9002; +} + +upstream rbac-service_upstream { + server rbac-service:9004; +} + +upstream payment-service_upstream { + server payment-service:9006; +} + +upstream notification-service_upstream { + server notification-service:9007; +} + +upstream email-service_upstream { + server email-service:9008; +} + +upstream cart-service_upstream { + server cart-service:9009; +} + +upstream cart_upstream { + server cart:9010; +} + +upstream user_upstream { + server user:9011; +} + +upstream customer_upstream { + server customer:9012; +} + +upstream email_upstream { + server email:9013; +} + +upstream notification_upstream { + server notification:9014; +} + +upstream payment_upstream { + server payment:9015; +} + +upstream product_upstream { + server product:9016; +} + +upstream rbac_upstream { + server rbac:9017; +} + +upstream supplier_upstream { + server supplier:9018; +} + +upstream upload_upstream { + server upload:9019; +} + +upstream th_upstream { + server th:9020; +} + +upstream kjhgf_upstream { + server kjhgf:9021; +} + +server { + listen 80; + + + location /api/v1/hds { + proxy_pass http://hd_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/customer-services { + proxy_pass http://customer-service_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/product-services { + proxy_pass http://product-service_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/rbac-services { + proxy_pass http://rbac-service_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/payment-services { + proxy_pass http://payment-service_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/notification-services { + proxy_pass http://notification-service_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/email-services { + proxy_pass http://email-service_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/cart-services { + proxy_pass http://cart-service_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/carts { + proxy_pass http://cart_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/users { + proxy_pass http://user_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/customers { + proxy_pass http://customer_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/emails { + proxy_pass http://email_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/notifications { + proxy_pass http://notification_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/payments { + proxy_pass http://payment_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/products { + proxy_pass http://product_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/rbacs { + proxy_pass http://rbac_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/suppliers { + proxy_pass http://supplier_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/uploads { + proxy_pass http://upload_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/ths { + proxy_pass http://th_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/kjhgfs { + proxy_pass http://kjhgf_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } +} \ No newline at end of file diff --git a/gateways/apps/testappd/docker-compose.dev.yml b/gateways/apps/testappd/docker-compose.dev.yml new file mode 100644 index 0000000..deb401b --- /dev/null +++ b/gateways/apps/testappd/docker-compose.dev.yml @@ -0,0 +1,325 @@ + +version: '3.8' +services: + + hd: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/hd + ports: + - "null:null" + volumes: + - /app/node_modules + - ../../../microservices/hd:/app + depends_on: + rabbitmq: + condition: service_healthy + + customer-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/customer-service + ports: + - "9000:9000" + volumes: + - /app/node_modules + - ../../../microservices/customer-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + product-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/product-service + ports: + - "9002:9002" + volumes: + - /app/node_modules + - ../../../microservices/product-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + rbac-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/rbac-service + ports: + - "9004:9004" + volumes: + - /app/node_modules + - ../../../microservices/rbac-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + payment-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/payment-service + ports: + - "9006:9006" + volumes: + - /app/node_modules + - ../../../microservices/payment-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + notification-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/notification-service + ports: + - "9007:9007" + volumes: + - /app/node_modules + - ../../../microservices/notification-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + email-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/email-service + ports: + - "9008:9008" + volumes: + - /app/node_modules + - ../../../microservices/email-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + cart-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/cart-service + ports: + - "9009:9009" + volumes: + - /app/node_modules + - ../../../microservices/cart-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + cart: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/cart + ports: + - "9010:9010" + volumes: + - /app/node_modules + - ../../../microservices/cart:/app + depends_on: + rabbitmq: + condition: service_healthy + + user: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/user + ports: + - "9011:9011" + volumes: + - /app/node_modules + - ../../../microservices/user:/app + depends_on: + rabbitmq: + condition: service_healthy + + customer: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/customer + ports: + - "9012:9012" + volumes: + - /app/node_modules + - ../../../microservices/customer:/app + depends_on: + rabbitmq: + condition: service_healthy + + email: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/email + ports: + - "9013:9013" + volumes: + - /app/node_modules + - ../../../microservices/email:/app + depends_on: + rabbitmq: + condition: service_healthy + + notification: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/notification + ports: + - "9014:9014" + volumes: + - /app/node_modules + - ../../../microservices/notification:/app + depends_on: + rabbitmq: + condition: service_healthy + + payment: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/payment + ports: + - "9015:9015" + volumes: + - /app/node_modules + - ../../../microservices/payment:/app + depends_on: + rabbitmq: + condition: service_healthy + + product: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/product + ports: + - "9016:9016" + volumes: + - /app/node_modules + - ../../../microservices/product:/app + depends_on: + rabbitmq: + condition: service_healthy + + rbac: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/rbac + ports: + - "9017:9017" + volumes: + - /app/node_modules + - ../../../microservices/rbac:/app + depends_on: + rabbitmq: + condition: service_healthy + + supplier: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/supplier + ports: + - "9018:9018" + volumes: + - /app/node_modules + - ../../../microservices/supplier:/app + depends_on: + rabbitmq: + condition: service_healthy + + upload: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/upload + ports: + - "9019:9019" + volumes: + - /app/node_modules + - ../../../microservices/upload:/app + depends_on: + rabbitmq: + condition: service_healthy + + th: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/th + ports: + - "9020:9020" + volumes: + - /app/node_modules + - ../../../microservices/th:/app + depends_on: + rabbitmq: + condition: service_healthy + + kjhgf: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/kjhgf + ports: + - "9021:9021" + volumes: + - /app/node_modules + - ../../../microservices/kjhgf:/app + depends_on: + rabbitmq: + condition: service_healthy + + nginx: + depends_on: + - hd + - customer-service + - product-service + - rbac-service + - payment-service + - notification-service + - email-service + - cart-service + - cart + - user + - customer + - email + - notification + - payment + - product + - rbac + - supplier + - upload + - th + - kjhgf + restart: always + build: + context: ./nginx + dockerfile: Dockerfile.dev + ports: + - '4000:80' + healthcheck: + test: ["CMD-SHELL", "curl -f http://localhost:80/health || exit 1"] + interval: 30s + timeout: 10s + retries: 3 + start_period: 40s + rabbitmq: + image: rabbitmq:3.13-management + container_name: rabbitmq + ports: + - '5672:5672' + - '15672:15672' + healthcheck: + test: ["CMD", "rabbitmq-diagnostics", "ping"] + interval: 30s + retries: 5 + mongodb: + image: mongo + ports: + - '27017:27017' + restart: always + volumes: + - type: bind + source: ./data + target: /data/db + krakend: + image: devopsfaith/krakend:2.7-watch + ports: + - '9001:9001' + - '8090:8090' + volumes: + - ./krakend/:/etc/krakend/ + command: ['run','-d','-c','/etc/krakend/krakend.json'] \ No newline at end of file diff --git a/gateways/apps/testappd/docker-compose.yml b/gateways/apps/testappd/docker-compose.yml new file mode 100644 index 0000000..be77908 --- /dev/null +++ b/gateways/apps/testappd/docker-compose.yml @@ -0,0 +1,325 @@ + +version: '3.8' +services: + + hd: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/hd + ports: + - "null:null" + volumes: + - /app/node_modules + - ../../../microservices/hd:/app + depends_on: + rabbitmq: + condition: service_healthy + + customer-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/customer-service + ports: + - "9000:9000" + volumes: + - /app/node_modules + - ../../../microservices/customer-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + product-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/product-service + ports: + - "9002:9002" + volumes: + - /app/node_modules + - ../../../microservices/product-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + rbac-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/rbac-service + ports: + - "9004:9004" + volumes: + - /app/node_modules + - ../../../microservices/rbac-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + payment-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/payment-service + ports: + - "9006:9006" + volumes: + - /app/node_modules + - ../../../microservices/payment-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + notification-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/notification-service + ports: + - "9007:9007" + volumes: + - /app/node_modules + - ../../../microservices/notification-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + email-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/email-service + ports: + - "9008:9008" + volumes: + - /app/node_modules + - ../../../microservices/email-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + cart-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/cart-service + ports: + - "9009:9009" + volumes: + - /app/node_modules + - ../../../microservices/cart-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + cart: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/cart + ports: + - "9010:9010" + volumes: + - /app/node_modules + - ../../../microservices/cart:/app + depends_on: + rabbitmq: + condition: service_healthy + + user: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/user + ports: + - "9011:9011" + volumes: + - /app/node_modules + - ../../../microservices/user:/app + depends_on: + rabbitmq: + condition: service_healthy + + customer: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/customer + ports: + - "9012:9012" + volumes: + - /app/node_modules + - ../../../microservices/customer:/app + depends_on: + rabbitmq: + condition: service_healthy + + email: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/email + ports: + - "9013:9013" + volumes: + - /app/node_modules + - ../../../microservices/email:/app + depends_on: + rabbitmq: + condition: service_healthy + + notification: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/notification + ports: + - "9014:9014" + volumes: + - /app/node_modules + - ../../../microservices/notification:/app + depends_on: + rabbitmq: + condition: service_healthy + + payment: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/payment + ports: + - "9015:9015" + volumes: + - /app/node_modules + - ../../../microservices/payment:/app + depends_on: + rabbitmq: + condition: service_healthy + + product: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/product + ports: + - "9016:9016" + volumes: + - /app/node_modules + - ../../../microservices/product:/app + depends_on: + rabbitmq: + condition: service_healthy + + rbac: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/rbac + ports: + - "9017:9017" + volumes: + - /app/node_modules + - ../../../microservices/rbac:/app + depends_on: + rabbitmq: + condition: service_healthy + + supplier: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/supplier + ports: + - "9018:9018" + volumes: + - /app/node_modules + - ../../../microservices/supplier:/app + depends_on: + rabbitmq: + condition: service_healthy + + upload: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/upload + ports: + - "9019:9019" + volumes: + - /app/node_modules + - ../../../microservices/upload:/app + depends_on: + rabbitmq: + condition: service_healthy + + th: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/th + ports: + - "9020:9020" + volumes: + - /app/node_modules + - ../../../microservices/th:/app + depends_on: + rabbitmq: + condition: service_healthy + + kjhgf: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/kjhgf + ports: + - "9021:9021" + volumes: + - /app/node_modules + - ../../../microservices/kjhgf:/app + depends_on: + rabbitmq: + condition: service_healthy + + nginx: + depends_on: + - hd + - customer-service + - product-service + - rbac-service + - payment-service + - notification-service + - email-service + - cart-service + - cart + - user + - customer + - email + - notification + - payment + - product + - rbac + - supplier + - upload + - th + - kjhgf + restart: always + build: + context: ./nginx + dockerfile: Dockerfile.dev + ports: + - '4000:80' + healthcheck: + test: ["CMD-SHELL", "curl -f http://localhost:80/health || exit 1"] + interval: 30s + timeout: 10s + retries: 3 + start_period: 40s + rabbitmq: + image: rabbitmq:3.13-management + container_name: rabbitmq + ports: + - '5672:5672' + - '15672:15672' + healthcheck: + test: ["CMD", "rabbitmq-diagnostics", "ping"] + interval: 30s + retries: 5 + mongodb: + image: mongo + ports: + - '27017:27017' + restart: always + volumes: + - type: bind + source: ./data + target: /data/db + krakend: + image: devopsfaith/krakend:2.7 + ports: + - '9001:9001' + - '8090:8090' + volumes: + - ./krakend/:/etc/krakend/ + command: ['run','-d','-c','/etc/krakend/krakend.json'] \ No newline at end of file diff --git a/gateways/apps/testappd/krakend/krakend.json b/gateways/apps/testappd/krakend/krakend.json new file mode 100644 index 0000000..7038925 --- /dev/null +++ b/gateways/apps/testappd/krakend/krakend.json @@ -0,0 +1,354 @@ + +{ + "$schema": "https://www.krakend.io/schema/v2.5/krakend.json", + "version": 3, + "name": "Microservices-suite API Gateway", + "port": 9001, + "cache_ttl": "3600s", + "timeout": "300s", + "endpoints": [ + { + "@comment": "Check the health of all your APIs", + "endpoint": "/__suite_status", + "method": "GET", + "backend": [ + { + "host": ["http://hd:null"], + "url_pattern": "/", + "mapping": { + "message": "hd" + } + }, + + { + "host": ["http://customer-service:9000"], + "url_pattern": "/", + "mapping": { + "message": "customer-service" + } + }, + + { + "host": ["http://product-service:9002"], + "url_pattern": "/", + "mapping": { + "message": "product-service" + } + }, + + { + "host": ["http://rbac-service:9004"], + "url_pattern": "/", + "mapping": { + "message": "rbac-service" + } + }, + + { + "host": ["http://payment-service:9006"], + "url_pattern": "/", + "mapping": { + "message": "payment-service" + } + }, + + { + "host": ["http://notification-service:9007"], + "url_pattern": "/", + "mapping": { + "message": "notification-service" + } + }, + + { + "host": ["http://email-service:9008"], + "url_pattern": "/", + "mapping": { + "message": "email-service" + } + }, + + { + "host": ["http://cart-service:9009"], + "url_pattern": "/", + "mapping": { + "message": "cart-service" + } + }, + + { + "host": ["http://cart:9010"], + "url_pattern": "/", + "mapping": { + "message": "cart" + } + }, + + { + "host": ["http://user:9011"], + "url_pattern": "/", + "mapping": { + "message": "user" + } + }, + + { + "host": ["http://customer:9012"], + "url_pattern": "/", + "mapping": { + "message": "customer" + } + }, + + { + "host": ["http://email:9013"], + "url_pattern": "/", + "mapping": { + "message": "email" + } + }, + + { + "host": ["http://notification:9014"], + "url_pattern": "/", + "mapping": { + "message": "notification" + } + }, + + { + "host": ["http://payment:9015"], + "url_pattern": "/", + "mapping": { + "message": "payment" + } + }, + + { + "host": ["http://product:9016"], + "url_pattern": "/", + "mapping": { + "message": "product" + } + }, + + { + "host": ["http://rbac:9017"], + "url_pattern": "/", + "mapping": { + "message": "rbac" + } + }, + + { + "host": ["http://supplier:9018"], + "url_pattern": "/", + "mapping": { + "message": "supplier" + } + }, + + { + "host": ["http://upload:9019"], + "url_pattern": "/", + "mapping": { + "message": "upload" + } + }, + + { + "host": ["http://th:9020"], + "url_pattern": "/", + "mapping": { + "message": "th" + } + }, + + { + "host": ["http://kjhgf:9021"], + "url_pattern": "/", + "mapping": { + "message": "kjhgf" + } + }] + }, + { + "@comment": "Hit all API list endpoints simultaneously", + "endpoint": "/api/v1/", + "method": "GET", + "backend": [ + { + "host": ["http://hd:null"], + "url_pattern": "/api/v1/hds", + "mapping": { + "data": "hds" + } + }, + + { + "host": ["http://customer-service:9000"], + "url_pattern": "/api/v1/customer-services", + "mapping": { + "data": "customer-services" + } + }, + + { + "host": ["http://product-service:9002"], + "url_pattern": "/api/v1/product-services", + "mapping": { + "data": "product-services" + } + }, + + { + "host": ["http://rbac-service:9004"], + "url_pattern": "/api/v1/rbac-services", + "mapping": { + "data": "rbac-services" + } + }, + + { + "host": ["http://payment-service:9006"], + "url_pattern": "/api/v1/payment-services", + "mapping": { + "data": "payment-services" + } + }, + + { + "host": ["http://notification-service:9007"], + "url_pattern": "/api/v1/notification-services", + "mapping": { + "data": "notification-services" + } + }, + + { + "host": ["http://email-service:9008"], + "url_pattern": "/api/v1/email-services", + "mapping": { + "data": "email-services" + } + }, + + { + "host": ["http://cart-service:9009"], + "url_pattern": "/api/v1/cart-services", + "mapping": { + "data": "cart-services" + } + }, + + { + "host": ["http://cart:9010"], + "url_pattern": "/api/v1/carts", + "mapping": { + "data": "carts" + } + }, + + { + "host": ["http://user:9011"], + "url_pattern": "/api/v1/users", + "mapping": { + "data": "users" + } + }, + + { + "host": ["http://customer:9012"], + "url_pattern": "/api/v1/customers", + "mapping": { + "data": "customers" + } + }, + + { + "host": ["http://email:9013"], + "url_pattern": "/api/v1/emails", + "mapping": { + "data": "emails" + } + }, + + { + "host": ["http://notification:9014"], + "url_pattern": "/api/v1/notifications", + "mapping": { + "data": "notifications" + } + }, + + { + "host": ["http://payment:9015"], + "url_pattern": "/api/v1/payments", + "mapping": { + "data": "payments" + } + }, + + { + "host": ["http://product:9016"], + "url_pattern": "/api/v1/products", + "mapping": { + "data": "products" + } + }, + + { + "host": ["http://rbac:9017"], + "url_pattern": "/api/v1/rbacs", + "mapping": { + "data": "rbacs" + } + }, + + { + "host": ["http://supplier:9018"], + "url_pattern": "/api/v1/suppliers", + "mapping": { + "data": "suppliers" + } + }, + + { + "host": ["http://upload:9019"], + "url_pattern": "/api/v1/uploads", + "mapping": { + "data": "uploads" + } + }, + + { + "host": ["http://th:9020"], + "url_pattern": "/api/v1/ths", + "mapping": { + "data": "ths" + } + }, + + { + "host": ["http://kjhgf:9021"], + "url_pattern": "/api/v1/kjhgfs", + "mapping": { + "data": "kjhgfs" + } + }] + }, + { + "@comment": "Fetch all data from the hd service", + "endpoint": "/api/v1/hds", + "method": "GET", + "backend": [ + { + "host": ["http://hd:null"], + "url_pattern": "/api/v1/hds", + "mapping": { + "data": "hds" + } + }] + } + ] +} \ No newline at end of file diff --git a/gateways/apps/testappd/nginx/Dockerfile b/gateways/apps/testappd/nginx/Dockerfile new file mode 100644 index 0000000..ddf7281 --- /dev/null +++ b/gateways/apps/testappd/nginx/Dockerfile @@ -0,0 +1,3 @@ + +FROM nginx +COPY ./default.conf /etc/nginx/conf.d/default.conf \ No newline at end of file diff --git a/gateways/apps/testappd/nginx/Dockerfile.dev b/gateways/apps/testappd/nginx/Dockerfile.dev new file mode 100644 index 0000000..ddf7281 --- /dev/null +++ b/gateways/apps/testappd/nginx/Dockerfile.dev @@ -0,0 +1,3 @@ + +FROM nginx +COPY ./default.conf /etc/nginx/conf.d/default.conf \ No newline at end of file diff --git a/gateways/apps/testappd/nginx/default.conf b/gateways/apps/testappd/nginx/default.conf new file mode 100644 index 0000000..79f0686 --- /dev/null +++ b/gateways/apps/testappd/nginx/default.conf @@ -0,0 +1,246 @@ + + +upstream hd_upstream { + server hd:null; +} + +upstream customer-service_upstream { + server customer-service:9000; +} + +upstream product-service_upstream { + server product-service:9002; +} + +upstream rbac-service_upstream { + server rbac-service:9004; +} + +upstream payment-service_upstream { + server payment-service:9006; +} + +upstream notification-service_upstream { + server notification-service:9007; +} + +upstream email-service_upstream { + server email-service:9008; +} + +upstream cart-service_upstream { + server cart-service:9009; +} + +upstream cart_upstream { + server cart:9010; +} + +upstream user_upstream { + server user:9011; +} + +upstream customer_upstream { + server customer:9012; +} + +upstream email_upstream { + server email:9013; +} + +upstream notification_upstream { + server notification:9014; +} + +upstream payment_upstream { + server payment:9015; +} + +upstream product_upstream { + server product:9016; +} + +upstream rbac_upstream { + server rbac:9017; +} + +upstream supplier_upstream { + server supplier:9018; +} + +upstream upload_upstream { + server upload:9019; +} + +upstream th_upstream { + server th:9020; +} + +upstream kjhgf_upstream { + server kjhgf:9021; +} + +server { + listen 80; + + + location /api/v1/hds { + proxy_pass http://hd_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/customer-services { + proxy_pass http://customer-service_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/product-services { + proxy_pass http://product-service_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/rbac-services { + proxy_pass http://rbac-service_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/payment-services { + proxy_pass http://payment-service_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/notification-services { + proxy_pass http://notification-service_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/email-services { + proxy_pass http://email-service_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/cart-services { + proxy_pass http://cart-service_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/carts { + proxy_pass http://cart_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/users { + proxy_pass http://user_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/customers { + proxy_pass http://customer_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/emails { + proxy_pass http://email_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/notifications { + proxy_pass http://notification_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/payments { + proxy_pass http://payment_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/products { + proxy_pass http://product_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/rbacs { + proxy_pass http://rbac_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/suppliers { + proxy_pass http://supplier_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/uploads { + proxy_pass http://upload_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/ths { + proxy_pass http://th_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/kjhgfs { + proxy_pass http://kjhgf_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } +} \ No newline at end of file diff --git a/gateways/apps/testappfklaskd/docker-compose.dev.yml b/gateways/apps/testappfklaskd/docker-compose.dev.yml new file mode 100644 index 0000000..deb401b --- /dev/null +++ b/gateways/apps/testappfklaskd/docker-compose.dev.yml @@ -0,0 +1,325 @@ + +version: '3.8' +services: + + hd: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/hd + ports: + - "null:null" + volumes: + - /app/node_modules + - ../../../microservices/hd:/app + depends_on: + rabbitmq: + condition: service_healthy + + customer-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/customer-service + ports: + - "9000:9000" + volumes: + - /app/node_modules + - ../../../microservices/customer-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + product-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/product-service + ports: + - "9002:9002" + volumes: + - /app/node_modules + - ../../../microservices/product-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + rbac-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/rbac-service + ports: + - "9004:9004" + volumes: + - /app/node_modules + - ../../../microservices/rbac-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + payment-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/payment-service + ports: + - "9006:9006" + volumes: + - /app/node_modules + - ../../../microservices/payment-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + notification-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/notification-service + ports: + - "9007:9007" + volumes: + - /app/node_modules + - ../../../microservices/notification-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + email-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/email-service + ports: + - "9008:9008" + volumes: + - /app/node_modules + - ../../../microservices/email-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + cart-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/cart-service + ports: + - "9009:9009" + volumes: + - /app/node_modules + - ../../../microservices/cart-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + cart: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/cart + ports: + - "9010:9010" + volumes: + - /app/node_modules + - ../../../microservices/cart:/app + depends_on: + rabbitmq: + condition: service_healthy + + user: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/user + ports: + - "9011:9011" + volumes: + - /app/node_modules + - ../../../microservices/user:/app + depends_on: + rabbitmq: + condition: service_healthy + + customer: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/customer + ports: + - "9012:9012" + volumes: + - /app/node_modules + - ../../../microservices/customer:/app + depends_on: + rabbitmq: + condition: service_healthy + + email: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/email + ports: + - "9013:9013" + volumes: + - /app/node_modules + - ../../../microservices/email:/app + depends_on: + rabbitmq: + condition: service_healthy + + notification: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/notification + ports: + - "9014:9014" + volumes: + - /app/node_modules + - ../../../microservices/notification:/app + depends_on: + rabbitmq: + condition: service_healthy + + payment: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/payment + ports: + - "9015:9015" + volumes: + - /app/node_modules + - ../../../microservices/payment:/app + depends_on: + rabbitmq: + condition: service_healthy + + product: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/product + ports: + - "9016:9016" + volumes: + - /app/node_modules + - ../../../microservices/product:/app + depends_on: + rabbitmq: + condition: service_healthy + + rbac: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/rbac + ports: + - "9017:9017" + volumes: + - /app/node_modules + - ../../../microservices/rbac:/app + depends_on: + rabbitmq: + condition: service_healthy + + supplier: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/supplier + ports: + - "9018:9018" + volumes: + - /app/node_modules + - ../../../microservices/supplier:/app + depends_on: + rabbitmq: + condition: service_healthy + + upload: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/upload + ports: + - "9019:9019" + volumes: + - /app/node_modules + - ../../../microservices/upload:/app + depends_on: + rabbitmq: + condition: service_healthy + + th: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/th + ports: + - "9020:9020" + volumes: + - /app/node_modules + - ../../../microservices/th:/app + depends_on: + rabbitmq: + condition: service_healthy + + kjhgf: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/kjhgf + ports: + - "9021:9021" + volumes: + - /app/node_modules + - ../../../microservices/kjhgf:/app + depends_on: + rabbitmq: + condition: service_healthy + + nginx: + depends_on: + - hd + - customer-service + - product-service + - rbac-service + - payment-service + - notification-service + - email-service + - cart-service + - cart + - user + - customer + - email + - notification + - payment + - product + - rbac + - supplier + - upload + - th + - kjhgf + restart: always + build: + context: ./nginx + dockerfile: Dockerfile.dev + ports: + - '4000:80' + healthcheck: + test: ["CMD-SHELL", "curl -f http://localhost:80/health || exit 1"] + interval: 30s + timeout: 10s + retries: 3 + start_period: 40s + rabbitmq: + image: rabbitmq:3.13-management + container_name: rabbitmq + ports: + - '5672:5672' + - '15672:15672' + healthcheck: + test: ["CMD", "rabbitmq-diagnostics", "ping"] + interval: 30s + retries: 5 + mongodb: + image: mongo + ports: + - '27017:27017' + restart: always + volumes: + - type: bind + source: ./data + target: /data/db + krakend: + image: devopsfaith/krakend:2.7-watch + ports: + - '9001:9001' + - '8090:8090' + volumes: + - ./krakend/:/etc/krakend/ + command: ['run','-d','-c','/etc/krakend/krakend.json'] \ No newline at end of file diff --git a/gateways/apps/testappfklaskd/docker-compose.yml b/gateways/apps/testappfklaskd/docker-compose.yml new file mode 100644 index 0000000..be77908 --- /dev/null +++ b/gateways/apps/testappfklaskd/docker-compose.yml @@ -0,0 +1,325 @@ + +version: '3.8' +services: + + hd: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/hd + ports: + - "null:null" + volumes: + - /app/node_modules + - ../../../microservices/hd:/app + depends_on: + rabbitmq: + condition: service_healthy + + customer-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/customer-service + ports: + - "9000:9000" + volumes: + - /app/node_modules + - ../../../microservices/customer-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + product-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/product-service + ports: + - "9002:9002" + volumes: + - /app/node_modules + - ../../../microservices/product-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + rbac-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/rbac-service + ports: + - "9004:9004" + volumes: + - /app/node_modules + - ../../../microservices/rbac-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + payment-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/payment-service + ports: + - "9006:9006" + volumes: + - /app/node_modules + - ../../../microservices/payment-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + notification-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/notification-service + ports: + - "9007:9007" + volumes: + - /app/node_modules + - ../../../microservices/notification-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + email-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/email-service + ports: + - "9008:9008" + volumes: + - /app/node_modules + - ../../../microservices/email-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + cart-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/cart-service + ports: + - "9009:9009" + volumes: + - /app/node_modules + - ../../../microservices/cart-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + cart: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/cart + ports: + - "9010:9010" + volumes: + - /app/node_modules + - ../../../microservices/cart:/app + depends_on: + rabbitmq: + condition: service_healthy + + user: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/user + ports: + - "9011:9011" + volumes: + - /app/node_modules + - ../../../microservices/user:/app + depends_on: + rabbitmq: + condition: service_healthy + + customer: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/customer + ports: + - "9012:9012" + volumes: + - /app/node_modules + - ../../../microservices/customer:/app + depends_on: + rabbitmq: + condition: service_healthy + + email: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/email + ports: + - "9013:9013" + volumes: + - /app/node_modules + - ../../../microservices/email:/app + depends_on: + rabbitmq: + condition: service_healthy + + notification: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/notification + ports: + - "9014:9014" + volumes: + - /app/node_modules + - ../../../microservices/notification:/app + depends_on: + rabbitmq: + condition: service_healthy + + payment: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/payment + ports: + - "9015:9015" + volumes: + - /app/node_modules + - ../../../microservices/payment:/app + depends_on: + rabbitmq: + condition: service_healthy + + product: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/product + ports: + - "9016:9016" + volumes: + - /app/node_modules + - ../../../microservices/product:/app + depends_on: + rabbitmq: + condition: service_healthy + + rbac: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/rbac + ports: + - "9017:9017" + volumes: + - /app/node_modules + - ../../../microservices/rbac:/app + depends_on: + rabbitmq: + condition: service_healthy + + supplier: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/supplier + ports: + - "9018:9018" + volumes: + - /app/node_modules + - ../../../microservices/supplier:/app + depends_on: + rabbitmq: + condition: service_healthy + + upload: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/upload + ports: + - "9019:9019" + volumes: + - /app/node_modules + - ../../../microservices/upload:/app + depends_on: + rabbitmq: + condition: service_healthy + + th: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/th + ports: + - "9020:9020" + volumes: + - /app/node_modules + - ../../../microservices/th:/app + depends_on: + rabbitmq: + condition: service_healthy + + kjhgf: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/kjhgf + ports: + - "9021:9021" + volumes: + - /app/node_modules + - ../../../microservices/kjhgf:/app + depends_on: + rabbitmq: + condition: service_healthy + + nginx: + depends_on: + - hd + - customer-service + - product-service + - rbac-service + - payment-service + - notification-service + - email-service + - cart-service + - cart + - user + - customer + - email + - notification + - payment + - product + - rbac + - supplier + - upload + - th + - kjhgf + restart: always + build: + context: ./nginx + dockerfile: Dockerfile.dev + ports: + - '4000:80' + healthcheck: + test: ["CMD-SHELL", "curl -f http://localhost:80/health || exit 1"] + interval: 30s + timeout: 10s + retries: 3 + start_period: 40s + rabbitmq: + image: rabbitmq:3.13-management + container_name: rabbitmq + ports: + - '5672:5672' + - '15672:15672' + healthcheck: + test: ["CMD", "rabbitmq-diagnostics", "ping"] + interval: 30s + retries: 5 + mongodb: + image: mongo + ports: + - '27017:27017' + restart: always + volumes: + - type: bind + source: ./data + target: /data/db + krakend: + image: devopsfaith/krakend:2.7 + ports: + - '9001:9001' + - '8090:8090' + volumes: + - ./krakend/:/etc/krakend/ + command: ['run','-d','-c','/etc/krakend/krakend.json'] \ No newline at end of file diff --git a/gateways/apps/testappfklaskd/krakend/krakend.json b/gateways/apps/testappfklaskd/krakend/krakend.json new file mode 100644 index 0000000..7038925 --- /dev/null +++ b/gateways/apps/testappfklaskd/krakend/krakend.json @@ -0,0 +1,354 @@ + +{ + "$schema": "https://www.krakend.io/schema/v2.5/krakend.json", + "version": 3, + "name": "Microservices-suite API Gateway", + "port": 9001, + "cache_ttl": "3600s", + "timeout": "300s", + "endpoints": [ + { + "@comment": "Check the health of all your APIs", + "endpoint": "/__suite_status", + "method": "GET", + "backend": [ + { + "host": ["http://hd:null"], + "url_pattern": "/", + "mapping": { + "message": "hd" + } + }, + + { + "host": ["http://customer-service:9000"], + "url_pattern": "/", + "mapping": { + "message": "customer-service" + } + }, + + { + "host": ["http://product-service:9002"], + "url_pattern": "/", + "mapping": { + "message": "product-service" + } + }, + + { + "host": ["http://rbac-service:9004"], + "url_pattern": "/", + "mapping": { + "message": "rbac-service" + } + }, + + { + "host": ["http://payment-service:9006"], + "url_pattern": "/", + "mapping": { + "message": "payment-service" + } + }, + + { + "host": ["http://notification-service:9007"], + "url_pattern": "/", + "mapping": { + "message": "notification-service" + } + }, + + { + "host": ["http://email-service:9008"], + "url_pattern": "/", + "mapping": { + "message": "email-service" + } + }, + + { + "host": ["http://cart-service:9009"], + "url_pattern": "/", + "mapping": { + "message": "cart-service" + } + }, + + { + "host": ["http://cart:9010"], + "url_pattern": "/", + "mapping": { + "message": "cart" + } + }, + + { + "host": ["http://user:9011"], + "url_pattern": "/", + "mapping": { + "message": "user" + } + }, + + { + "host": ["http://customer:9012"], + "url_pattern": "/", + "mapping": { + "message": "customer" + } + }, + + { + "host": ["http://email:9013"], + "url_pattern": "/", + "mapping": { + "message": "email" + } + }, + + { + "host": ["http://notification:9014"], + "url_pattern": "/", + "mapping": { + "message": "notification" + } + }, + + { + "host": ["http://payment:9015"], + "url_pattern": "/", + "mapping": { + "message": "payment" + } + }, + + { + "host": ["http://product:9016"], + "url_pattern": "/", + "mapping": { + "message": "product" + } + }, + + { + "host": ["http://rbac:9017"], + "url_pattern": "/", + "mapping": { + "message": "rbac" + } + }, + + { + "host": ["http://supplier:9018"], + "url_pattern": "/", + "mapping": { + "message": "supplier" + } + }, + + { + "host": ["http://upload:9019"], + "url_pattern": "/", + "mapping": { + "message": "upload" + } + }, + + { + "host": ["http://th:9020"], + "url_pattern": "/", + "mapping": { + "message": "th" + } + }, + + { + "host": ["http://kjhgf:9021"], + "url_pattern": "/", + "mapping": { + "message": "kjhgf" + } + }] + }, + { + "@comment": "Hit all API list endpoints simultaneously", + "endpoint": "/api/v1/", + "method": "GET", + "backend": [ + { + "host": ["http://hd:null"], + "url_pattern": "/api/v1/hds", + "mapping": { + "data": "hds" + } + }, + + { + "host": ["http://customer-service:9000"], + "url_pattern": "/api/v1/customer-services", + "mapping": { + "data": "customer-services" + } + }, + + { + "host": ["http://product-service:9002"], + "url_pattern": "/api/v1/product-services", + "mapping": { + "data": "product-services" + } + }, + + { + "host": ["http://rbac-service:9004"], + "url_pattern": "/api/v1/rbac-services", + "mapping": { + "data": "rbac-services" + } + }, + + { + "host": ["http://payment-service:9006"], + "url_pattern": "/api/v1/payment-services", + "mapping": { + "data": "payment-services" + } + }, + + { + "host": ["http://notification-service:9007"], + "url_pattern": "/api/v1/notification-services", + "mapping": { + "data": "notification-services" + } + }, + + { + "host": ["http://email-service:9008"], + "url_pattern": "/api/v1/email-services", + "mapping": { + "data": "email-services" + } + }, + + { + "host": ["http://cart-service:9009"], + "url_pattern": "/api/v1/cart-services", + "mapping": { + "data": "cart-services" + } + }, + + { + "host": ["http://cart:9010"], + "url_pattern": "/api/v1/carts", + "mapping": { + "data": "carts" + } + }, + + { + "host": ["http://user:9011"], + "url_pattern": "/api/v1/users", + "mapping": { + "data": "users" + } + }, + + { + "host": ["http://customer:9012"], + "url_pattern": "/api/v1/customers", + "mapping": { + "data": "customers" + } + }, + + { + "host": ["http://email:9013"], + "url_pattern": "/api/v1/emails", + "mapping": { + "data": "emails" + } + }, + + { + "host": ["http://notification:9014"], + "url_pattern": "/api/v1/notifications", + "mapping": { + "data": "notifications" + } + }, + + { + "host": ["http://payment:9015"], + "url_pattern": "/api/v1/payments", + "mapping": { + "data": "payments" + } + }, + + { + "host": ["http://product:9016"], + "url_pattern": "/api/v1/products", + "mapping": { + "data": "products" + } + }, + + { + "host": ["http://rbac:9017"], + "url_pattern": "/api/v1/rbacs", + "mapping": { + "data": "rbacs" + } + }, + + { + "host": ["http://supplier:9018"], + "url_pattern": "/api/v1/suppliers", + "mapping": { + "data": "suppliers" + } + }, + + { + "host": ["http://upload:9019"], + "url_pattern": "/api/v1/uploads", + "mapping": { + "data": "uploads" + } + }, + + { + "host": ["http://th:9020"], + "url_pattern": "/api/v1/ths", + "mapping": { + "data": "ths" + } + }, + + { + "host": ["http://kjhgf:9021"], + "url_pattern": "/api/v1/kjhgfs", + "mapping": { + "data": "kjhgfs" + } + }] + }, + { + "@comment": "Fetch all data from the hd service", + "endpoint": "/api/v1/hds", + "method": "GET", + "backend": [ + { + "host": ["http://hd:null"], + "url_pattern": "/api/v1/hds", + "mapping": { + "data": "hds" + } + }] + } + ] +} \ No newline at end of file diff --git a/gateways/apps/testappfklaskd/nginx/Dockerfile b/gateways/apps/testappfklaskd/nginx/Dockerfile new file mode 100644 index 0000000..ddf7281 --- /dev/null +++ b/gateways/apps/testappfklaskd/nginx/Dockerfile @@ -0,0 +1,3 @@ + +FROM nginx +COPY ./default.conf /etc/nginx/conf.d/default.conf \ No newline at end of file diff --git a/gateways/apps/testappfklaskd/nginx/Dockerfile.dev b/gateways/apps/testappfklaskd/nginx/Dockerfile.dev new file mode 100644 index 0000000..ddf7281 --- /dev/null +++ b/gateways/apps/testappfklaskd/nginx/Dockerfile.dev @@ -0,0 +1,3 @@ + +FROM nginx +COPY ./default.conf /etc/nginx/conf.d/default.conf \ No newline at end of file diff --git a/gateways/apps/testappfklaskd/nginx/default.conf b/gateways/apps/testappfklaskd/nginx/default.conf new file mode 100644 index 0000000..79f0686 --- /dev/null +++ b/gateways/apps/testappfklaskd/nginx/default.conf @@ -0,0 +1,246 @@ + + +upstream hd_upstream { + server hd:null; +} + +upstream customer-service_upstream { + server customer-service:9000; +} + +upstream product-service_upstream { + server product-service:9002; +} + +upstream rbac-service_upstream { + server rbac-service:9004; +} + +upstream payment-service_upstream { + server payment-service:9006; +} + +upstream notification-service_upstream { + server notification-service:9007; +} + +upstream email-service_upstream { + server email-service:9008; +} + +upstream cart-service_upstream { + server cart-service:9009; +} + +upstream cart_upstream { + server cart:9010; +} + +upstream user_upstream { + server user:9011; +} + +upstream customer_upstream { + server customer:9012; +} + +upstream email_upstream { + server email:9013; +} + +upstream notification_upstream { + server notification:9014; +} + +upstream payment_upstream { + server payment:9015; +} + +upstream product_upstream { + server product:9016; +} + +upstream rbac_upstream { + server rbac:9017; +} + +upstream supplier_upstream { + server supplier:9018; +} + +upstream upload_upstream { + server upload:9019; +} + +upstream th_upstream { + server th:9020; +} + +upstream kjhgf_upstream { + server kjhgf:9021; +} + +server { + listen 80; + + + location /api/v1/hds { + proxy_pass http://hd_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/customer-services { + proxy_pass http://customer-service_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/product-services { + proxy_pass http://product-service_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/rbac-services { + proxy_pass http://rbac-service_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/payment-services { + proxy_pass http://payment-service_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/notification-services { + proxy_pass http://notification-service_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/email-services { + proxy_pass http://email-service_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/cart-services { + proxy_pass http://cart-service_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/carts { + proxy_pass http://cart_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/users { + proxy_pass http://user_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/customers { + proxy_pass http://customer_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/emails { + proxy_pass http://email_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/notifications { + proxy_pass http://notification_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/payments { + proxy_pass http://payment_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/products { + proxy_pass http://product_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/rbacs { + proxy_pass http://rbac_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/suppliers { + proxy_pass http://supplier_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/uploads { + proxy_pass http://upload_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/ths { + proxy_pass http://th_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/kjhgfs { + proxy_pass http://kjhgf_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } +} \ No newline at end of file diff --git a/gateways/apps/testasppp/docker-compose.dev.yml b/gateways/apps/testasppp/docker-compose.dev.yml new file mode 100644 index 0000000..deb401b --- /dev/null +++ b/gateways/apps/testasppp/docker-compose.dev.yml @@ -0,0 +1,325 @@ + +version: '3.8' +services: + + hd: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/hd + ports: + - "null:null" + volumes: + - /app/node_modules + - ../../../microservices/hd:/app + depends_on: + rabbitmq: + condition: service_healthy + + customer-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/customer-service + ports: + - "9000:9000" + volumes: + - /app/node_modules + - ../../../microservices/customer-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + product-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/product-service + ports: + - "9002:9002" + volumes: + - /app/node_modules + - ../../../microservices/product-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + rbac-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/rbac-service + ports: + - "9004:9004" + volumes: + - /app/node_modules + - ../../../microservices/rbac-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + payment-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/payment-service + ports: + - "9006:9006" + volumes: + - /app/node_modules + - ../../../microservices/payment-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + notification-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/notification-service + ports: + - "9007:9007" + volumes: + - /app/node_modules + - ../../../microservices/notification-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + email-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/email-service + ports: + - "9008:9008" + volumes: + - /app/node_modules + - ../../../microservices/email-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + cart-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/cart-service + ports: + - "9009:9009" + volumes: + - /app/node_modules + - ../../../microservices/cart-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + cart: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/cart + ports: + - "9010:9010" + volumes: + - /app/node_modules + - ../../../microservices/cart:/app + depends_on: + rabbitmq: + condition: service_healthy + + user: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/user + ports: + - "9011:9011" + volumes: + - /app/node_modules + - ../../../microservices/user:/app + depends_on: + rabbitmq: + condition: service_healthy + + customer: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/customer + ports: + - "9012:9012" + volumes: + - /app/node_modules + - ../../../microservices/customer:/app + depends_on: + rabbitmq: + condition: service_healthy + + email: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/email + ports: + - "9013:9013" + volumes: + - /app/node_modules + - ../../../microservices/email:/app + depends_on: + rabbitmq: + condition: service_healthy + + notification: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/notification + ports: + - "9014:9014" + volumes: + - /app/node_modules + - ../../../microservices/notification:/app + depends_on: + rabbitmq: + condition: service_healthy + + payment: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/payment + ports: + - "9015:9015" + volumes: + - /app/node_modules + - ../../../microservices/payment:/app + depends_on: + rabbitmq: + condition: service_healthy + + product: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/product + ports: + - "9016:9016" + volumes: + - /app/node_modules + - ../../../microservices/product:/app + depends_on: + rabbitmq: + condition: service_healthy + + rbac: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/rbac + ports: + - "9017:9017" + volumes: + - /app/node_modules + - ../../../microservices/rbac:/app + depends_on: + rabbitmq: + condition: service_healthy + + supplier: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/supplier + ports: + - "9018:9018" + volumes: + - /app/node_modules + - ../../../microservices/supplier:/app + depends_on: + rabbitmq: + condition: service_healthy + + upload: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/upload + ports: + - "9019:9019" + volumes: + - /app/node_modules + - ../../../microservices/upload:/app + depends_on: + rabbitmq: + condition: service_healthy + + th: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/th + ports: + - "9020:9020" + volumes: + - /app/node_modules + - ../../../microservices/th:/app + depends_on: + rabbitmq: + condition: service_healthy + + kjhgf: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/kjhgf + ports: + - "9021:9021" + volumes: + - /app/node_modules + - ../../../microservices/kjhgf:/app + depends_on: + rabbitmq: + condition: service_healthy + + nginx: + depends_on: + - hd + - customer-service + - product-service + - rbac-service + - payment-service + - notification-service + - email-service + - cart-service + - cart + - user + - customer + - email + - notification + - payment + - product + - rbac + - supplier + - upload + - th + - kjhgf + restart: always + build: + context: ./nginx + dockerfile: Dockerfile.dev + ports: + - '4000:80' + healthcheck: + test: ["CMD-SHELL", "curl -f http://localhost:80/health || exit 1"] + interval: 30s + timeout: 10s + retries: 3 + start_period: 40s + rabbitmq: + image: rabbitmq:3.13-management + container_name: rabbitmq + ports: + - '5672:5672' + - '15672:15672' + healthcheck: + test: ["CMD", "rabbitmq-diagnostics", "ping"] + interval: 30s + retries: 5 + mongodb: + image: mongo + ports: + - '27017:27017' + restart: always + volumes: + - type: bind + source: ./data + target: /data/db + krakend: + image: devopsfaith/krakend:2.7-watch + ports: + - '9001:9001' + - '8090:8090' + volumes: + - ./krakend/:/etc/krakend/ + command: ['run','-d','-c','/etc/krakend/krakend.json'] \ No newline at end of file diff --git a/gateways/apps/testasppp/docker-compose.yml b/gateways/apps/testasppp/docker-compose.yml new file mode 100644 index 0000000..be77908 --- /dev/null +++ b/gateways/apps/testasppp/docker-compose.yml @@ -0,0 +1,325 @@ + +version: '3.8' +services: + + hd: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/hd + ports: + - "null:null" + volumes: + - /app/node_modules + - ../../../microservices/hd:/app + depends_on: + rabbitmq: + condition: service_healthy + + customer-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/customer-service + ports: + - "9000:9000" + volumes: + - /app/node_modules + - ../../../microservices/customer-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + product-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/product-service + ports: + - "9002:9002" + volumes: + - /app/node_modules + - ../../../microservices/product-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + rbac-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/rbac-service + ports: + - "9004:9004" + volumes: + - /app/node_modules + - ../../../microservices/rbac-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + payment-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/payment-service + ports: + - "9006:9006" + volumes: + - /app/node_modules + - ../../../microservices/payment-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + notification-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/notification-service + ports: + - "9007:9007" + volumes: + - /app/node_modules + - ../../../microservices/notification-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + email-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/email-service + ports: + - "9008:9008" + volumes: + - /app/node_modules + - ../../../microservices/email-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + cart-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/cart-service + ports: + - "9009:9009" + volumes: + - /app/node_modules + - ../../../microservices/cart-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + cart: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/cart + ports: + - "9010:9010" + volumes: + - /app/node_modules + - ../../../microservices/cart:/app + depends_on: + rabbitmq: + condition: service_healthy + + user: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/user + ports: + - "9011:9011" + volumes: + - /app/node_modules + - ../../../microservices/user:/app + depends_on: + rabbitmq: + condition: service_healthy + + customer: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/customer + ports: + - "9012:9012" + volumes: + - /app/node_modules + - ../../../microservices/customer:/app + depends_on: + rabbitmq: + condition: service_healthy + + email: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/email + ports: + - "9013:9013" + volumes: + - /app/node_modules + - ../../../microservices/email:/app + depends_on: + rabbitmq: + condition: service_healthy + + notification: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/notification + ports: + - "9014:9014" + volumes: + - /app/node_modules + - ../../../microservices/notification:/app + depends_on: + rabbitmq: + condition: service_healthy + + payment: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/payment + ports: + - "9015:9015" + volumes: + - /app/node_modules + - ../../../microservices/payment:/app + depends_on: + rabbitmq: + condition: service_healthy + + product: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/product + ports: + - "9016:9016" + volumes: + - /app/node_modules + - ../../../microservices/product:/app + depends_on: + rabbitmq: + condition: service_healthy + + rbac: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/rbac + ports: + - "9017:9017" + volumes: + - /app/node_modules + - ../../../microservices/rbac:/app + depends_on: + rabbitmq: + condition: service_healthy + + supplier: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/supplier + ports: + - "9018:9018" + volumes: + - /app/node_modules + - ../../../microservices/supplier:/app + depends_on: + rabbitmq: + condition: service_healthy + + upload: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/upload + ports: + - "9019:9019" + volumes: + - /app/node_modules + - ../../../microservices/upload:/app + depends_on: + rabbitmq: + condition: service_healthy + + th: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/th + ports: + - "9020:9020" + volumes: + - /app/node_modules + - ../../../microservices/th:/app + depends_on: + rabbitmq: + condition: service_healthy + + kjhgf: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/kjhgf + ports: + - "9021:9021" + volumes: + - /app/node_modules + - ../../../microservices/kjhgf:/app + depends_on: + rabbitmq: + condition: service_healthy + + nginx: + depends_on: + - hd + - customer-service + - product-service + - rbac-service + - payment-service + - notification-service + - email-service + - cart-service + - cart + - user + - customer + - email + - notification + - payment + - product + - rbac + - supplier + - upload + - th + - kjhgf + restart: always + build: + context: ./nginx + dockerfile: Dockerfile.dev + ports: + - '4000:80' + healthcheck: + test: ["CMD-SHELL", "curl -f http://localhost:80/health || exit 1"] + interval: 30s + timeout: 10s + retries: 3 + start_period: 40s + rabbitmq: + image: rabbitmq:3.13-management + container_name: rabbitmq + ports: + - '5672:5672' + - '15672:15672' + healthcheck: + test: ["CMD", "rabbitmq-diagnostics", "ping"] + interval: 30s + retries: 5 + mongodb: + image: mongo + ports: + - '27017:27017' + restart: always + volumes: + - type: bind + source: ./data + target: /data/db + krakend: + image: devopsfaith/krakend:2.7 + ports: + - '9001:9001' + - '8090:8090' + volumes: + - ./krakend/:/etc/krakend/ + command: ['run','-d','-c','/etc/krakend/krakend.json'] \ No newline at end of file diff --git a/gateways/apps/testasppp/krakend/krakend.json b/gateways/apps/testasppp/krakend/krakend.json new file mode 100644 index 0000000..7038925 --- /dev/null +++ b/gateways/apps/testasppp/krakend/krakend.json @@ -0,0 +1,354 @@ + +{ + "$schema": "https://www.krakend.io/schema/v2.5/krakend.json", + "version": 3, + "name": "Microservices-suite API Gateway", + "port": 9001, + "cache_ttl": "3600s", + "timeout": "300s", + "endpoints": [ + { + "@comment": "Check the health of all your APIs", + "endpoint": "/__suite_status", + "method": "GET", + "backend": [ + { + "host": ["http://hd:null"], + "url_pattern": "/", + "mapping": { + "message": "hd" + } + }, + + { + "host": ["http://customer-service:9000"], + "url_pattern": "/", + "mapping": { + "message": "customer-service" + } + }, + + { + "host": ["http://product-service:9002"], + "url_pattern": "/", + "mapping": { + "message": "product-service" + } + }, + + { + "host": ["http://rbac-service:9004"], + "url_pattern": "/", + "mapping": { + "message": "rbac-service" + } + }, + + { + "host": ["http://payment-service:9006"], + "url_pattern": "/", + "mapping": { + "message": "payment-service" + } + }, + + { + "host": ["http://notification-service:9007"], + "url_pattern": "/", + "mapping": { + "message": "notification-service" + } + }, + + { + "host": ["http://email-service:9008"], + "url_pattern": "/", + "mapping": { + "message": "email-service" + } + }, + + { + "host": ["http://cart-service:9009"], + "url_pattern": "/", + "mapping": { + "message": "cart-service" + } + }, + + { + "host": ["http://cart:9010"], + "url_pattern": "/", + "mapping": { + "message": "cart" + } + }, + + { + "host": ["http://user:9011"], + "url_pattern": "/", + "mapping": { + "message": "user" + } + }, + + { + "host": ["http://customer:9012"], + "url_pattern": "/", + "mapping": { + "message": "customer" + } + }, + + { + "host": ["http://email:9013"], + "url_pattern": "/", + "mapping": { + "message": "email" + } + }, + + { + "host": ["http://notification:9014"], + "url_pattern": "/", + "mapping": { + "message": "notification" + } + }, + + { + "host": ["http://payment:9015"], + "url_pattern": "/", + "mapping": { + "message": "payment" + } + }, + + { + "host": ["http://product:9016"], + "url_pattern": "/", + "mapping": { + "message": "product" + } + }, + + { + "host": ["http://rbac:9017"], + "url_pattern": "/", + "mapping": { + "message": "rbac" + } + }, + + { + "host": ["http://supplier:9018"], + "url_pattern": "/", + "mapping": { + "message": "supplier" + } + }, + + { + "host": ["http://upload:9019"], + "url_pattern": "/", + "mapping": { + "message": "upload" + } + }, + + { + "host": ["http://th:9020"], + "url_pattern": "/", + "mapping": { + "message": "th" + } + }, + + { + "host": ["http://kjhgf:9021"], + "url_pattern": "/", + "mapping": { + "message": "kjhgf" + } + }] + }, + { + "@comment": "Hit all API list endpoints simultaneously", + "endpoint": "/api/v1/", + "method": "GET", + "backend": [ + { + "host": ["http://hd:null"], + "url_pattern": "/api/v1/hds", + "mapping": { + "data": "hds" + } + }, + + { + "host": ["http://customer-service:9000"], + "url_pattern": "/api/v1/customer-services", + "mapping": { + "data": "customer-services" + } + }, + + { + "host": ["http://product-service:9002"], + "url_pattern": "/api/v1/product-services", + "mapping": { + "data": "product-services" + } + }, + + { + "host": ["http://rbac-service:9004"], + "url_pattern": "/api/v1/rbac-services", + "mapping": { + "data": "rbac-services" + } + }, + + { + "host": ["http://payment-service:9006"], + "url_pattern": "/api/v1/payment-services", + "mapping": { + "data": "payment-services" + } + }, + + { + "host": ["http://notification-service:9007"], + "url_pattern": "/api/v1/notification-services", + "mapping": { + "data": "notification-services" + } + }, + + { + "host": ["http://email-service:9008"], + "url_pattern": "/api/v1/email-services", + "mapping": { + "data": "email-services" + } + }, + + { + "host": ["http://cart-service:9009"], + "url_pattern": "/api/v1/cart-services", + "mapping": { + "data": "cart-services" + } + }, + + { + "host": ["http://cart:9010"], + "url_pattern": "/api/v1/carts", + "mapping": { + "data": "carts" + } + }, + + { + "host": ["http://user:9011"], + "url_pattern": "/api/v1/users", + "mapping": { + "data": "users" + } + }, + + { + "host": ["http://customer:9012"], + "url_pattern": "/api/v1/customers", + "mapping": { + "data": "customers" + } + }, + + { + "host": ["http://email:9013"], + "url_pattern": "/api/v1/emails", + "mapping": { + "data": "emails" + } + }, + + { + "host": ["http://notification:9014"], + "url_pattern": "/api/v1/notifications", + "mapping": { + "data": "notifications" + } + }, + + { + "host": ["http://payment:9015"], + "url_pattern": "/api/v1/payments", + "mapping": { + "data": "payments" + } + }, + + { + "host": ["http://product:9016"], + "url_pattern": "/api/v1/products", + "mapping": { + "data": "products" + } + }, + + { + "host": ["http://rbac:9017"], + "url_pattern": "/api/v1/rbacs", + "mapping": { + "data": "rbacs" + } + }, + + { + "host": ["http://supplier:9018"], + "url_pattern": "/api/v1/suppliers", + "mapping": { + "data": "suppliers" + } + }, + + { + "host": ["http://upload:9019"], + "url_pattern": "/api/v1/uploads", + "mapping": { + "data": "uploads" + } + }, + + { + "host": ["http://th:9020"], + "url_pattern": "/api/v1/ths", + "mapping": { + "data": "ths" + } + }, + + { + "host": ["http://kjhgf:9021"], + "url_pattern": "/api/v1/kjhgfs", + "mapping": { + "data": "kjhgfs" + } + }] + }, + { + "@comment": "Fetch all data from the hd service", + "endpoint": "/api/v1/hds", + "method": "GET", + "backend": [ + { + "host": ["http://hd:null"], + "url_pattern": "/api/v1/hds", + "mapping": { + "data": "hds" + } + }] + } + ] +} \ No newline at end of file diff --git a/gateways/apps/testasppp/nginx/Dockerfile b/gateways/apps/testasppp/nginx/Dockerfile new file mode 100644 index 0000000..ddf7281 --- /dev/null +++ b/gateways/apps/testasppp/nginx/Dockerfile @@ -0,0 +1,3 @@ + +FROM nginx +COPY ./default.conf /etc/nginx/conf.d/default.conf \ No newline at end of file diff --git a/gateways/apps/testasppp/nginx/Dockerfile.dev b/gateways/apps/testasppp/nginx/Dockerfile.dev new file mode 100644 index 0000000..ddf7281 --- /dev/null +++ b/gateways/apps/testasppp/nginx/Dockerfile.dev @@ -0,0 +1,3 @@ + +FROM nginx +COPY ./default.conf /etc/nginx/conf.d/default.conf \ No newline at end of file diff --git a/gateways/apps/testasppp/nginx/default.conf b/gateways/apps/testasppp/nginx/default.conf new file mode 100644 index 0000000..79f0686 --- /dev/null +++ b/gateways/apps/testasppp/nginx/default.conf @@ -0,0 +1,246 @@ + + +upstream hd_upstream { + server hd:null; +} + +upstream customer-service_upstream { + server customer-service:9000; +} + +upstream product-service_upstream { + server product-service:9002; +} + +upstream rbac-service_upstream { + server rbac-service:9004; +} + +upstream payment-service_upstream { + server payment-service:9006; +} + +upstream notification-service_upstream { + server notification-service:9007; +} + +upstream email-service_upstream { + server email-service:9008; +} + +upstream cart-service_upstream { + server cart-service:9009; +} + +upstream cart_upstream { + server cart:9010; +} + +upstream user_upstream { + server user:9011; +} + +upstream customer_upstream { + server customer:9012; +} + +upstream email_upstream { + server email:9013; +} + +upstream notification_upstream { + server notification:9014; +} + +upstream payment_upstream { + server payment:9015; +} + +upstream product_upstream { + server product:9016; +} + +upstream rbac_upstream { + server rbac:9017; +} + +upstream supplier_upstream { + server supplier:9018; +} + +upstream upload_upstream { + server upload:9019; +} + +upstream th_upstream { + server th:9020; +} + +upstream kjhgf_upstream { + server kjhgf:9021; +} + +server { + listen 80; + + + location /api/v1/hds { + proxy_pass http://hd_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/customer-services { + proxy_pass http://customer-service_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/product-services { + proxy_pass http://product-service_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/rbac-services { + proxy_pass http://rbac-service_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/payment-services { + proxy_pass http://payment-service_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/notification-services { + proxy_pass http://notification-service_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/email-services { + proxy_pass http://email-service_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/cart-services { + proxy_pass http://cart-service_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/carts { + proxy_pass http://cart_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/users { + proxy_pass http://user_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/customers { + proxy_pass http://customer_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/emails { + proxy_pass http://email_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/notifications { + proxy_pass http://notification_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/payments { + proxy_pass http://payment_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/products { + proxy_pass http://product_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/rbacs { + proxy_pass http://rbac_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/suppliers { + proxy_pass http://supplier_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/uploads { + proxy_pass http://upload_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/ths { + proxy_pass http://th_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/kjhgfs { + proxy_pass http://kjhgf_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } +} \ No newline at end of file diff --git a/gateways/apps/uewf/docker-compose.dev.yml b/gateways/apps/uewf/docker-compose.dev.yml new file mode 100644 index 0000000..5d85059 --- /dev/null +++ b/gateways/apps/uewf/docker-compose.dev.yml @@ -0,0 +1,367 @@ + +version: '3.8' +services: + + hd: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/hd + ports: + - "null:null" + volumes: + - /app/node_modules + - ../../../microservices/hd:/app + depends_on: + rabbitmq: + condition: service_healthy + + customer-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/customer-service + ports: + - "9000:9000" + volumes: + - /app/node_modules + - ../../../microservices/customer-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + product-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/product-service + ports: + - "9002:9002" + volumes: + - /app/node_modules + - ../../../microservices/product-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + rbac-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/rbac-service + ports: + - "9004:9004" + volumes: + - /app/node_modules + - ../../../microservices/rbac-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + payment-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/payment-service + ports: + - "9006:9006" + volumes: + - /app/node_modules + - ../../../microservices/payment-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + notification-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/notification-service + ports: + - "9007:9007" + volumes: + - /app/node_modules + - ../../../microservices/notification-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + email-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/email-service + ports: + - "9008:9008" + volumes: + - /app/node_modules + - ../../../microservices/email-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + cart-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/cart-service + ports: + - "9009:9009" + volumes: + - /app/node_modules + - ../../../microservices/cart-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + cart: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/cart + ports: + - "9010:9010" + volumes: + - /app/node_modules + - ../../../microservices/cart:/app + depends_on: + rabbitmq: + condition: service_healthy + + user: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/user + ports: + - "9011:9011" + volumes: + - /app/node_modules + - ../../../microservices/user:/app + depends_on: + rabbitmq: + condition: service_healthy + + customer: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/customer + ports: + - "9012:9012" + volumes: + - /app/node_modules + - ../../../microservices/customer:/app + depends_on: + rabbitmq: + condition: service_healthy + + email: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/email + ports: + - "9013:9013" + volumes: + - /app/node_modules + - ../../../microservices/email:/app + depends_on: + rabbitmq: + condition: service_healthy + + notification: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/notification + ports: + - "9014:9014" + volumes: + - /app/node_modules + - ../../../microservices/notification:/app + depends_on: + rabbitmq: + condition: service_healthy + + payment: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/payment + ports: + - "9015:9015" + volumes: + - /app/node_modules + - ../../../microservices/payment:/app + depends_on: + rabbitmq: + condition: service_healthy + + product: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/product + ports: + - "9016:9016" + volumes: + - /app/node_modules + - ../../../microservices/product:/app + depends_on: + rabbitmq: + condition: service_healthy + + rbac: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/rbac + ports: + - "9017:9017" + volumes: + - /app/node_modules + - ../../../microservices/rbac:/app + depends_on: + rabbitmq: + condition: service_healthy + + supplier: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/supplier + ports: + - "9018:9018" + volumes: + - /app/node_modules + - ../../../microservices/supplier:/app + depends_on: + rabbitmq: + condition: service_healthy + + upload: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/upload + ports: + - "9019:9019" + volumes: + - /app/node_modules + - ../../../microservices/upload:/app + depends_on: + rabbitmq: + condition: service_healthy + + th: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/th + ports: + - "9020:9020" + volumes: + - /app/node_modules + - ../../../microservices/th:/app + depends_on: + rabbitmq: + condition: service_healthy + + kjhgf: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/kjhgf + ports: + - "9021:9021" + volumes: + - /app/node_modules + - ../../../microservices/kjhgf:/app + depends_on: + rabbitmq: + condition: service_healthy + + hhgfdsdfghj: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/hhgfdsdfghj + ports: + - "9022:9022" + volumes: + - /app/node_modules + - ../../../microservices/hhgfdsdfghj:/app + depends_on: + rabbitmq: + condition: service_healthy + + ghjk: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/ghjk + ports: + - "9023:9023" + volumes: + - /app/node_modules + - ../../../microservices/ghjk:/app + depends_on: + rabbitmq: + condition: service_healthy + + shjksgd: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/shjksgd + ports: + - "30067:30067" + volumes: + - /app/node_modules + - ../../../microservices/shjksgd:/app + depends_on: + rabbitmq: + condition: service_healthy + + nginx: + depends_on: + - hd + - customer-service + - product-service + - rbac-service + - payment-service + - notification-service + - email-service + - cart-service + - cart + - user + - customer + - email + - notification + - payment + - product + - rbac + - supplier + - upload + - th + - kjhgf + - hhgfdsdfghj + - ghjk + - shjksgd + restart: always + build: + context: ./nginx + dockerfile: Dockerfile.dev + ports: + - '4000:80' + healthcheck: + test: ["CMD-SHELL", "curl -f http://localhost:80/health || exit 1"] + interval: 30s + timeout: 10s + retries: 3 + start_period: 40s + rabbitmq: + image: rabbitmq:3.13-management + container_name: rabbitmq + ports: + - '5672:5672' + - '15672:15672' + healthcheck: + test: ["CMD", "rabbitmq-diagnostics", "ping"] + interval: 30s + retries: 5 + mongodb: + image: mongo + ports: + - '27017:27017' + restart: always + volumes: + - type: bind + source: ./data + target: /data/db + krakend: + image: devopsfaith/krakend:2.7-watch + ports: + - '9001:9001' + - '8090:8090' + volumes: + - ./krakend/:/etc/krakend/ + command: ['run','-d','-c','/etc/krakend/krakend.json'] \ No newline at end of file diff --git a/gateways/apps/uewf/docker-compose.yml b/gateways/apps/uewf/docker-compose.yml new file mode 100644 index 0000000..cad4827 --- /dev/null +++ b/gateways/apps/uewf/docker-compose.yml @@ -0,0 +1,367 @@ + +version: '3.8' +services: + + hd: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/hd + ports: + - "null:null" + volumes: + - /app/node_modules + - ../../../microservices/hd:/app + depends_on: + rabbitmq: + condition: service_healthy + + customer-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/customer-service + ports: + - "9000:9000" + volumes: + - /app/node_modules + - ../../../microservices/customer-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + product-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/product-service + ports: + - "9002:9002" + volumes: + - /app/node_modules + - ../../../microservices/product-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + rbac-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/rbac-service + ports: + - "9004:9004" + volumes: + - /app/node_modules + - ../../../microservices/rbac-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + payment-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/payment-service + ports: + - "9006:9006" + volumes: + - /app/node_modules + - ../../../microservices/payment-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + notification-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/notification-service + ports: + - "9007:9007" + volumes: + - /app/node_modules + - ../../../microservices/notification-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + email-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/email-service + ports: + - "9008:9008" + volumes: + - /app/node_modules + - ../../../microservices/email-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + cart-service: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/cart-service + ports: + - "9009:9009" + volumes: + - /app/node_modules + - ../../../microservices/cart-service:/app + depends_on: + rabbitmq: + condition: service_healthy + + cart: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/cart + ports: + - "9010:9010" + volumes: + - /app/node_modules + - ../../../microservices/cart:/app + depends_on: + rabbitmq: + condition: service_healthy + + user: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/user + ports: + - "9011:9011" + volumes: + - /app/node_modules + - ../../../microservices/user:/app + depends_on: + rabbitmq: + condition: service_healthy + + customer: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/customer + ports: + - "9012:9012" + volumes: + - /app/node_modules + - ../../../microservices/customer:/app + depends_on: + rabbitmq: + condition: service_healthy + + email: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/email + ports: + - "9013:9013" + volumes: + - /app/node_modules + - ../../../microservices/email:/app + depends_on: + rabbitmq: + condition: service_healthy + + notification: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/notification + ports: + - "9014:9014" + volumes: + - /app/node_modules + - ../../../microservices/notification:/app + depends_on: + rabbitmq: + condition: service_healthy + + payment: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/payment + ports: + - "9015:9015" + volumes: + - /app/node_modules + - ../../../microservices/payment:/app + depends_on: + rabbitmq: + condition: service_healthy + + product: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/product + ports: + - "9016:9016" + volumes: + - /app/node_modules + - ../../../microservices/product:/app + depends_on: + rabbitmq: + condition: service_healthy + + rbac: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/rbac + ports: + - "9017:9017" + volumes: + - /app/node_modules + - ../../../microservices/rbac:/app + depends_on: + rabbitmq: + condition: service_healthy + + supplier: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/supplier + ports: + - "9018:9018" + volumes: + - /app/node_modules + - ../../../microservices/supplier:/app + depends_on: + rabbitmq: + condition: service_healthy + + upload: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/upload + ports: + - "9019:9019" + volumes: + - /app/node_modules + - ../../../microservices/upload:/app + depends_on: + rabbitmq: + condition: service_healthy + + th: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/th + ports: + - "9020:9020" + volumes: + - /app/node_modules + - ../../../microservices/th:/app + depends_on: + rabbitmq: + condition: service_healthy + + kjhgf: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/kjhgf + ports: + - "9021:9021" + volumes: + - /app/node_modules + - ../../../microservices/kjhgf:/app + depends_on: + rabbitmq: + condition: service_healthy + + hhgfdsdfghj: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/hhgfdsdfghj + ports: + - "9022:9022" + volumes: + - /app/node_modules + - ../../../microservices/hhgfdsdfghj:/app + depends_on: + rabbitmq: + condition: service_healthy + + ghjk: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/ghjk + ports: + - "9023:9023" + volumes: + - /app/node_modules + - ../../../microservices/ghjk:/app + depends_on: + rabbitmq: + condition: service_healthy + + shjksgd: + build: + dockerfile: Dockerfile.dev + context: ../../../microservices/shjksgd + ports: + - "30067:30067" + volumes: + - /app/node_modules + - ../../../microservices/shjksgd:/app + depends_on: + rabbitmq: + condition: service_healthy + + nginx: + depends_on: + - hd + - customer-service + - product-service + - rbac-service + - payment-service + - notification-service + - email-service + - cart-service + - cart + - user + - customer + - email + - notification + - payment + - product + - rbac + - supplier + - upload + - th + - kjhgf + - hhgfdsdfghj + - ghjk + - shjksgd + restart: always + build: + context: ./nginx + dockerfile: Dockerfile.dev + ports: + - '4000:80' + healthcheck: + test: ["CMD-SHELL", "curl -f http://localhost:80/health || exit 1"] + interval: 30s + timeout: 10s + retries: 3 + start_period: 40s + rabbitmq: + image: rabbitmq:3.13-management + container_name: rabbitmq + ports: + - '5672:5672' + - '15672:15672' + healthcheck: + test: ["CMD", "rabbitmq-diagnostics", "ping"] + interval: 30s + retries: 5 + mongodb: + image: mongo + ports: + - '27017:27017' + restart: always + volumes: + - type: bind + source: ./data + target: /data/db + krakend: + image: devopsfaith/krakend:2.7 + ports: + - '9001:9001' + - '8090:8090' + volumes: + - ./krakend/:/etc/krakend/ + command: ['run','-d','-c','/etc/krakend/krakend.json'] \ No newline at end of file diff --git a/gateways/apps/uewf/krakend/krakend.json b/gateways/apps/uewf/krakend/krakend.json new file mode 100644 index 0000000..12a9d97 --- /dev/null +++ b/gateways/apps/uewf/krakend/krakend.json @@ -0,0 +1,402 @@ + +{ + "$schema": "https://www.krakend.io/schema/v2.5/krakend.json", + "version": 3, + "name": "Microservices-suite API Gateway", + "port": 9001, + "cache_ttl": "3600s", + "timeout": "300s", + "endpoints": [ + { + "@comment": "Check the health of all your APIs", + "endpoint": "/__suite_status", + "method": "GET", + "backend": [ + { + "host": ["http://hd:null"], + "url_pattern": "/", + "mapping": { + "message": "hd" + } + }, + + { + "host": ["http://customer-service:9000"], + "url_pattern": "/", + "mapping": { + "message": "customer-service" + } + }, + + { + "host": ["http://product-service:9002"], + "url_pattern": "/", + "mapping": { + "message": "product-service" + } + }, + + { + "host": ["http://rbac-service:9004"], + "url_pattern": "/", + "mapping": { + "message": "rbac-service" + } + }, + + { + "host": ["http://payment-service:9006"], + "url_pattern": "/", + "mapping": { + "message": "payment-service" + } + }, + + { + "host": ["http://notification-service:9007"], + "url_pattern": "/", + "mapping": { + "message": "notification-service" + } + }, + + { + "host": ["http://email-service:9008"], + "url_pattern": "/", + "mapping": { + "message": "email-service" + } + }, + + { + "host": ["http://cart-service:9009"], + "url_pattern": "/", + "mapping": { + "message": "cart-service" + } + }, + + { + "host": ["http://cart:9010"], + "url_pattern": "/", + "mapping": { + "message": "cart" + } + }, + + { + "host": ["http://user:9011"], + "url_pattern": "/", + "mapping": { + "message": "user" + } + }, + + { + "host": ["http://customer:9012"], + "url_pattern": "/", + "mapping": { + "message": "customer" + } + }, + + { + "host": ["http://email:9013"], + "url_pattern": "/", + "mapping": { + "message": "email" + } + }, + + { + "host": ["http://notification:9014"], + "url_pattern": "/", + "mapping": { + "message": "notification" + } + }, + + { + "host": ["http://payment:9015"], + "url_pattern": "/", + "mapping": { + "message": "payment" + } + }, + + { + "host": ["http://product:9016"], + "url_pattern": "/", + "mapping": { + "message": "product" + } + }, + + { + "host": ["http://rbac:9017"], + "url_pattern": "/", + "mapping": { + "message": "rbac" + } + }, + + { + "host": ["http://supplier:9018"], + "url_pattern": "/", + "mapping": { + "message": "supplier" + } + }, + + { + "host": ["http://upload:9019"], + "url_pattern": "/", + "mapping": { + "message": "upload" + } + }, + + { + "host": ["http://th:9020"], + "url_pattern": "/", + "mapping": { + "message": "th" + } + }, + + { + "host": ["http://kjhgf:9021"], + "url_pattern": "/", + "mapping": { + "message": "kjhgf" + } + }, + + { + "host": ["http://hhgfdsdfghj:9022"], + "url_pattern": "/", + "mapping": { + "message": "hhgfdsdfghj" + } + }, + + { + "host": ["http://ghjk:9023"], + "url_pattern": "/", + "mapping": { + "message": "ghjk" + } + }, + + { + "host": ["http://shjksgd:30067"], + "url_pattern": "/", + "mapping": { + "message": "shjksgd" + } + }] + }, + { + "@comment": "Hit all API list endpoints simultaneously", + "endpoint": "/api/v1/", + "method": "GET", + "backend": [ + { + "host": ["http://hd:null"], + "url_pattern": "/api/v1/hds", + "mapping": { + "data": "hds" + } + }, + + { + "host": ["http://customer-service:9000"], + "url_pattern": "/api/v1/customer-services", + "mapping": { + "data": "customer-services" + } + }, + + { + "host": ["http://product-service:9002"], + "url_pattern": "/api/v1/product-services", + "mapping": { + "data": "product-services" + } + }, + + { + "host": ["http://rbac-service:9004"], + "url_pattern": "/api/v1/rbac-services", + "mapping": { + "data": "rbac-services" + } + }, + + { + "host": ["http://payment-service:9006"], + "url_pattern": "/api/v1/payment-services", + "mapping": { + "data": "payment-services" + } + }, + + { + "host": ["http://notification-service:9007"], + "url_pattern": "/api/v1/notification-services", + "mapping": { + "data": "notification-services" + } + }, + + { + "host": ["http://email-service:9008"], + "url_pattern": "/api/v1/email-services", + "mapping": { + "data": "email-services" + } + }, + + { + "host": ["http://cart-service:9009"], + "url_pattern": "/api/v1/cart-services", + "mapping": { + "data": "cart-services" + } + }, + + { + "host": ["http://cart:9010"], + "url_pattern": "/api/v1/carts", + "mapping": { + "data": "carts" + } + }, + + { + "host": ["http://user:9011"], + "url_pattern": "/api/v1/users", + "mapping": { + "data": "users" + } + }, + + { + "host": ["http://customer:9012"], + "url_pattern": "/api/v1/customers", + "mapping": { + "data": "customers" + } + }, + + { + "host": ["http://email:9013"], + "url_pattern": "/api/v1/emails", + "mapping": { + "data": "emails" + } + }, + + { + "host": ["http://notification:9014"], + "url_pattern": "/api/v1/notifications", + "mapping": { + "data": "notifications" + } + }, + + { + "host": ["http://payment:9015"], + "url_pattern": "/api/v1/payments", + "mapping": { + "data": "payments" + } + }, + + { + "host": ["http://product:9016"], + "url_pattern": "/api/v1/products", + "mapping": { + "data": "products" + } + }, + + { + "host": ["http://rbac:9017"], + "url_pattern": "/api/v1/rbacs", + "mapping": { + "data": "rbacs" + } + }, + + { + "host": ["http://supplier:9018"], + "url_pattern": "/api/v1/suppliers", + "mapping": { + "data": "suppliers" + } + }, + + { + "host": ["http://upload:9019"], + "url_pattern": "/api/v1/uploads", + "mapping": { + "data": "uploads" + } + }, + + { + "host": ["http://th:9020"], + "url_pattern": "/api/v1/ths", + "mapping": { + "data": "ths" + } + }, + + { + "host": ["http://kjhgf:9021"], + "url_pattern": "/api/v1/kjhgfs", + "mapping": { + "data": "kjhgfs" + } + }, + + { + "host": ["http://hhgfdsdfghj:9022"], + "url_pattern": "/api/v1/hhgfdsdfghjs", + "mapping": { + "data": "hhgfdsdfghjs" + } + }, + + { + "host": ["http://ghjk:9023"], + "url_pattern": "/api/v1/ghjks", + "mapping": { + "data": "ghjks" + } + }, + + { + "host": ["http://shjksgd:30067"], + "url_pattern": "/api/v1/shjksgds", + "mapping": { + "data": "shjksgds" + } + }] + }, + { + "@comment": "Fetch all data from the hd service", + "endpoint": "/api/v1/hds", + "method": "GET", + "backend": [ + { + "host": ["http://hd:null"], + "url_pattern": "/api/v1/hds", + "mapping": { + "data": "hds" + } + }] + } + ] +} \ No newline at end of file diff --git a/gateways/apps/uewf/nginx/Dockerfile b/gateways/apps/uewf/nginx/Dockerfile new file mode 100644 index 0000000..ddf7281 --- /dev/null +++ b/gateways/apps/uewf/nginx/Dockerfile @@ -0,0 +1,3 @@ + +FROM nginx +COPY ./default.conf /etc/nginx/conf.d/default.conf \ No newline at end of file diff --git a/gateways/apps/uewf/nginx/Dockerfile.dev b/gateways/apps/uewf/nginx/Dockerfile.dev new file mode 100644 index 0000000..ddf7281 --- /dev/null +++ b/gateways/apps/uewf/nginx/Dockerfile.dev @@ -0,0 +1,3 @@ + +FROM nginx +COPY ./default.conf /etc/nginx/conf.d/default.conf \ No newline at end of file diff --git a/gateways/apps/uewf/nginx/default.conf b/gateways/apps/uewf/nginx/default.conf new file mode 100644 index 0000000..d4dace0 --- /dev/null +++ b/gateways/apps/uewf/nginx/default.conf @@ -0,0 +1,282 @@ + + +upstream hd_upstream { + server hd:null; +} + +upstream customer-service_upstream { + server customer-service:9000; +} + +upstream product-service_upstream { + server product-service:9002; +} + +upstream rbac-service_upstream { + server rbac-service:9004; +} + +upstream payment-service_upstream { + server payment-service:9006; +} + +upstream notification-service_upstream { + server notification-service:9007; +} + +upstream email-service_upstream { + server email-service:9008; +} + +upstream cart-service_upstream { + server cart-service:9009; +} + +upstream cart_upstream { + server cart:9010; +} + +upstream user_upstream { + server user:9011; +} + +upstream customer_upstream { + server customer:9012; +} + +upstream email_upstream { + server email:9013; +} + +upstream notification_upstream { + server notification:9014; +} + +upstream payment_upstream { + server payment:9015; +} + +upstream product_upstream { + server product:9016; +} + +upstream rbac_upstream { + server rbac:9017; +} + +upstream supplier_upstream { + server supplier:9018; +} + +upstream upload_upstream { + server upload:9019; +} + +upstream th_upstream { + server th:9020; +} + +upstream kjhgf_upstream { + server kjhgf:9021; +} + +upstream hhgfdsdfghj_upstream { + server hhgfdsdfghj:9022; +} + +upstream ghjk_upstream { + server ghjk:9023; +} + +upstream shjksgd_upstream { + server shjksgd:30067; +} + +server { + listen 80; + + + location /api/v1/hds { + proxy_pass http://hd_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/customer-services { + proxy_pass http://customer-service_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/product-services { + proxy_pass http://product-service_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/rbac-services { + proxy_pass http://rbac-service_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/payment-services { + proxy_pass http://payment-service_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/notification-services { + proxy_pass http://notification-service_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/email-services { + proxy_pass http://email-service_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/cart-services { + proxy_pass http://cart-service_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/carts { + proxy_pass http://cart_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/users { + proxy_pass http://user_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/customers { + proxy_pass http://customer_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/emails { + proxy_pass http://email_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/notifications { + proxy_pass http://notification_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/payments { + proxy_pass http://payment_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/products { + proxy_pass http://product_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/rbacs { + proxy_pass http://rbac_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/suppliers { + proxy_pass http://supplier_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/uploads { + proxy_pass http://upload_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/ths { + proxy_pass http://th_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/kjhgfs { + proxy_pass http://kjhgf_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/hhgfdsdfghjs { + proxy_pass http://hhgfdsdfghj_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/ghjks { + proxy_pass http://ghjk_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /api/v1/shjksgds { + proxy_pass http://shjksgd_upstream; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } +} \ No newline at end of file diff --git a/microservices/ghjk/.dockerignore b/microservices/ghjk/.dockerignore new file mode 100644 index 0000000..25a56cf --- /dev/null +++ b/microservices/ghjk/.dockerignore @@ -0,0 +1,5 @@ + +#These files wont be sent to the docker builder during the COPY . . command + +node_modules +bar diff --git a/microservices/ghjk/Dockerfile.dev b/microservices/ghjk/Dockerfile.dev new file mode 100644 index 0000000..8f85789 --- /dev/null +++ b/microservices/ghjk/Dockerfile.dev @@ -0,0 +1,12 @@ + +FROM node:18-alpine3.18 + +WORKDIR /app + +COPY package.json . + +RUN yarn install + +COPY . . + +CMD [ "yarn","dev" ] diff --git a/microservices/ghjk/ecosystem.config.js b/microservices/ghjk/ecosystem.config.js new file mode 100644 index 0000000..961e318 --- /dev/null +++ b/microservices/ghjk/ecosystem.config.js @@ -0,0 +1,26 @@ + +module.exports = { + apps : [{ + name : ghjk, + autorestart: true, + watch: true, + time: true, + script : "./index.js", + instances:4, + env_production: { + NODE_ENV: "prod", + DATABASE_URL:"mongodb://mongodb:27017/microservices-suite_ghjk_proddb", + EXCHANGE:@microservices-suite, + AMQP_HOST:"amqp://rabbitmq:5672", + PORT:9023 + }, + env_development: { + NODE_ENV: "dev", + DATABASE_URL:"mongodb://mongodb:27017/microservices-suite_ghjk_devdb", + EXCHANGE:@microservices-suite, + AMQP_HOST:"amqp://rabbitmq:5672", + PORT:9023 + } + }] + } + diff --git a/microservices/ghjk/index.js b/microservices/ghjk/index.js new file mode 100644 index 0000000..dd30663 --- /dev/null +++ b/microservices/ghjk/index.js @@ -0,0 +1,65 @@ + +const http = require('http'); +const express = require('express'); +const mongoose = require('mongoose'); +const { config, morgan, logger } = require('@microservices-suite/config'); +const { errorHandler } = require('@microservices-suite/errors'); +const { validate, APIError } = require('@microservices-suite/utilities'); +const { getUsers } = require('./src/services'); +const { router } = require('./src/routes'); +const { subscriber } = require('./src/subscriber'); +const rabbitmq = require('@microservices-suite/broker/rabbitmq'); +// const app = require('./src/app'); + +mongoose.connect(config.db).then(() => { + logger.info(`📀 successfully connected to db: ${config.db}`); +}).catch(err => { + logger.error(`failed to connect to db. Exiting... ${err.message}`); + process.exit(0); +}); + +const app = express(); + +app.use(express.json()); + +app.get('/', (req, res) => { + res.json({ message: 'hello from @microservices-suite/ghjk' }); +}); + +const server = http.createServer(app); + +server.on('error', (err) => { + logger.error(err); + if (err.code === 'EADDRINUSE') { + logger.error('Address already in use, retrying...'); + setTimeout(() => { + server.close(); + server.listen(config.port, 'localhost'); + }, 1000); + errorHandler(err); + } +}); + +server.listen(config.port, async() => { + logger.info(`🚀 @microservices-suite/ghjk listening at: http://localhost:${config.port}`); + const channel = await rabbitmq.workerQueue.amqpInitializeQueue({ config }); + await rabbitmq.workerQueue.consumeFromQueue({ + channel, + queue: 'ghjk', + subscriberHandler: subscriber.subscriberHandler + }); +}); + +app.use(morgan.errorHandler); + +app.use(morgan.successHandler); + +app.use('/api/v1', router); + +// Global error handler should come after all other middlewares +app.all('*', (req, res, next) => { + const err = new APIError(404, `requested resource not found on server: ${req.originalUrl}`); + next(err); +}); + +app.use(errorHandler); diff --git a/microservices/ghjk/package.json b/microservices/ghjk/package.json new file mode 100644 index 0000000..f3067f5 --- /dev/null +++ b/microservices/ghjk/package.json @@ -0,0 +1,46 @@ +{ + "name": "@microservices-suite/ghjk", + "version": "1.0.0", + "description": "This is the ghjk service. TODO: update this description", + "main": "index.js", + "author": "Gilbert", + "license": "MIT", + "dependencies": { + "@microservices-suite/config": "1.0.0", + "@microservices-suite/errors": "1.0.0", + "@microservices-suite/utilities": "1.0.7", + "@microservices-suite/broker": "1.0.0", + "dotenv": "^16.4.5", + "express": "^4.18.3", + "helmet": "^7.1.0", + "mongodb": "^6.5.0", + "mongoose": "^8.2.1", + "morgan": "^1.10.0", + "pm2": "^5.3.1", + "winston": "^3.12.0" + }, + "devDependencies": { + "nodemon": "^3.1.0" + }, + "workspaces": { + "nohoist": [ + "**/@microservices-suite/utilities/", + "**/@microservices-suite/utilities/**", + "**/@microservices-suite/errors/", + "**/@microservices-suite/errors/**", + "**/@microservices-suite/config/", + "**/@microservices-suite/config/**", + "**/@microservices-suite/broker/", + "**/@microservices-suite/broker/**" + ] + }, + "scripts": { + "release": "npx bumpp-version@latest && npm publish", + "dev": "NODE_ENV=dev nodemon --legacy-watch -q index.js", + "start": "pm2-runtime start ecosystem.config.js --env production", + "stoprod": "pm2 stop ecosystem.config.js", + "deletprod": "pm2 delete ecosystem.config.js", + "test": "jest" + }, + "private": true +} \ No newline at end of file diff --git a/microservices/ghjk/src/controllers/controllers.js b/microservices/ghjk/src/controllers/controllers.js new file mode 100644 index 0000000..1d0e39d --- /dev/null +++ b/microservices/ghjk/src/controllers/controllers.js @@ -0,0 +1,52 @@ + +const services = require('../services/services'); +const { asyncErrorHandler, APIError } = require('@microservices-suite/utilities'); + +const createGhjk = asyncErrorHandler(async (req, res) => { + const { body } = req; + const { ghjk: data } = await services.createGhjk({ body }); + res.status(201).json({ data }); +}); + +const getGhjks = asyncErrorHandler(async (req, res) => { + const { ghjks: data } = await services.getGhjks(); + res.status(200).json({ data }); +}); + +const getGhjk = asyncErrorHandler(async (req, res) => { + const { id } = req.params; + const { ghjk: data } = await services.getGhjkById({ id }); + if (!data) { + throw new APIError(404, 'ghjk not found'); + } + res.status(200).json({ data }); +}); + +const updateGhjk = asyncErrorHandler(async (req, res) => { + const { id } = req.params; + const { body } = req; + const { ghjk } = await services.getGhjkById({ id }); + if (!ghjk) { + throw new APIError(404, 'ghjk not found'); + } + const { upserted_ghjk: data } = await services.updateGhjkProfile({ id, body }); + res.status(200).json({ data }); +}); + +const deleteGhjk = asyncErrorHandler(async (req, res) => { + const { id } = req.params; + const { ghjk } = await services.getGhjkById({ id }); + if (!ghjk) { + throw new APIError(404, 'ghjk not found'); + } + await services.deleteGhjk({ id }); + res.status(200).json({ message: 'Deletion successful' }); +}); +module.exports = { + createGhjk, + getGhjks, + getGhjk, + updateGhjk, + deleteGhjk +}; + diff --git a/microservices/ghjk/src/controllers/index.js b/microservices/ghjk/src/controllers/index.js new file mode 100644 index 0000000..f41caf5 --- /dev/null +++ b/microservices/ghjk/src/controllers/index.js @@ -0,0 +1,2 @@ +const { hello } = require('./controllers'); +module.exports = controllers; \ No newline at end of file diff --git a/microservices/ghjk/src/models/index.js b/microservices/ghjk/src/models/index.js new file mode 100644 index 0000000..b0d086a --- /dev/null +++ b/microservices/ghjk/src/models/index.js @@ -0,0 +1,2 @@ +const models = require('./model'); +module.exports = models; \ No newline at end of file diff --git a/microservices/ghjk/src/models/models.js b/microservices/ghjk/src/models/models.js new file mode 100644 index 0000000..f9237d4 --- /dev/null +++ b/microservices/ghjk/src/models/models.js @@ -0,0 +1,16 @@ + +const mongoose = require('mongoose'); + +const ghjkSchema = new mongoose.Schema({ + name: { + type: String, + required: true, + } +} + , { + timestamps: true + }); + +const Ghjk = mongoose.model('ghjk', ghjkSchema); + +module.exports = Ghjk; diff --git a/microservices/ghjk/src/routes/index.js b/microservices/ghjk/src/routes/index.js new file mode 100644 index 0000000..c564440 --- /dev/null +++ b/microservices/ghjk/src/routes/index.js @@ -0,0 +1,2 @@ +const router = require('./routes'); +module.exports = { router }; \ No newline at end of file diff --git a/microservices/ghjk/src/routes/routes.js b/microservices/ghjk/src/routes/routes.js new file mode 100644 index 0000000..83a526c --- /dev/null +++ b/microservices/ghjk/src/routes/routes.js @@ -0,0 +1,20 @@ + +const express = require('express'); +const { validate } = require('@microservices-suite/utilities'); + +const ghjkController = require('../controllers/controllers'); + +const router = express.Router(); + +router + .route('/ghjks') + .post(ghjkController.createGhjk) + .get(ghjkController.getGhjks); + +router + .route('/ghjks/:id') + .get(ghjkController.getGhjk) + .patch(ghjkController.updateGhjk) + .delete(ghjkController.deleteGhjk); + +module.exports = router; diff --git a/microservices/ghjk/src/services/index.js b/microservices/ghjk/src/services/index.js new file mode 100644 index 0000000..a099545 --- /dev/null +++ b/microservices/ghjk/src/services/index.js @@ -0,0 +1 @@ +module.exports = {}; \ No newline at end of file diff --git a/microservices/ghjk/src/services/services.js b/microservices/ghjk/src/services/services.js new file mode 100644 index 0000000..4d6ed20 --- /dev/null +++ b/microservices/ghjk/src/services/services.js @@ -0,0 +1,34 @@ + +const { ObjectId } = require('mongodb'); +const Ghjk = require('../models/models'); + +const createGhjk = async ({ body }) => { + const ghjk = await Ghjk.create(body); + return { ghjk }; +}; + +const getGhjks = async () => { + const ghjks = await Ghjk.find({}); + return { ghjks }; +}; + +const getGhjkById = async ({ id }) => { + const ghjk = await Ghjk.findById(id); + return { ghjk }; +}; + +const updateGhjkProfile = async ({ id, body }) => { + const upserted_ghjk = await Ghjk.updateOne({ _id: ObjectId(id) }, { ...body }, { upsert: false }); + return { upserted_ghjk }; +}; + +const deleteGhjk = async ({ id }) => { + await Ghjk.deleteOne({ _id: ObjectId(id) }); +}; +module.exports = { + createGhjk, + getGhjks, + getGhjkById, + updateGhjkProfile, + deleteGhjk +}; diff --git a/microservices/ghjk/src/subscriber/index.js b/microservices/ghjk/src/subscriber/index.js new file mode 100644 index 0000000..8f99ac7 --- /dev/null +++ b/microservices/ghjk/src/subscriber/index.js @@ -0,0 +1 @@ +module.exports.subscriber = require('./subscriber'); \ No newline at end of file diff --git a/microservices/ghjk/src/subscriber/subscriber.js b/microservices/ghjk/src/subscriber/subscriber.js new file mode 100644 index 0000000..ad714ad --- /dev/null +++ b/microservices/ghjk/src/subscriber/subscriber.js @@ -0,0 +1,60 @@ + +const ghjkService = require('../services/services'); +const rabbitmq = require('@microservices-suite/broker/rabbitmq'); + +const subscribe = async ({ channel, config, routing_key }) => { + try { + const q = await channel.assertQueue('', { exclusive: true }); + console.log(`⚡️ ${routing_key}: successfully subscribed to exchange: ${config.exchange}`); + await channel.bindQueue(q.queue, config.exchange, routing_key); + await channel.consume(q.queue, async(msg) => { + if (msg !== null) { + const service = msg.fields.routingKey; + console.log("Message received [x] %s: '%s'", msg.fields.routingKey, msg.content.toString()); + await subscriberHandler({ channel, msg, service, config }); + } + }, { noAck: false }); + } catch (error) { + throw new APIError(500, `Failed to set up subscriber ${error.message}`); + } +}; + +const subscriberHandler = async ({ channel, msg, service, config }) => { + const messageContent = JSON.parse(msg.content.toString()); // Parse the message content + const { action, body } = messageContent; // Destructure type and body from the parsed content + let data; + let auth; + switch (action) { + case 'create': + try { + await ghjkService.createGhjk({ body }) + } catch (error) { + //TODO: handle this case. Eg do we roll back or what next.. + console.log(`ghjk: subscriber-failed to create ghjk: ${error.message}`); + + console.log({ error }); + } + break; + // TODO: use rpc for read operations + case 'read': + const { ghjks } = await ghjkService.getGhjks(); + data = ghjks; + await rabbitmq.workerQueue.sendToQueue({ data, queue: service, config }); + break; + case 'read:id': + ghjk = await ghjkService.getGhjkById({ id: body.id }); + ghjk = ghjk.ghjk; + await rabbitmq.workerQueue.sendToQueue({ data, queue: service, config }); + break; + case 'update': + break; + case 'delete': + break; + default: + channel.ack(msg); + } +} +module.exports = { + subscriberHandler, + subscribe +}; diff --git a/microservices/hd/.dockerignore b/microservices/hd/.dockerignore new file mode 100644 index 0000000..25a56cf --- /dev/null +++ b/microservices/hd/.dockerignore @@ -0,0 +1,5 @@ + +#These files wont be sent to the docker builder during the COPY . . command + +node_modules +bar diff --git a/microservices/hd/Dockerfile.dev b/microservices/hd/Dockerfile.dev new file mode 100644 index 0000000..8f85789 --- /dev/null +++ b/microservices/hd/Dockerfile.dev @@ -0,0 +1,12 @@ + +FROM node:18-alpine3.18 + +WORKDIR /app + +COPY package.json . + +RUN yarn install + +COPY . . + +CMD [ "yarn","dev" ] diff --git a/microservices/hd/ecosystem.config.js b/microservices/hd/ecosystem.config.js new file mode 100644 index 0000000..0d44230 --- /dev/null +++ b/microservices/hd/ecosystem.config.js @@ -0,0 +1,26 @@ + +module.exports = { + apps : [{ + name : hd, + autorestart: true, + watch: true, + time: true, + script : "./index.js", + instances:4, + env_production: { + NODE_ENV: "prod", + DATABASE_URL:"mongodb://mongodb:27017/microservices-suite_hd_proddb", + EXCHANGE:@microservices-suite, + AMQP_HOST:"amqp://rabbitmq:5672", + PORT:NaN + }, + env_development: { + NODE_ENV: "dev", + DATABASE_URL:"mongodb://mongodb:27017/microservices-suite_hd_devdb", + EXCHANGE:@microservices-suite, + AMQP_HOST:"amqp://rabbitmq:5672", + PORT:NaN + } + }] + } + diff --git a/microservices/hd/index.js b/microservices/hd/index.js new file mode 100644 index 0000000..db6bad3 --- /dev/null +++ b/microservices/hd/index.js @@ -0,0 +1,65 @@ + +const http = require('http'); +const express = require('express'); +const mongoose = require('mongoose'); +const { config, morgan, logger } = require('@microservices-suite/config'); +const { errorHandler } = require('@microservices-suite/errors'); +const { validate, APIError } = require('@microservices-suite/utilities'); +const { getUsers } = require('./src/services'); +const { router } = require('./src/routes'); +const { subscriber } = require('./src/subscriber'); +const rabbitmq = require('@microservices-suite/broker/rabbitmq'); +// const app = require('./src/app'); + +mongoose.connect(config.db).then(() => { + logger.info(`📀 successfully connected to db: ${config.db}`); +}).catch(err => { + logger.error(`failed to connect to db. Exiting... ${err.message}`); + process.exit(0); +}); + +const app = express(); + +app.use(express.json()); + +app.get('/', (req, res) => { + res.json({ message: 'hello from @microservices-suite/hd' }); +}); + +const server = http.createServer(app); + +server.on('error', (err) => { + logger.error(err); + if (err.code === 'EADDRINUSE') { + logger.error('Address already in use, retrying...'); + setTimeout(() => { + server.close(); + server.listen(config.port, 'localhost'); + }, 1000); + errorHandler(err); + } +}); + +server.listen(config.port, async() => { + logger.info(`🚀 @microservices-suite/hd listening at: http://localhost:${config.port}`); + const channel = await rabbitmq.workerQueue.amqpInitializeQueue({ config }); + await rabbitmq.workerQueue.consumeFromQueue({ + channel, + queue: 'hd', + subscriberHandler: subscriber.subscriberHandler + }); +}); + +app.use(morgan.errorHandler); + +app.use(morgan.successHandler); + +app.use('/api/v1', router); + +// Global error handler should come after all other middlewares +app.all('*', (req, res, next) => { + const err = new APIError(404, `requested resource not found on server: ${req.originalUrl}`); + next(err); +}); + +app.use(errorHandler); diff --git a/microservices/hd/package.json b/microservices/hd/package.json new file mode 100644 index 0000000..f3d8a7d --- /dev/null +++ b/microservices/hd/package.json @@ -0,0 +1,46 @@ +{ + "name": "@microservices-suite/hd", + "version": "1.0.0", + "description": "This is the hd service. TODO: update this description", + "main": "index.js", + "author": "Gilbert", + "license": "MIT", + "dependencies": { + "@microservices-suite/config": "1.0.0", + "@microservices-suite/errors": "1.0.0", + "@microservices-suite/utilities": "1.0.7", + "@microservices-suite/broker": "1.0.0", + "dotenv": "^16.4.5", + "express": "^4.18.3", + "helmet": "^7.1.0", + "mongodb": "^6.5.0", + "mongoose": "^8.2.1", + "morgan": "^1.10.0", + "pm2": "^5.3.1", + "winston": "^3.12.0" + }, + "devDependencies": { + "nodemon": "^3.1.0" + }, + "workspaces": { + "nohoist": [ + "**/@microservices-suite/utilities/", + "**/@microservices-suite/utilities/**", + "**/@microservices-suite/errors/", + "**/@microservices-suite/errors/**", + "**/@microservices-suite/config/", + "**/@microservices-suite/config/**", + "**/@microservices-suite/broker/", + "**/@microservices-suite/broker/**" + ] + }, + "scripts": { + "release": "npx bumpp-version@latest && npm publish", + "dev": "NODE_ENV=dev nodemon --legacy-watch -q index.js", + "start": "pm2-runtime start ecosystem.config.js --env production", + "stoprod": "pm2 stop ecosystem.config.js", + "deletprod": "pm2 delete ecosystem.config.js", + "test": "jest" + }, + "private": true +} \ No newline at end of file diff --git a/microservices/hd/src/controllers/controllers.js b/microservices/hd/src/controllers/controllers.js new file mode 100644 index 0000000..5f503f7 --- /dev/null +++ b/microservices/hd/src/controllers/controllers.js @@ -0,0 +1,52 @@ + +const services = require('../services/services'); +const { asyncErrorHandler, APIError } = require('@microservices-suite/utilities'); + +const createHd = asyncErrorHandler(async (req, res) => { + const { body } = req; + const { hd: data } = await services.createHd({ body }); + res.status(201).json({ data }); +}); + +const getHds = asyncErrorHandler(async (req, res) => { + const { hds: data } = await services.getHds(); + res.status(200).json({ data }); +}); + +const getHd = asyncErrorHandler(async (req, res) => { + const { id } = req.params; + const { hd: data } = await services.getHdById({ id }); + if (!data) { + throw new APIError(404, 'hd not found'); + } + res.status(200).json({ data }); +}); + +const updateHd = asyncErrorHandler(async (req, res) => { + const { id } = req.params; + const { body } = req; + const { hd } = await services.getHdById({ id }); + if (!hd) { + throw new APIError(404, 'hd not found'); + } + const { upserted_hd: data } = await services.updateHdProfile({ id, body }); + res.status(200).json({ data }); +}); + +const deleteHd = asyncErrorHandler(async (req, res) => { + const { id } = req.params; + const { hd } = await services.getHdById({ id }); + if (!hd) { + throw new APIError(404, 'hd not found'); + } + await services.deleteHd({ id }); + res.status(200).json({ message: 'Deletion successful' }); +}); +module.exports = { + createHd, + getHds, + getHd, + updateHd, + deleteHd +}; + diff --git a/microservices/hd/src/controllers/index.js b/microservices/hd/src/controllers/index.js new file mode 100644 index 0000000..f41caf5 --- /dev/null +++ b/microservices/hd/src/controllers/index.js @@ -0,0 +1,2 @@ +const { hello } = require('./controllers'); +module.exports = controllers; \ No newline at end of file diff --git a/microservices/hd/src/models/index.js b/microservices/hd/src/models/index.js new file mode 100644 index 0000000..b0d086a --- /dev/null +++ b/microservices/hd/src/models/index.js @@ -0,0 +1,2 @@ +const models = require('./model'); +module.exports = models; \ No newline at end of file diff --git a/microservices/hd/src/models/models.js b/microservices/hd/src/models/models.js new file mode 100644 index 0000000..f108382 --- /dev/null +++ b/microservices/hd/src/models/models.js @@ -0,0 +1,16 @@ + +const mongoose = require('mongoose'); + +const hdSchema = new mongoose.Schema({ + name: { + type: String, + required: true, + } +} + , { + timestamps: true + }); + +const Hd = mongoose.model('hd', hdSchema); + +module.exports = Hd; diff --git a/microservices/hd/src/routes/index.js b/microservices/hd/src/routes/index.js new file mode 100644 index 0000000..c564440 --- /dev/null +++ b/microservices/hd/src/routes/index.js @@ -0,0 +1,2 @@ +const router = require('./routes'); +module.exports = { router }; \ No newline at end of file diff --git a/microservices/hd/src/routes/routes.js b/microservices/hd/src/routes/routes.js new file mode 100644 index 0000000..6715ba1 --- /dev/null +++ b/microservices/hd/src/routes/routes.js @@ -0,0 +1,20 @@ + +const express = require('express'); +const { validate } = require('@microservices-suite/utilities'); + +const hdController = require('../controllers/controllers'); + +const router = express.Router(); + +router + .route('/hds') + .post(hdController.createHd) + .get(hdController.getHds); + +router + .route('/hds/:id') + .get(hdController.getHd) + .patch(hdController.updateHd) + .delete(hdController.deleteHd); + +module.exports = router; diff --git a/microservices/hd/src/services/index.js b/microservices/hd/src/services/index.js new file mode 100644 index 0000000..a099545 --- /dev/null +++ b/microservices/hd/src/services/index.js @@ -0,0 +1 @@ +module.exports = {}; \ No newline at end of file diff --git a/microservices/hd/src/services/services.js b/microservices/hd/src/services/services.js new file mode 100644 index 0000000..57c5b94 --- /dev/null +++ b/microservices/hd/src/services/services.js @@ -0,0 +1,34 @@ + +const { ObjectId } = require('mongodb'); +const Hd = require('../models/models'); + +const createHd = async ({ body }) => { + const hd = await Hd.create(body); + return { hd }; +}; + +const getHds = async () => { + const hds = await Hd.find({}); + return { hds }; +}; + +const getHdById = async ({ id }) => { + const hd = await Hd.findById(id); + return { hd }; +}; + +const updateHdProfile = async ({ id, body }) => { + const upserted_hd = await Hd.updateOne({ _id: ObjectId(id) }, { ...body }, { upsert: false }); + return { upserted_hd }; +}; + +const deleteHd = async ({ id }) => { + await Hd.deleteOne({ _id: ObjectId(id) }); +}; +module.exports = { + createHd, + getHds, + getHdById, + updateHdProfile, + deleteHd +}; diff --git a/microservices/hd/src/subscriber/index.js b/microservices/hd/src/subscriber/index.js new file mode 100644 index 0000000..8f99ac7 --- /dev/null +++ b/microservices/hd/src/subscriber/index.js @@ -0,0 +1 @@ +module.exports.subscriber = require('./subscriber'); \ No newline at end of file diff --git a/microservices/hd/src/subscriber/subscriber.js b/microservices/hd/src/subscriber/subscriber.js new file mode 100644 index 0000000..478df3c --- /dev/null +++ b/microservices/hd/src/subscriber/subscriber.js @@ -0,0 +1,60 @@ + +const hdService = require('../services/services'); +const rabbitmq = require('@microservices-suite/broker/rabbitmq'); + +const subscribe = async ({ channel, config, routing_key }) => { + try { + const q = await channel.assertQueue('', { exclusive: true }); + console.log(`⚡️ ${routing_key}: successfully subscribed to exchange: ${config.exchange}`); + await channel.bindQueue(q.queue, config.exchange, routing_key); + await channel.consume(q.queue, async(msg) => { + if (msg !== null) { + const service = msg.fields.routingKey; + console.log("Message received [x] %s: '%s'", msg.fields.routingKey, msg.content.toString()); + await subscriberHandler({ channel, msg, service, config }); + } + }, { noAck: false }); + } catch (error) { + throw new APIError(500, `Failed to set up subscriber ${error.message}`); + } +}; + +const subscriberHandler = async ({ channel, msg, service, config }) => { + const messageContent = JSON.parse(msg.content.toString()); // Parse the message content + const { action, body } = messageContent; // Destructure type and body from the parsed content + let data; + let auth; + switch (action) { + case 'create': + try { + await hdService.createHd({ body }) + } catch (error) { + //TODO: handle this case. Eg do we roll back or what next.. + console.log(`hd: subscriber-failed to create hd: ${error.message}`); + + console.log({ error }); + } + break; + // TODO: use rpc for read operations + case 'read': + const { hds } = await hdService.getHds(); + data = hds; + await rabbitmq.workerQueue.sendToQueue({ data, queue: service, config }); + break; + case 'read:id': + hd = await hdService.getHdById({ id: body.id }); + hd = hd.hd; + await rabbitmq.workerQueue.sendToQueue({ data, queue: service, config }); + break; + case 'update': + break; + case 'delete': + break; + default: + channel.ack(msg); + } +} +module.exports = { + subscriberHandler, + subscribe +}; diff --git a/microservices/hhgfdsdfghj/.dockerignore b/microservices/hhgfdsdfghj/.dockerignore new file mode 100644 index 0000000..25a56cf --- /dev/null +++ b/microservices/hhgfdsdfghj/.dockerignore @@ -0,0 +1,5 @@ + +#These files wont be sent to the docker builder during the COPY . . command + +node_modules +bar diff --git a/microservices/hhgfdsdfghj/Dockerfile.dev b/microservices/hhgfdsdfghj/Dockerfile.dev new file mode 100644 index 0000000..8f85789 --- /dev/null +++ b/microservices/hhgfdsdfghj/Dockerfile.dev @@ -0,0 +1,12 @@ + +FROM node:18-alpine3.18 + +WORKDIR /app + +COPY package.json . + +RUN yarn install + +COPY . . + +CMD [ "yarn","dev" ] diff --git a/microservices/hhgfdsdfghj/ecosystem.config.js b/microservices/hhgfdsdfghj/ecosystem.config.js new file mode 100644 index 0000000..439a34d --- /dev/null +++ b/microservices/hhgfdsdfghj/ecosystem.config.js @@ -0,0 +1,26 @@ + +module.exports = { + apps : [{ + name : hhgfdsdfghj, + autorestart: true, + watch: true, + time: true, + script : "./index.js", + instances:4, + env_production: { + NODE_ENV: "prod", + DATABASE_URL:"mongodb://mongodb:27017/microservices-suite_hhgfdsdfghj_proddb", + EXCHANGE:@microservices-suite, + AMQP_HOST:"amqp://rabbitmq:5672", + PORT:9022 + }, + env_development: { + NODE_ENV: "dev", + DATABASE_URL:"mongodb://mongodb:27017/microservices-suite_hhgfdsdfghj_devdb", + EXCHANGE:@microservices-suite, + AMQP_HOST:"amqp://rabbitmq:5672", + PORT:9022 + } + }] + } + diff --git a/microservices/hhgfdsdfghj/index.js b/microservices/hhgfdsdfghj/index.js new file mode 100644 index 0000000..918ccc4 --- /dev/null +++ b/microservices/hhgfdsdfghj/index.js @@ -0,0 +1,65 @@ + +const http = require('http'); +const express = require('express'); +const mongoose = require('mongoose'); +const { config, morgan, logger } = require('@microservices-suite/config'); +const { errorHandler } = require('@microservices-suite/errors'); +const { validate, APIError } = require('@microservices-suite/utilities'); +const { getUsers } = require('./src/services'); +const { router } = require('./src/routes'); +const { subscriber } = require('./src/subscriber'); +const rabbitmq = require('@microservices-suite/broker/rabbitmq'); +// const app = require('./src/app'); + +mongoose.connect(config.db).then(() => { + logger.info(`📀 successfully connected to db: ${config.db}`); +}).catch(err => { + logger.error(`failed to connect to db. Exiting... ${err.message}`); + process.exit(0); +}); + +const app = express(); + +app.use(express.json()); + +app.get('/', (req, res) => { + res.json({ message: 'hello from @microservices-suite/hhgfdsdfghj' }); +}); + +const server = http.createServer(app); + +server.on('error', (err) => { + logger.error(err); + if (err.code === 'EADDRINUSE') { + logger.error('Address already in use, retrying...'); + setTimeout(() => { + server.close(); + server.listen(config.port, 'localhost'); + }, 1000); + errorHandler(err); + } +}); + +server.listen(config.port, async() => { + logger.info(`🚀 @microservices-suite/hhgfdsdfghj listening at: http://localhost:${config.port}`); + const channel = await rabbitmq.workerQueue.amqpInitializeQueue({ config }); + await rabbitmq.workerQueue.consumeFromQueue({ + channel, + queue: 'hhgfdsdfghj', + subscriberHandler: subscriber.subscriberHandler + }); +}); + +app.use(morgan.errorHandler); + +app.use(morgan.successHandler); + +app.use('/api/v1', router); + +// Global error handler should come after all other middlewares +app.all('*', (req, res, next) => { + const err = new APIError(404, `requested resource not found on server: ${req.originalUrl}`); + next(err); +}); + +app.use(errorHandler); diff --git a/microservices/hhgfdsdfghj/package.json b/microservices/hhgfdsdfghj/package.json new file mode 100644 index 0000000..f1e08f3 --- /dev/null +++ b/microservices/hhgfdsdfghj/package.json @@ -0,0 +1,46 @@ +{ + "name": "@microservices-suite/hhgfdsdfghj", + "version": "1.0.0", + "description": "This is the hhgfdsdfghj service. TODO: update this description", + "main": "index.js", + "author": "Gilbert", + "license": "MIT", + "dependencies": { + "@microservices-suite/config": "1.0.0", + "@microservices-suite/errors": "1.0.0", + "@microservices-suite/utilities": "1.0.7", + "@microservices-suite/broker": "1.0.0", + "dotenv": "^16.4.5", + "express": "^4.18.3", + "helmet": "^7.1.0", + "mongodb": "^6.5.0", + "mongoose": "^8.2.1", + "morgan": "^1.10.0", + "pm2": "^5.3.1", + "winston": "^3.12.0" + }, + "devDependencies": { + "nodemon": "^3.1.0" + }, + "workspaces": { + "nohoist": [ + "**/@microservices-suite/utilities/", + "**/@microservices-suite/utilities/**", + "**/@microservices-suite/errors/", + "**/@microservices-suite/errors/**", + "**/@microservices-suite/config/", + "**/@microservices-suite/config/**", + "**/@microservices-suite/broker/", + "**/@microservices-suite/broker/**" + ] + }, + "scripts": { + "release": "npx bumpp-version@latest && npm publish", + "dev": "NODE_ENV=dev nodemon --legacy-watch -q index.js", + "start": "pm2-runtime start ecosystem.config.js --env production", + "stoprod": "pm2 stop ecosystem.config.js", + "deletprod": "pm2 delete ecosystem.config.js", + "test": "jest" + }, + "private": true +} \ No newline at end of file diff --git a/microservices/hhgfdsdfghj/src/controllers/controllers.js b/microservices/hhgfdsdfghj/src/controllers/controllers.js new file mode 100644 index 0000000..315ff8d --- /dev/null +++ b/microservices/hhgfdsdfghj/src/controllers/controllers.js @@ -0,0 +1,52 @@ + +const services = require('../services/services'); +const { asyncErrorHandler, APIError } = require('@microservices-suite/utilities'); + +const createHhgfdsdfghj = asyncErrorHandler(async (req, res) => { + const { body } = req; + const { hhgfdsdfghj: data } = await services.createHhgfdsdfghj({ body }); + res.status(201).json({ data }); +}); + +const getHhgfdsdfghjs = asyncErrorHandler(async (req, res) => { + const { hhgfdsdfghjs: data } = await services.getHhgfdsdfghjs(); + res.status(200).json({ data }); +}); + +const getHhgfdsdfghj = asyncErrorHandler(async (req, res) => { + const { id } = req.params; + const { hhgfdsdfghj: data } = await services.getHhgfdsdfghjById({ id }); + if (!data) { + throw new APIError(404, 'hhgfdsdfghj not found'); + } + res.status(200).json({ data }); +}); + +const updateHhgfdsdfghj = asyncErrorHandler(async (req, res) => { + const { id } = req.params; + const { body } = req; + const { hhgfdsdfghj } = await services.getHhgfdsdfghjById({ id }); + if (!hhgfdsdfghj) { + throw new APIError(404, 'hhgfdsdfghj not found'); + } + const { upserted_hhgfdsdfghj: data } = await services.updateHhgfdsdfghjProfile({ id, body }); + res.status(200).json({ data }); +}); + +const deleteHhgfdsdfghj = asyncErrorHandler(async (req, res) => { + const { id } = req.params; + const { hhgfdsdfghj } = await services.getHhgfdsdfghjById({ id }); + if (!hhgfdsdfghj) { + throw new APIError(404, 'hhgfdsdfghj not found'); + } + await services.deleteHhgfdsdfghj({ id }); + res.status(200).json({ message: 'Deletion successful' }); +}); +module.exports = { + createHhgfdsdfghj, + getHhgfdsdfghjs, + getHhgfdsdfghj, + updateHhgfdsdfghj, + deleteHhgfdsdfghj +}; + diff --git a/microservices/hhgfdsdfghj/src/controllers/index.js b/microservices/hhgfdsdfghj/src/controllers/index.js new file mode 100644 index 0000000..f41caf5 --- /dev/null +++ b/microservices/hhgfdsdfghj/src/controllers/index.js @@ -0,0 +1,2 @@ +const { hello } = require('./controllers'); +module.exports = controllers; \ No newline at end of file diff --git a/microservices/hhgfdsdfghj/src/models/index.js b/microservices/hhgfdsdfghj/src/models/index.js new file mode 100644 index 0000000..b0d086a --- /dev/null +++ b/microservices/hhgfdsdfghj/src/models/index.js @@ -0,0 +1,2 @@ +const models = require('./model'); +module.exports = models; \ No newline at end of file diff --git a/microservices/hhgfdsdfghj/src/models/models.js b/microservices/hhgfdsdfghj/src/models/models.js new file mode 100644 index 0000000..098814e --- /dev/null +++ b/microservices/hhgfdsdfghj/src/models/models.js @@ -0,0 +1,16 @@ + +const mongoose = require('mongoose'); + +const hhgfdsdfghjSchema = new mongoose.Schema({ + name: { + type: String, + required: true, + } +} + , { + timestamps: true + }); + +const Hhgfdsdfghj = mongoose.model('hhgfdsdfghj', hhgfdsdfghjSchema); + +module.exports = Hhgfdsdfghj; diff --git a/microservices/hhgfdsdfghj/src/routes/index.js b/microservices/hhgfdsdfghj/src/routes/index.js new file mode 100644 index 0000000..c564440 --- /dev/null +++ b/microservices/hhgfdsdfghj/src/routes/index.js @@ -0,0 +1,2 @@ +const router = require('./routes'); +module.exports = { router }; \ No newline at end of file diff --git a/microservices/hhgfdsdfghj/src/routes/routes.js b/microservices/hhgfdsdfghj/src/routes/routes.js new file mode 100644 index 0000000..0e4c4e9 --- /dev/null +++ b/microservices/hhgfdsdfghj/src/routes/routes.js @@ -0,0 +1,20 @@ + +const express = require('express'); +const { validate } = require('@microservices-suite/utilities'); + +const hhgfdsdfghjController = require('../controllers/controllers'); + +const router = express.Router(); + +router + .route('/hhgfdsdfghjs') + .post(hhgfdsdfghjController.createHhgfdsdfghj) + .get(hhgfdsdfghjController.getHhgfdsdfghjs); + +router + .route('/hhgfdsdfghjs/:id') + .get(hhgfdsdfghjController.getHhgfdsdfghj) + .patch(hhgfdsdfghjController.updateHhgfdsdfghj) + .delete(hhgfdsdfghjController.deleteHhgfdsdfghj); + +module.exports = router; diff --git a/microservices/hhgfdsdfghj/src/services/index.js b/microservices/hhgfdsdfghj/src/services/index.js new file mode 100644 index 0000000..a099545 --- /dev/null +++ b/microservices/hhgfdsdfghj/src/services/index.js @@ -0,0 +1 @@ +module.exports = {}; \ No newline at end of file diff --git a/microservices/hhgfdsdfghj/src/services/services.js b/microservices/hhgfdsdfghj/src/services/services.js new file mode 100644 index 0000000..5ef57ac --- /dev/null +++ b/microservices/hhgfdsdfghj/src/services/services.js @@ -0,0 +1,34 @@ + +const { ObjectId } = require('mongodb'); +const Hhgfdsdfghj = require('../models/models'); + +const createHhgfdsdfghj = async ({ body }) => { + const hhgfdsdfghj = await Hhgfdsdfghj.create(body); + return { hhgfdsdfghj }; +}; + +const getHhgfdsdfghjs = async () => { + const hhgfdsdfghjs = await Hhgfdsdfghj.find({}); + return { hhgfdsdfghjs }; +}; + +const getHhgfdsdfghjById = async ({ id }) => { + const hhgfdsdfghj = await Hhgfdsdfghj.findById(id); + return { hhgfdsdfghj }; +}; + +const updateHhgfdsdfghjProfile = async ({ id, body }) => { + const upserted_hhgfdsdfghj = await Hhgfdsdfghj.updateOne({ _id: ObjectId(id) }, { ...body }, { upsert: false }); + return { upserted_hhgfdsdfghj }; +}; + +const deleteHhgfdsdfghj = async ({ id }) => { + await Hhgfdsdfghj.deleteOne({ _id: ObjectId(id) }); +}; +module.exports = { + createHhgfdsdfghj, + getHhgfdsdfghjs, + getHhgfdsdfghjById, + updateHhgfdsdfghjProfile, + deleteHhgfdsdfghj +}; diff --git a/microservices/hhgfdsdfghj/src/subscriber/index.js b/microservices/hhgfdsdfghj/src/subscriber/index.js new file mode 100644 index 0000000..8f99ac7 --- /dev/null +++ b/microservices/hhgfdsdfghj/src/subscriber/index.js @@ -0,0 +1 @@ +module.exports.subscriber = require('./subscriber'); \ No newline at end of file diff --git a/microservices/hhgfdsdfghj/src/subscriber/subscriber.js b/microservices/hhgfdsdfghj/src/subscriber/subscriber.js new file mode 100644 index 0000000..6a16274 --- /dev/null +++ b/microservices/hhgfdsdfghj/src/subscriber/subscriber.js @@ -0,0 +1,60 @@ + +const hhgfdsdfghjService = require('../services/services'); +const rabbitmq = require('@microservices-suite/broker/rabbitmq'); + +const subscribe = async ({ channel, config, routing_key }) => { + try { + const q = await channel.assertQueue('', { exclusive: true }); + console.log(`⚡️ ${routing_key}: successfully subscribed to exchange: ${config.exchange}`); + await channel.bindQueue(q.queue, config.exchange, routing_key); + await channel.consume(q.queue, async(msg) => { + if (msg !== null) { + const service = msg.fields.routingKey; + console.log("Message received [x] %s: '%s'", msg.fields.routingKey, msg.content.toString()); + await subscriberHandler({ channel, msg, service, config }); + } + }, { noAck: false }); + } catch (error) { + throw new APIError(500, `Failed to set up subscriber ${error.message}`); + } +}; + +const subscriberHandler = async ({ channel, msg, service, config }) => { + const messageContent = JSON.parse(msg.content.toString()); // Parse the message content + const { action, body } = messageContent; // Destructure type and body from the parsed content + let data; + let auth; + switch (action) { + case 'create': + try { + await hhgfdsdfghjService.createHhgfdsdfghj({ body }) + } catch (error) { + //TODO: handle this case. Eg do we roll back or what next.. + console.log(`hhgfdsdfghj: subscriber-failed to create hhgfdsdfghj: ${error.message}`); + + console.log({ error }); + } + break; + // TODO: use rpc for read operations + case 'read': + const { hhgfdsdfghjs } = await hhgfdsdfghjService.getHhgfdsdfghjs(); + data = hhgfdsdfghjs; + await rabbitmq.workerQueue.sendToQueue({ data, queue: service, config }); + break; + case 'read:id': + hhgfdsdfghj = await hhgfdsdfghjService.getHhgfdsdfghjById({ id: body.id }); + hhgfdsdfghj = hhgfdsdfghj.hhgfdsdfghj; + await rabbitmq.workerQueue.sendToQueue({ data, queue: service, config }); + break; + case 'update': + break; + case 'delete': + break; + default: + channel.ack(msg); + } +} +module.exports = { + subscriberHandler, + subscribe +}; diff --git a/microservices/kjhgf/.dockerignore b/microservices/kjhgf/.dockerignore new file mode 100644 index 0000000..25a56cf --- /dev/null +++ b/microservices/kjhgf/.dockerignore @@ -0,0 +1,5 @@ + +#These files wont be sent to the docker builder during the COPY . . command + +node_modules +bar diff --git a/microservices/kjhgf/Dockerfile.dev b/microservices/kjhgf/Dockerfile.dev new file mode 100644 index 0000000..8f85789 --- /dev/null +++ b/microservices/kjhgf/Dockerfile.dev @@ -0,0 +1,12 @@ + +FROM node:18-alpine3.18 + +WORKDIR /app + +COPY package.json . + +RUN yarn install + +COPY . . + +CMD [ "yarn","dev" ] diff --git a/microservices/kjhgf/ecosystem.config.js b/microservices/kjhgf/ecosystem.config.js new file mode 100644 index 0000000..1fe9070 --- /dev/null +++ b/microservices/kjhgf/ecosystem.config.js @@ -0,0 +1,26 @@ + +module.exports = { + apps : [{ + name : kjhgf, + autorestart: true, + watch: true, + time: true, + script : "./index.js", + instances:4, + env_production: { + NODE_ENV: "prod", + DATABASE_URL:"mongodb://mongodb:27017/microservices-suite_kjhgf_proddb", + EXCHANGE:@microservices-suite, + AMQP_HOST:"amqp://rabbitmq:5672", + PORT:9021 + }, + env_development: { + NODE_ENV: "dev", + DATABASE_URL:"mongodb://mongodb:27017/microservices-suite_kjhgf_devdb", + EXCHANGE:@microservices-suite, + AMQP_HOST:"amqp://rabbitmq:5672", + PORT:9021 + } + }] + } + diff --git a/microservices/kjhgf/index.js b/microservices/kjhgf/index.js new file mode 100644 index 0000000..e71a08d --- /dev/null +++ b/microservices/kjhgf/index.js @@ -0,0 +1,65 @@ + +const http = require('http'); +const express = require('express'); +const mongoose = require('mongoose'); +const { config, morgan, logger } = require('@microservices-suite/config'); +const { errorHandler } = require('@microservices-suite/errors'); +const { validate, APIError } = require('@microservices-suite/utilities'); +const { getUsers } = require('./src/services'); +const { router } = require('./src/routes'); +const { subscriber } = require('./src/subscriber'); +const rabbitmq = require('@microservices-suite/broker/rabbitmq'); +// const app = require('./src/app'); + +mongoose.connect(config.db).then(() => { + logger.info(`📀 successfully connected to db: ${config.db}`); +}).catch(err => { + logger.error(`failed to connect to db. Exiting... ${err.message}`); + process.exit(0); +}); + +const app = express(); + +app.use(express.json()); + +app.get('/', (req, res) => { + res.json({ message: 'hello from @microservices-suite/kjhgf' }); +}); + +const server = http.createServer(app); + +server.on('error', (err) => { + logger.error(err); + if (err.code === 'EADDRINUSE') { + logger.error('Address already in use, retrying...'); + setTimeout(() => { + server.close(); + server.listen(config.port, 'localhost'); + }, 1000); + errorHandler(err); + } +}); + +server.listen(config.port, async() => { + logger.info(`🚀 @microservices-suite/kjhgf listening at: http://localhost:${config.port}`); + const channel = await rabbitmq.workerQueue.amqpInitializeQueue({ config }); + await rabbitmq.workerQueue.consumeFromQueue({ + channel, + queue: 'kjhgf', + subscriberHandler: subscriber.subscriberHandler + }); +}); + +app.use(morgan.errorHandler); + +app.use(morgan.successHandler); + +app.use('/api/v1', router); + +// Global error handler should come after all other middlewares +app.all('*', (req, res, next) => { + const err = new APIError(404, `requested resource not found on server: ${req.originalUrl}`); + next(err); +}); + +app.use(errorHandler); diff --git a/microservices/kjhgf/package.json b/microservices/kjhgf/package.json new file mode 100644 index 0000000..ec58610 --- /dev/null +++ b/microservices/kjhgf/package.json @@ -0,0 +1,46 @@ +{ + "name": "@microservices-suite/kjhgf", + "version": "1.0.0", + "description": "This is the kjhgf service. TODO: update this description", + "main": "index.js", + "author": "Gilbert", + "license": "MIT", + "dependencies": { + "@microservices-suite/config": "1.0.0", + "@microservices-suite/errors": "1.0.0", + "@microservices-suite/utilities": "1.0.7", + "@microservices-suite/broker": "1.0.0", + "dotenv": "^16.4.5", + "express": "^4.18.3", + "helmet": "^7.1.0", + "mongodb": "^6.5.0", + "mongoose": "^8.2.1", + "morgan": "^1.10.0", + "pm2": "^5.3.1", + "winston": "^3.12.0" + }, + "devDependencies": { + "nodemon": "^3.1.0" + }, + "workspaces": { + "nohoist": [ + "**/@microservices-suite/utilities/", + "**/@microservices-suite/utilities/**", + "**/@microservices-suite/errors/", + "**/@microservices-suite/errors/**", + "**/@microservices-suite/config/", + "**/@microservices-suite/config/**", + "**/@microservices-suite/broker/", + "**/@microservices-suite/broker/**" + ] + }, + "scripts": { + "release": "npx bumpp-version@latest && npm publish", + "dev": "NODE_ENV=dev nodemon --legacy-watch -q index.js", + "start": "pm2-runtime start ecosystem.config.js --env production", + "stoprod": "pm2 stop ecosystem.config.js", + "deletprod": "pm2 delete ecosystem.config.js", + "test": "jest" + }, + "private": true +} \ No newline at end of file diff --git a/microservices/kjhgf/src/controllers/controllers.js b/microservices/kjhgf/src/controllers/controllers.js new file mode 100644 index 0000000..c18e4c7 --- /dev/null +++ b/microservices/kjhgf/src/controllers/controllers.js @@ -0,0 +1,52 @@ + +const services = require('../services/services'); +const { asyncErrorHandler, APIError } = require('@microservices-suite/utilities'); + +const createKjhgf = asyncErrorHandler(async (req, res) => { + const { body } = req; + const { kjhgf: data } = await services.createKjhgf({ body }); + res.status(201).json({ data }); +}); + +const getKjhgfs = asyncErrorHandler(async (req, res) => { + const { kjhgfs: data } = await services.getKjhgfs(); + res.status(200).json({ data }); +}); + +const getKjhgf = asyncErrorHandler(async (req, res) => { + const { id } = req.params; + const { kjhgf: data } = await services.getKjhgfById({ id }); + if (!data) { + throw new APIError(404, 'kjhgf not found'); + } + res.status(200).json({ data }); +}); + +const updateKjhgf = asyncErrorHandler(async (req, res) => { + const { id } = req.params; + const { body } = req; + const { kjhgf } = await services.getKjhgfById({ id }); + if (!kjhgf) { + throw new APIError(404, 'kjhgf not found'); + } + const { upserted_kjhgf: data } = await services.updateKjhgfProfile({ id, body }); + res.status(200).json({ data }); +}); + +const deleteKjhgf = asyncErrorHandler(async (req, res) => { + const { id } = req.params; + const { kjhgf } = await services.getKjhgfById({ id }); + if (!kjhgf) { + throw new APIError(404, 'kjhgf not found'); + } + await services.deleteKjhgf({ id }); + res.status(200).json({ message: 'Deletion successful' }); +}); +module.exports = { + createKjhgf, + getKjhgfs, + getKjhgf, + updateKjhgf, + deleteKjhgf +}; + diff --git a/microservices/kjhgf/src/controllers/index.js b/microservices/kjhgf/src/controllers/index.js new file mode 100644 index 0000000..f41caf5 --- /dev/null +++ b/microservices/kjhgf/src/controllers/index.js @@ -0,0 +1,2 @@ +const { hello } = require('./controllers'); +module.exports = controllers; \ No newline at end of file diff --git a/microservices/kjhgf/src/models/index.js b/microservices/kjhgf/src/models/index.js new file mode 100644 index 0000000..b0d086a --- /dev/null +++ b/microservices/kjhgf/src/models/index.js @@ -0,0 +1,2 @@ +const models = require('./model'); +module.exports = models; \ No newline at end of file diff --git a/microservices/kjhgf/src/models/models.js b/microservices/kjhgf/src/models/models.js new file mode 100644 index 0000000..3fe3c31 --- /dev/null +++ b/microservices/kjhgf/src/models/models.js @@ -0,0 +1,16 @@ + +const mongoose = require('mongoose'); + +const kjhgfSchema = new mongoose.Schema({ + name: { + type: String, + required: true, + } +} + , { + timestamps: true + }); + +const Kjhgf = mongoose.model('kjhgf', kjhgfSchema); + +module.exports = Kjhgf; diff --git a/microservices/kjhgf/src/routes/index.js b/microservices/kjhgf/src/routes/index.js new file mode 100644 index 0000000..c564440 --- /dev/null +++ b/microservices/kjhgf/src/routes/index.js @@ -0,0 +1,2 @@ +const router = require('./routes'); +module.exports = { router }; \ No newline at end of file diff --git a/microservices/kjhgf/src/routes/routes.js b/microservices/kjhgf/src/routes/routes.js new file mode 100644 index 0000000..edd8f13 --- /dev/null +++ b/microservices/kjhgf/src/routes/routes.js @@ -0,0 +1,20 @@ + +const express = require('express'); +const { validate } = require('@microservices-suite/utilities'); + +const kjhgfController = require('../controllers/controllers'); + +const router = express.Router(); + +router + .route('/kjhgfs') + .post(kjhgfController.createKjhgf) + .get(kjhgfController.getKjhgfs); + +router + .route('/kjhgfs/:id') + .get(kjhgfController.getKjhgf) + .patch(kjhgfController.updateKjhgf) + .delete(kjhgfController.deleteKjhgf); + +module.exports = router; diff --git a/microservices/kjhgf/src/services/index.js b/microservices/kjhgf/src/services/index.js new file mode 100644 index 0000000..a099545 --- /dev/null +++ b/microservices/kjhgf/src/services/index.js @@ -0,0 +1 @@ +module.exports = {}; \ No newline at end of file diff --git a/microservices/kjhgf/src/services/services.js b/microservices/kjhgf/src/services/services.js new file mode 100644 index 0000000..2af299e --- /dev/null +++ b/microservices/kjhgf/src/services/services.js @@ -0,0 +1,34 @@ + +const { ObjectId } = require('mongodb'); +const Kjhgf = require('../models/models'); + +const createKjhgf = async ({ body }) => { + const kjhgf = await Kjhgf.create(body); + return { kjhgf }; +}; + +const getKjhgfs = async () => { + const kjhgfs = await Kjhgf.find({}); + return { kjhgfs }; +}; + +const getKjhgfById = async ({ id }) => { + const kjhgf = await Kjhgf.findById(id); + return { kjhgf }; +}; + +const updateKjhgfProfile = async ({ id, body }) => { + const upserted_kjhgf = await Kjhgf.updateOne({ _id: ObjectId(id) }, { ...body }, { upsert: false }); + return { upserted_kjhgf }; +}; + +const deleteKjhgf = async ({ id }) => { + await Kjhgf.deleteOne({ _id: ObjectId(id) }); +}; +module.exports = { + createKjhgf, + getKjhgfs, + getKjhgfById, + updateKjhgfProfile, + deleteKjhgf +}; diff --git a/microservices/kjhgf/src/subscriber/index.js b/microservices/kjhgf/src/subscriber/index.js new file mode 100644 index 0000000..8f99ac7 --- /dev/null +++ b/microservices/kjhgf/src/subscriber/index.js @@ -0,0 +1 @@ +module.exports.subscriber = require('./subscriber'); \ No newline at end of file diff --git a/microservices/kjhgf/src/subscriber/subscriber.js b/microservices/kjhgf/src/subscriber/subscriber.js new file mode 100644 index 0000000..863005d --- /dev/null +++ b/microservices/kjhgf/src/subscriber/subscriber.js @@ -0,0 +1,60 @@ + +const kjhgfService = require('../services/services'); +const rabbitmq = require('@microservices-suite/broker/rabbitmq'); + +const subscribe = async ({ channel, config, routing_key }) => { + try { + const q = await channel.assertQueue('', { exclusive: true }); + console.log(`⚡️ ${routing_key}: successfully subscribed to exchange: ${config.exchange}`); + await channel.bindQueue(q.queue, config.exchange, routing_key); + await channel.consume(q.queue, async(msg) => { + if (msg !== null) { + const service = msg.fields.routingKey; + console.log("Message received [x] %s: '%s'", msg.fields.routingKey, msg.content.toString()); + await subscriberHandler({ channel, msg, service, config }); + } + }, { noAck: false }); + } catch (error) { + throw new APIError(500, `Failed to set up subscriber ${error.message}`); + } +}; + +const subscriberHandler = async ({ channel, msg, service, config }) => { + const messageContent = JSON.parse(msg.content.toString()); // Parse the message content + const { action, body } = messageContent; // Destructure type and body from the parsed content + let data; + let auth; + switch (action) { + case 'create': + try { + await kjhgfService.createKjhgf({ body }) + } catch (error) { + //TODO: handle this case. Eg do we roll back or what next.. + console.log(`kjhgf: subscriber-failed to create kjhgf: ${error.message}`); + + console.log({ error }); + } + break; + // TODO: use rpc for read operations + case 'read': + const { kjhgfs } = await kjhgfService.getKjhgfs(); + data = kjhgfs; + await rabbitmq.workerQueue.sendToQueue({ data, queue: service, config }); + break; + case 'read:id': + kjhgf = await kjhgfService.getKjhgfById({ id: body.id }); + kjhgf = kjhgf.kjhgf; + await rabbitmq.workerQueue.sendToQueue({ data, queue: service, config }); + break; + case 'update': + break; + case 'delete': + break; + default: + channel.ack(msg); + } +} +module.exports = { + subscriberHandler, + subscribe +}; diff --git a/microservices/notification/ecosystem.config.js b/microservices/notification/ecosystem.config.js index 3d8a0ae..7a7486c 100644 --- a/microservices/notification/ecosystem.config.js +++ b/microservices/notification/ecosystem.config.js @@ -1,7 +1,7 @@ module.exports = { apps : [{ - name : notification, + name : "notification", autorestart: true, watch: true, time: true, @@ -9,16 +9,16 @@ module.exports = { instances:4, env_production: { NODE_ENV: "prod", - DATABASE_URL="mongodb://mongodb:27017/microservices-suite_notification_proddb", - EXCHANGE="@monorepo", - AMQP_HOST="amqp://rabbitmq:5672", + DATABASE_URL:"mongodb://mongodb:27017/microservices-suite_notification_proddb", + EXCHANGE:"@microservices-suite", + AMQP_HOST:"amqp://rabbitmq:5672", PORT:9014 }, env_development: { NODE_ENV: "dev", - DATABASE_URL="mongodb://mongodb:27017/microservices-suite_notification_devdb", - EXCHANGE="@monorepo", - AMQP_HOST="amqp://rabbitmq:5672", + DATABASE_URL:"mongodb://mongodb:27017/microservices-suite_notification_devdb", + EXCHANGE:"@microservices-suite", + AMQP_HOST:"amqp://rabbitmq:5672", PORT:9014 } }] diff --git a/microservices/shjksgd/.dockerignore b/microservices/shjksgd/.dockerignore new file mode 100644 index 0000000..25a56cf --- /dev/null +++ b/microservices/shjksgd/.dockerignore @@ -0,0 +1,5 @@ + +#These files wont be sent to the docker builder during the COPY . . command + +node_modules +bar diff --git a/microservices/shjksgd/Dockerfile.dev b/microservices/shjksgd/Dockerfile.dev new file mode 100644 index 0000000..8f85789 --- /dev/null +++ b/microservices/shjksgd/Dockerfile.dev @@ -0,0 +1,12 @@ + +FROM node:18-alpine3.18 + +WORKDIR /app + +COPY package.json . + +RUN yarn install + +COPY . . + +CMD [ "yarn","dev" ] diff --git a/microservices/shjksgd/ecosystem.config.js b/microservices/shjksgd/ecosystem.config.js new file mode 100644 index 0000000..e2748f6 --- /dev/null +++ b/microservices/shjksgd/ecosystem.config.js @@ -0,0 +1,26 @@ + +module.exports = { + apps : [{ + name : shjksgd, + autorestart: true, + watch: true, + time: true, + script : "./index.js", + instances:4, + env_production: { + NODE_ENV: "prod", + DATABASE_URL:"mongodb://mongodb:27017/microservices-suite_shjksgd_proddb", + EXCHANGE:@microservices-suite, + AMQP_HOST:"amqp://rabbitmq:5672", + PORT:30067 + }, + env_development: { + NODE_ENV: "dev", + DATABASE_URL:"mongodb://mongodb:27017/microservices-suite_shjksgd_devdb", + EXCHANGE:@microservices-suite, + AMQP_HOST:"amqp://rabbitmq:5672", + PORT:30067 + } + }] + } + diff --git a/microservices/shjksgd/index.js b/microservices/shjksgd/index.js new file mode 100644 index 0000000..e7d6d50 --- /dev/null +++ b/microservices/shjksgd/index.js @@ -0,0 +1,65 @@ + +const http = require('http'); +const express = require('express'); +const mongoose = require('mongoose'); +const { config, morgan, logger } = require('@microservices-suite/config'); +const { errorHandler } = require('@microservices-suite/errors'); +const { validate, APIError } = require('@microservices-suite/utilities'); +const { getUsers } = require('./src/services'); +const { router } = require('./src/routes'); +const { subscriber } = require('./src/subscriber'); +const rabbitmq = require('@microservices-suite/broker/rabbitmq'); +// const app = require('./src/app'); + +mongoose.connect(config.db).then(() => { + logger.info(`📀 successfully connected to db: ${config.db}`); +}).catch(err => { + logger.error(`failed to connect to db. Exiting... ${err.message}`); + process.exit(0); +}); + +const app = express(); + +app.use(express.json()); + +app.get('/', (req, res) => { + res.json({ message: 'hello from @microservices-suite/shjksgd' }); +}); + +const server = http.createServer(app); + +server.on('error', (err) => { + logger.error(err); + if (err.code === 'EADDRINUSE') { + logger.error('Address already in use, retrying...'); + setTimeout(() => { + server.close(); + server.listen(config.port, 'localhost'); + }, 1000); + errorHandler(err); + } +}); + +server.listen(config.port, async() => { + logger.info(`🚀 @microservices-suite/shjksgd listening at: http://localhost:${config.port}`); + const channel = await rabbitmq.workerQueue.amqpInitializeQueue({ config }); + await rabbitmq.workerQueue.consumeFromQueue({ + channel, + queue: 'shjksgd', + subscriberHandler: subscriber.subscriberHandler + }); +}); + +app.use(morgan.errorHandler); + +app.use(morgan.successHandler); + +app.use('/api/v1', router); + +// Global error handler should come after all other middlewares +app.all('*', (req, res, next) => { + const err = new APIError(404, `requested resource not found on server: ${req.originalUrl}`); + next(err); +}); + +app.use(errorHandler); diff --git a/microservices/shjksgd/package.json b/microservices/shjksgd/package.json new file mode 100644 index 0000000..2bcd4e6 --- /dev/null +++ b/microservices/shjksgd/package.json @@ -0,0 +1,46 @@ +{ + "name": "@microservices-suite/shjksgd", + "version": "1.0.0", + "description": "This is the shjksgd service. TODO: update this description", + "main": "index.js", + "author": "Gilbert", + "license": "MIT", + "dependencies": { + "@microservices-suite/config": "1.0.0", + "@microservices-suite/errors": "1.0.0", + "@microservices-suite/utilities": "1.0.7", + "@microservices-suite/broker": "1.0.0", + "dotenv": "^16.4.5", + "express": "^4.18.3", + "helmet": "^7.1.0", + "mongodb": "^6.5.0", + "mongoose": "^8.2.1", + "morgan": "^1.10.0", + "pm2": "^5.3.1", + "winston": "^3.12.0" + }, + "devDependencies": { + "nodemon": "^3.1.0" + }, + "workspaces": { + "nohoist": [ + "**/@microservices-suite/utilities/", + "**/@microservices-suite/utilities/**", + "**/@microservices-suite/errors/", + "**/@microservices-suite/errors/**", + "**/@microservices-suite/config/", + "**/@microservices-suite/config/**", + "**/@microservices-suite/broker/", + "**/@microservices-suite/broker/**" + ] + }, + "scripts": { + "release": "npx bumpp-version@latest && npm publish", + "dev": "NODE_ENV=dev nodemon --legacy-watch -q index.js", + "start": "pm2-runtime start ecosystem.config.js --env production", + "stoprod": "pm2 stop ecosystem.config.js", + "deletprod": "pm2 delete ecosystem.config.js", + "test": "jest" + }, + "private": true +} \ No newline at end of file diff --git a/microservices/shjksgd/src/controllers/controllers.js b/microservices/shjksgd/src/controllers/controllers.js new file mode 100644 index 0000000..dfb27f6 --- /dev/null +++ b/microservices/shjksgd/src/controllers/controllers.js @@ -0,0 +1,52 @@ + +const services = require('../services/services'); +const { asyncErrorHandler, APIError } = require('@microservices-suite/utilities'); + +const createShjksgd = asyncErrorHandler(async (req, res) => { + const { body } = req; + const { shjksgd: data } = await services.createShjksgd({ body }); + res.status(201).json({ data }); +}); + +const getShjksgds = asyncErrorHandler(async (req, res) => { + const { shjksgds: data } = await services.getShjksgds(); + res.status(200).json({ data }); +}); + +const getShjksgd = asyncErrorHandler(async (req, res) => { + const { id } = req.params; + const { shjksgd: data } = await services.getShjksgdById({ id }); + if (!data) { + throw new APIError(404, 'shjksgd not found'); + } + res.status(200).json({ data }); +}); + +const updateShjksgd = asyncErrorHandler(async (req, res) => { + const { id } = req.params; + const { body } = req; + const { shjksgd } = await services.getShjksgdById({ id }); + if (!shjksgd) { + throw new APIError(404, 'shjksgd not found'); + } + const { upserted_shjksgd: data } = await services.updateShjksgdProfile({ id, body }); + res.status(200).json({ data }); +}); + +const deleteShjksgd = asyncErrorHandler(async (req, res) => { + const { id } = req.params; + const { shjksgd } = await services.getShjksgdById({ id }); + if (!shjksgd) { + throw new APIError(404, 'shjksgd not found'); + } + await services.deleteShjksgd({ id }); + res.status(200).json({ message: 'Deletion successful' }); +}); +module.exports = { + createShjksgd, + getShjksgds, + getShjksgd, + updateShjksgd, + deleteShjksgd +}; + diff --git a/microservices/shjksgd/src/controllers/index.js b/microservices/shjksgd/src/controllers/index.js new file mode 100644 index 0000000..f41caf5 --- /dev/null +++ b/microservices/shjksgd/src/controllers/index.js @@ -0,0 +1,2 @@ +const { hello } = require('./controllers'); +module.exports = controllers; \ No newline at end of file diff --git a/microservices/shjksgd/src/models/index.js b/microservices/shjksgd/src/models/index.js new file mode 100644 index 0000000..b0d086a --- /dev/null +++ b/microservices/shjksgd/src/models/index.js @@ -0,0 +1,2 @@ +const models = require('./model'); +module.exports = models; \ No newline at end of file diff --git a/microservices/shjksgd/src/models/models.js b/microservices/shjksgd/src/models/models.js new file mode 100644 index 0000000..28ed1a3 --- /dev/null +++ b/microservices/shjksgd/src/models/models.js @@ -0,0 +1,16 @@ + +const mongoose = require('mongoose'); + +const shjksgdSchema = new mongoose.Schema({ + name: { + type: String, + required: true, + } +} + , { + timestamps: true + }); + +const Shjksgd = mongoose.model('shjksgd', shjksgdSchema); + +module.exports = Shjksgd; diff --git a/microservices/shjksgd/src/routes/index.js b/microservices/shjksgd/src/routes/index.js new file mode 100644 index 0000000..c564440 --- /dev/null +++ b/microservices/shjksgd/src/routes/index.js @@ -0,0 +1,2 @@ +const router = require('./routes'); +module.exports = { router }; \ No newline at end of file diff --git a/microservices/shjksgd/src/routes/routes.js b/microservices/shjksgd/src/routes/routes.js new file mode 100644 index 0000000..01c5304 --- /dev/null +++ b/microservices/shjksgd/src/routes/routes.js @@ -0,0 +1,20 @@ + +const express = require('express'); +const { validate } = require('@microservices-suite/utilities'); + +const shjksgdController = require('../controllers/controllers'); + +const router = express.Router(); + +router + .route('/shjksgds') + .post(shjksgdController.createShjksgd) + .get(shjksgdController.getShjksgds); + +router + .route('/shjksgds/:id') + .get(shjksgdController.getShjksgd) + .patch(shjksgdController.updateShjksgd) + .delete(shjksgdController.deleteShjksgd); + +module.exports = router; diff --git a/microservices/shjksgd/src/services/index.js b/microservices/shjksgd/src/services/index.js new file mode 100644 index 0000000..a099545 --- /dev/null +++ b/microservices/shjksgd/src/services/index.js @@ -0,0 +1 @@ +module.exports = {}; \ No newline at end of file diff --git a/microservices/shjksgd/src/services/services.js b/microservices/shjksgd/src/services/services.js new file mode 100644 index 0000000..d206183 --- /dev/null +++ b/microservices/shjksgd/src/services/services.js @@ -0,0 +1,34 @@ + +const { ObjectId } = require('mongodb'); +const Shjksgd = require('../models/models'); + +const createShjksgd = async ({ body }) => { + const shjksgd = await Shjksgd.create(body); + return { shjksgd }; +}; + +const getShjksgds = async () => { + const shjksgds = await Shjksgd.find({}); + return { shjksgds }; +}; + +const getShjksgdById = async ({ id }) => { + const shjksgd = await Shjksgd.findById(id); + return { shjksgd }; +}; + +const updateShjksgdProfile = async ({ id, body }) => { + const upserted_shjksgd = await Shjksgd.updateOne({ _id: ObjectId(id) }, { ...body }, { upsert: false }); + return { upserted_shjksgd }; +}; + +const deleteShjksgd = async ({ id }) => { + await Shjksgd.deleteOne({ _id: ObjectId(id) }); +}; +module.exports = { + createShjksgd, + getShjksgds, + getShjksgdById, + updateShjksgdProfile, + deleteShjksgd +}; diff --git a/microservices/shjksgd/src/subscriber/index.js b/microservices/shjksgd/src/subscriber/index.js new file mode 100644 index 0000000..8f99ac7 --- /dev/null +++ b/microservices/shjksgd/src/subscriber/index.js @@ -0,0 +1 @@ +module.exports.subscriber = require('./subscriber'); \ No newline at end of file diff --git a/microservices/shjksgd/src/subscriber/subscriber.js b/microservices/shjksgd/src/subscriber/subscriber.js new file mode 100644 index 0000000..5da0fff --- /dev/null +++ b/microservices/shjksgd/src/subscriber/subscriber.js @@ -0,0 +1,60 @@ + +const shjksgdService = require('../services/services'); +const rabbitmq = require('@microservices-suite/broker/rabbitmq'); + +const subscribe = async ({ channel, config, routing_key }) => { + try { + const q = await channel.assertQueue('', { exclusive: true }); + console.log(`⚡️ ${routing_key}: successfully subscribed to exchange: ${config.exchange}`); + await channel.bindQueue(q.queue, config.exchange, routing_key); + await channel.consume(q.queue, async(msg) => { + if (msg !== null) { + const service = msg.fields.routingKey; + console.log("Message received [x] %s: '%s'", msg.fields.routingKey, msg.content.toString()); + await subscriberHandler({ channel, msg, service, config }); + } + }, { noAck: false }); + } catch (error) { + throw new APIError(500, `Failed to set up subscriber ${error.message}`); + } +}; + +const subscriberHandler = async ({ channel, msg, service, config }) => { + const messageContent = JSON.parse(msg.content.toString()); // Parse the message content + const { action, body } = messageContent; // Destructure type and body from the parsed content + let data; + let auth; + switch (action) { + case 'create': + try { + await shjksgdService.createShjksgd({ body }) + } catch (error) { + //TODO: handle this case. Eg do we roll back or what next.. + console.log(`shjksgd: subscriber-failed to create shjksgd: ${error.message}`); + + console.log({ error }); + } + break; + // TODO: use rpc for read operations + case 'read': + const { shjksgds } = await shjksgdService.getShjksgds(); + data = shjksgds; + await rabbitmq.workerQueue.sendToQueue({ data, queue: service, config }); + break; + case 'read:id': + shjksgd = await shjksgdService.getShjksgdById({ id: body.id }); + shjksgd = shjksgd.shjksgd; + await rabbitmq.workerQueue.sendToQueue({ data, queue: service, config }); + break; + case 'update': + break; + case 'delete': + break; + default: + channel.ack(msg); + } +} +module.exports = { + subscriberHandler, + subscribe +}; diff --git a/microservices/test/.dockerignore b/microservices/test/.dockerignore new file mode 100644 index 0000000..25a56cf --- /dev/null +++ b/microservices/test/.dockerignore @@ -0,0 +1,5 @@ + +#These files wont be sent to the docker builder during the COPY . . command + +node_modules +bar diff --git a/microservices/test/Dockerfile.dev b/microservices/test/Dockerfile.dev new file mode 100644 index 0000000..8f85789 --- /dev/null +++ b/microservices/test/Dockerfile.dev @@ -0,0 +1,12 @@ + +FROM node:18-alpine3.18 + +WORKDIR /app + +COPY package.json . + +RUN yarn install + +COPY . . + +CMD [ "yarn","dev" ] diff --git a/microservices/test/ecosystem.config.js b/microservices/test/ecosystem.config.js new file mode 100644 index 0000000..5f1c29b --- /dev/null +++ b/microservices/test/ecosystem.config.js @@ -0,0 +1,26 @@ + +module.exports = { + apps : [{ + name : "test", + autorestart: true, + watch: true, + time: true, + script : "./index.js", + instances:4, + env_production: { + NODE_ENV: "prod", + DATABASE_URL:"mongodb://mongodb:27017/microservices-suite_test_proddb", + EXCHANGE:"@microservices-suite", + AMQP_HOST:"amqp://rabbitmq:5672", + PORT:30068 + }, + env_development: { + NODE_ENV: "dev", + DATABASE_URL:"mongodb://mongodb:27017/microservices-suite_test_devdb", + EXCHANGE:"@microservices-suite", + AMQP_HOST:"amqp://rabbitmq:5672", + PORT:30068 + } + }] + } + diff --git a/microservices/test/index.js b/microservices/test/index.js new file mode 100644 index 0000000..f3c32d3 --- /dev/null +++ b/microservices/test/index.js @@ -0,0 +1,65 @@ + +const http = require('http'); +const express = require('express'); +const mongoose = require('mongoose'); +const { config, morgan, logger } = require('@microservices-suite/config'); +const { errorHandler } = require('@microservices-suite/errors'); +const { validate, APIError } = require('@microservices-suite/utilities'); +const { getUsers } = require('./src/services'); +const { router } = require('./src/routes'); +const { subscriber } = require('./src/subscriber'); +const rabbitmq = require('@microservices-suite/broker/rabbitmq'); +// const app = require('./src/app'); + +mongoose.connect(config.db).then(() => { + logger.info(`📀 successfully connected to db: ${config.db}`); +}).catch(err => { + logger.error(`failed to connect to db. Exiting... ${err.message}`); + process.exit(0); +}); + +const app = express(); + +app.use(express.json()); + +app.get('/', (req, res) => { + res.json({ message: 'hello from @microservices-suite/test' }); +}); + +const server = http.createServer(app); + +server.on('error', (err) => { + logger.error(err); + if (err.code === 'EADDRINUSE') { + logger.error('Address already in use, retrying...'); + setTimeout(() => { + server.close(); + server.listen(config.port, 'localhost'); + }, 1000); + errorHandler(err); + } +}); + +server.listen(config.port, async() => { + logger.info(`🚀 @microservices-suite/test listening at: http://localhost:${config.port}`); + const channel = await rabbitmq.workerQueue.amqpInitializeQueue({ config }); + await rabbitmq.workerQueue.consumeFromQueue({ + channel, + queue: 'test', + subscriberHandler: subscriber.subscriberHandler + }); +}); + +app.use(morgan.errorHandler); + +app.use(morgan.successHandler); + +app.use('/api/v1', router); + +// Global error handler should come after all other middlewares +app.all('*', (req, res, next) => { + const err = new APIError(404, `requested resource not found on server: ${req.originalUrl}`); + next(err); +}); + +app.use(errorHandler); diff --git a/microservices/test/package.json b/microservices/test/package.json new file mode 100644 index 0000000..a40c2d2 --- /dev/null +++ b/microservices/test/package.json @@ -0,0 +1,46 @@ +{ + "name": "@microservices-suite/test", + "version": "1.0.0", + "description": "This is the test service. TODO: update this description", + "main": "index.js", + "author": "Gilbert", + "license": "MIT", + "dependencies": { + "@microservices-suite/config": "1.0.0", + "@microservices-suite/errors": "1.0.0", + "@microservices-suite/utilities": "1.0.7", + "@microservices-suite/broker": "1.0.0", + "dotenv": "^16.4.5", + "express": "^4.18.3", + "helmet": "^7.1.0", + "mongodb": "^6.5.0", + "mongoose": "^8.2.1", + "morgan": "^1.10.0", + "pm2": "^5.3.1", + "winston": "^3.12.0" + }, + "devDependencies": { + "nodemon": "^3.1.0" + }, + "workspaces": { + "nohoist": [ + "**/@microservices-suite/utilities/", + "**/@microservices-suite/utilities/**", + "**/@microservices-suite/errors/", + "**/@microservices-suite/errors/**", + "**/@microservices-suite/config/", + "**/@microservices-suite/config/**", + "**/@microservices-suite/broker/", + "**/@microservices-suite/broker/**" + ] + }, + "scripts": { + "release": "npx bumpp-version@latest && npm publish", + "dev": "NODE_ENV=dev nodemon --legacy-watch -q index.js", + "start": "pm2-runtime start ecosystem.config.js --env production", + "stoprod": "pm2 stop ecosystem.config.js", + "deletprod": "pm2 delete ecosystem.config.js", + "test": "jest" + }, + "private": true +} \ No newline at end of file diff --git a/microservices/test/src/controllers/controllers.js b/microservices/test/src/controllers/controllers.js new file mode 100644 index 0000000..64bc560 --- /dev/null +++ b/microservices/test/src/controllers/controllers.js @@ -0,0 +1,52 @@ + +const services = require('../services/services'); +const { asyncErrorHandler, APIError } = require('@microservices-suite/utilities'); + +const createTest = asyncErrorHandler(async (req, res) => { + const { body } = req; + const { test: data } = await services.createTest({ body }); + res.status(201).json({ data }); +}); + +const getTests = asyncErrorHandler(async (req, res) => { + const { tests: data } = await services.getTests(); + res.status(200).json({ data }); +}); + +const getTest = asyncErrorHandler(async (req, res) => { + const { id } = req.params; + const { test: data } = await services.getTestById({ id }); + if (!data) { + throw new APIError(404, 'test not found'); + } + res.status(200).json({ data }); +}); + +const updateTest = asyncErrorHandler(async (req, res) => { + const { id } = req.params; + const { body } = req; + const { test } = await services.getTestById({ id }); + if (!test) { + throw new APIError(404, 'test not found'); + } + const { upserted_test: data } = await services.updateTestProfile({ id, body }); + res.status(200).json({ data }); +}); + +const deleteTest = asyncErrorHandler(async (req, res) => { + const { id } = req.params; + const { test } = await services.getTestById({ id }); + if (!test) { + throw new APIError(404, 'test not found'); + } + await services.deleteTest({ id }); + res.status(200).json({ message: 'Deletion successful' }); +}); +module.exports = { + createTest, + getTests, + getTest, + updateTest, + deleteTest +}; + diff --git a/microservices/test/src/controllers/index.js b/microservices/test/src/controllers/index.js new file mode 100644 index 0000000..f41caf5 --- /dev/null +++ b/microservices/test/src/controllers/index.js @@ -0,0 +1,2 @@ +const { hello } = require('./controllers'); +module.exports = controllers; \ No newline at end of file diff --git a/microservices/test/src/models/index.js b/microservices/test/src/models/index.js new file mode 100644 index 0000000..b0d086a --- /dev/null +++ b/microservices/test/src/models/index.js @@ -0,0 +1,2 @@ +const models = require('./model'); +module.exports = models; \ No newline at end of file diff --git a/microservices/test/src/models/models.js b/microservices/test/src/models/models.js new file mode 100644 index 0000000..34fb302 --- /dev/null +++ b/microservices/test/src/models/models.js @@ -0,0 +1,16 @@ + +const mongoose = require('mongoose'); + +const testSchema = new mongoose.Schema({ + name: { + type: String, + required: true, + } +} + , { + timestamps: true + }); + +const Test = mongoose.model('test', testSchema); + +module.exports = Test; diff --git a/microservices/test/src/routes/index.js b/microservices/test/src/routes/index.js new file mode 100644 index 0000000..c564440 --- /dev/null +++ b/microservices/test/src/routes/index.js @@ -0,0 +1,2 @@ +const router = require('./routes'); +module.exports = { router }; \ No newline at end of file diff --git a/microservices/test/src/routes/routes.js b/microservices/test/src/routes/routes.js new file mode 100644 index 0000000..70e7d06 --- /dev/null +++ b/microservices/test/src/routes/routes.js @@ -0,0 +1,20 @@ + +const express = require('express'); +const { validate } = require('@microservices-suite/utilities'); + +const testController = require('../controllers/controllers'); + +const router = express.Router(); + +router + .route('/tests') + .post(testController.createTest) + .get(testController.getTests); + +router + .route('/tests/:id') + .get(testController.getTest) + .patch(testController.updateTest) + .delete(testController.deleteTest); + +module.exports = router; diff --git a/microservices/test/src/services/index.js b/microservices/test/src/services/index.js new file mode 100644 index 0000000..a099545 --- /dev/null +++ b/microservices/test/src/services/index.js @@ -0,0 +1 @@ +module.exports = {}; \ No newline at end of file diff --git a/microservices/test/src/services/services.js b/microservices/test/src/services/services.js new file mode 100644 index 0000000..27504f8 --- /dev/null +++ b/microservices/test/src/services/services.js @@ -0,0 +1,34 @@ + +const { ObjectId } = require('mongodb'); +const Test = require('../models/models'); + +const createTest = async ({ body }) => { + const test = await Test.create(body); + return { test }; +}; + +const getTests = async () => { + const tests = await Test.find({}); + return { tests }; +}; + +const getTestById = async ({ id }) => { + const test = await Test.findById(id); + return { test }; +}; + +const updateTestProfile = async ({ id, body }) => { + const upserted_test = await Test.updateOne({ _id: ObjectId(id) }, { ...body }, { upsert: false }); + return { upserted_test }; +}; + +const deleteTest = async ({ id }) => { + await Test.deleteOne({ _id: ObjectId(id) }); +}; +module.exports = { + createTest, + getTests, + getTestById, + updateTestProfile, + deleteTest +}; diff --git a/microservices/test/src/subscriber/index.js b/microservices/test/src/subscriber/index.js new file mode 100644 index 0000000..8f99ac7 --- /dev/null +++ b/microservices/test/src/subscriber/index.js @@ -0,0 +1 @@ +module.exports.subscriber = require('./subscriber'); \ No newline at end of file diff --git a/microservices/test/src/subscriber/subscriber.js b/microservices/test/src/subscriber/subscriber.js new file mode 100644 index 0000000..1f1c11d --- /dev/null +++ b/microservices/test/src/subscriber/subscriber.js @@ -0,0 +1,60 @@ + +const testService = require('../services/services'); +const rabbitmq = require('@microservices-suite/broker/rabbitmq'); + +const subscribe = async ({ channel, config, routing_key }) => { + try { + const q = await channel.assertQueue('', { exclusive: true }); + console.log(`⚡️ ${routing_key}: successfully subscribed to exchange: ${config.exchange}`); + await channel.bindQueue(q.queue, config.exchange, routing_key); + await channel.consume(q.queue, async(msg) => { + if (msg !== null) { + const service = msg.fields.routingKey; + console.log("Message received [x] %s: '%s'", msg.fields.routingKey, msg.content.toString()); + await subscriberHandler({ channel, msg, service, config }); + } + }, { noAck: false }); + } catch (error) { + throw new APIError(500, `Failed to set up subscriber ${error.message}`); + } +}; + +const subscriberHandler = async ({ channel, msg, service, config }) => { + const messageContent = JSON.parse(msg.content.toString()); // Parse the message content + const { action, body } = messageContent; // Destructure type and body from the parsed content + let data; + let auth; + switch (action) { + case 'create': + try { + await testService.createTest({ body }) + } catch (error) { + //TODO: handle this case. Eg do we roll back or what next.. + console.log(`test: subscriber-failed to create test: ${error.message}`); + + console.log({ error }); + } + break; + // TODO: use rpc for read operations + case 'read': + const { tests } = await testService.getTests(); + data = tests; + await rabbitmq.workerQueue.sendToQueue({ data, queue: service, config }); + break; + case 'read:id': + test = await testService.getTestById({ id: body.id }); + test = test.test; + await rabbitmq.workerQueue.sendToQueue({ data, queue: service, config }); + break; + case 'update': + break; + case 'delete': + break; + default: + channel.ack(msg); + } +} +module.exports = { + subscriberHandler, + subscribe +}; diff --git a/microservices/th/.dockerignore b/microservices/th/.dockerignore new file mode 100644 index 0000000..25a56cf --- /dev/null +++ b/microservices/th/.dockerignore @@ -0,0 +1,5 @@ + +#These files wont be sent to the docker builder during the COPY . . command + +node_modules +bar diff --git a/microservices/th/Dockerfile.dev b/microservices/th/Dockerfile.dev new file mode 100644 index 0000000..8f85789 --- /dev/null +++ b/microservices/th/Dockerfile.dev @@ -0,0 +1,12 @@ + +FROM node:18-alpine3.18 + +WORKDIR /app + +COPY package.json . + +RUN yarn install + +COPY . . + +CMD [ "yarn","dev" ] diff --git a/microservices/th/ecosystem.config.js b/microservices/th/ecosystem.config.js new file mode 100644 index 0000000..d85436b --- /dev/null +++ b/microservices/th/ecosystem.config.js @@ -0,0 +1,26 @@ + +module.exports = { + apps : [{ + name : th, + autorestart: true, + watch: true, + time: true, + script : "./index.js", + instances:4, + env_production: { + NODE_ENV: "prod", + DATABASE_URL:"mongodb://mongodb:27017/microservices-suite_th_proddb", + EXCHANGE:@microservices-suite, + AMQP_HOST:"amqp://rabbitmq:5672", + PORT:9020 + }, + env_development: { + NODE_ENV: "dev", + DATABASE_URL:"mongodb://mongodb:27017/microservices-suite_th_devdb", + EXCHANGE:@microservices-suite, + AMQP_HOST:"amqp://rabbitmq:5672", + PORT:9020 + } + }] + } + diff --git a/microservices/th/index.js b/microservices/th/index.js new file mode 100644 index 0000000..2898e55 --- /dev/null +++ b/microservices/th/index.js @@ -0,0 +1,65 @@ + +const http = require('http'); +const express = require('express'); +const mongoose = require('mongoose'); +const { config, morgan, logger } = require('@microservices-suite/config'); +const { errorHandler } = require('@microservices-suite/errors'); +const { validate, APIError } = require('@microservices-suite/utilities'); +const { getUsers } = require('./src/services'); +const { router } = require('./src/routes'); +const { subscriber } = require('./src/subscriber'); +const rabbitmq = require('@microservices-suite/broker/rabbitmq'); +// const app = require('./src/app'); + +mongoose.connect(config.db).then(() => { + logger.info(`📀 successfully connected to db: ${config.db}`); +}).catch(err => { + logger.error(`failed to connect to db. Exiting... ${err.message}`); + process.exit(0); +}); + +const app = express(); + +app.use(express.json()); + +app.get('/', (req, res) => { + res.json({ message: 'hello from @microservices-suite/th' }); +}); + +const server = http.createServer(app); + +server.on('error', (err) => { + logger.error(err); + if (err.code === 'EADDRINUSE') { + logger.error('Address already in use, retrying...'); + setTimeout(() => { + server.close(); + server.listen(config.port, 'localhost'); + }, 1000); + errorHandler(err); + } +}); + +server.listen(config.port, async() => { + logger.info(`🚀 @microservices-suite/th listening at: http://localhost:${config.port}`); + const channel = await rabbitmq.workerQueue.amqpInitializeQueue({ config }); + await rabbitmq.workerQueue.consumeFromQueue({ + channel, + queue: 'th', + subscriberHandler: subscriber.subscriberHandler + }); +}); + +app.use(morgan.errorHandler); + +app.use(morgan.successHandler); + +app.use('/api/v1', router); + +// Global error handler should come after all other middlewares +app.all('*', (req, res, next) => { + const err = new APIError(404, `requested resource not found on server: ${req.originalUrl}`); + next(err); +}); + +app.use(errorHandler); diff --git a/microservices/th/package.json b/microservices/th/package.json new file mode 100644 index 0000000..164bceb --- /dev/null +++ b/microservices/th/package.json @@ -0,0 +1,46 @@ +{ + "name": "@microservices-suite/th", + "version": "1.0.0", + "description": "This is the th service. TODO: update this description", + "main": "index.js", + "author": "Gilbert", + "license": "MIT", + "dependencies": { + "@microservices-suite/config": "1.0.0", + "@microservices-suite/errors": "1.0.0", + "@microservices-suite/utilities": "1.0.7", + "@microservices-suite/broker": "1.0.0", + "dotenv": "^16.4.5", + "express": "^4.18.3", + "helmet": "^7.1.0", + "mongodb": "^6.5.0", + "mongoose": "^8.2.1", + "morgan": "^1.10.0", + "pm2": "^5.3.1", + "winston": "^3.12.0" + }, + "devDependencies": { + "nodemon": "^3.1.0" + }, + "workspaces": { + "nohoist": [ + "**/@microservices-suite/utilities/", + "**/@microservices-suite/utilities/**", + "**/@microservices-suite/errors/", + "**/@microservices-suite/errors/**", + "**/@microservices-suite/config/", + "**/@microservices-suite/config/**", + "**/@microservices-suite/broker/", + "**/@microservices-suite/broker/**" + ] + }, + "scripts": { + "release": "npx bumpp-version@latest && npm publish", + "dev": "NODE_ENV=dev nodemon --legacy-watch -q index.js", + "start": "pm2-runtime start ecosystem.config.js --env production", + "stoprod": "pm2 stop ecosystem.config.js", + "deletprod": "pm2 delete ecosystem.config.js", + "test": "jest" + }, + "private": true +} \ No newline at end of file diff --git a/microservices/th/src/controllers/controllers.js b/microservices/th/src/controllers/controllers.js new file mode 100644 index 0000000..2471e0d --- /dev/null +++ b/microservices/th/src/controllers/controllers.js @@ -0,0 +1,52 @@ + +const services = require('../services/services'); +const { asyncErrorHandler, APIError } = require('@microservices-suite/utilities'); + +const createTh = asyncErrorHandler(async (req, res) => { + const { body } = req; + const { th: data } = await services.createTh({ body }); + res.status(201).json({ data }); +}); + +const getThs = asyncErrorHandler(async (req, res) => { + const { ths: data } = await services.getThs(); + res.status(200).json({ data }); +}); + +const getTh = asyncErrorHandler(async (req, res) => { + const { id } = req.params; + const { th: data } = await services.getThById({ id }); + if (!data) { + throw new APIError(404, 'th not found'); + } + res.status(200).json({ data }); +}); + +const updateTh = asyncErrorHandler(async (req, res) => { + const { id } = req.params; + const { body } = req; + const { th } = await services.getThById({ id }); + if (!th) { + throw new APIError(404, 'th not found'); + } + const { upserted_th: data } = await services.updateThProfile({ id, body }); + res.status(200).json({ data }); +}); + +const deleteTh = asyncErrorHandler(async (req, res) => { + const { id } = req.params; + const { th } = await services.getThById({ id }); + if (!th) { + throw new APIError(404, 'th not found'); + } + await services.deleteTh({ id }); + res.status(200).json({ message: 'Deletion successful' }); +}); +module.exports = { + createTh, + getThs, + getTh, + updateTh, + deleteTh +}; + diff --git a/microservices/th/src/controllers/index.js b/microservices/th/src/controllers/index.js new file mode 100644 index 0000000..f41caf5 --- /dev/null +++ b/microservices/th/src/controllers/index.js @@ -0,0 +1,2 @@ +const { hello } = require('./controllers'); +module.exports = controllers; \ No newline at end of file diff --git a/microservices/th/src/models/index.js b/microservices/th/src/models/index.js new file mode 100644 index 0000000..b0d086a --- /dev/null +++ b/microservices/th/src/models/index.js @@ -0,0 +1,2 @@ +const models = require('./model'); +module.exports = models; \ No newline at end of file diff --git a/microservices/th/src/models/models.js b/microservices/th/src/models/models.js new file mode 100644 index 0000000..f267ddf --- /dev/null +++ b/microservices/th/src/models/models.js @@ -0,0 +1,16 @@ + +const mongoose = require('mongoose'); + +const thSchema = new mongoose.Schema({ + name: { + type: String, + required: true, + } +} + , { + timestamps: true + }); + +const Th = mongoose.model('th', thSchema); + +module.exports = Th; diff --git a/microservices/th/src/routes/index.js b/microservices/th/src/routes/index.js new file mode 100644 index 0000000..c564440 --- /dev/null +++ b/microservices/th/src/routes/index.js @@ -0,0 +1,2 @@ +const router = require('./routes'); +module.exports = { router }; \ No newline at end of file diff --git a/microservices/th/src/routes/routes.js b/microservices/th/src/routes/routes.js new file mode 100644 index 0000000..b7b66ce --- /dev/null +++ b/microservices/th/src/routes/routes.js @@ -0,0 +1,20 @@ + +const express = require('express'); +const { validate } = require('@microservices-suite/utilities'); + +const thController = require('../controllers/controllers'); + +const router = express.Router(); + +router + .route('/ths') + .post(thController.createTh) + .get(thController.getThs); + +router + .route('/ths/:id') + .get(thController.getTh) + .patch(thController.updateTh) + .delete(thController.deleteTh); + +module.exports = router; diff --git a/microservices/th/src/services/index.js b/microservices/th/src/services/index.js new file mode 100644 index 0000000..a099545 --- /dev/null +++ b/microservices/th/src/services/index.js @@ -0,0 +1 @@ +module.exports = {}; \ No newline at end of file diff --git a/microservices/th/src/services/services.js b/microservices/th/src/services/services.js new file mode 100644 index 0000000..6101df5 --- /dev/null +++ b/microservices/th/src/services/services.js @@ -0,0 +1,34 @@ + +const { ObjectId } = require('mongodb'); +const Th = require('../models/models'); + +const createTh = async ({ body }) => { + const th = await Th.create(body); + return { th }; +}; + +const getThs = async () => { + const ths = await Th.find({}); + return { ths }; +}; + +const getThById = async ({ id }) => { + const th = await Th.findById(id); + return { th }; +}; + +const updateThProfile = async ({ id, body }) => { + const upserted_th = await Th.updateOne({ _id: ObjectId(id) }, { ...body }, { upsert: false }); + return { upserted_th }; +}; + +const deleteTh = async ({ id }) => { + await Th.deleteOne({ _id: ObjectId(id) }); +}; +module.exports = { + createTh, + getThs, + getThById, + updateThProfile, + deleteTh +}; diff --git a/microservices/th/src/subscriber/index.js b/microservices/th/src/subscriber/index.js new file mode 100644 index 0000000..8f99ac7 --- /dev/null +++ b/microservices/th/src/subscriber/index.js @@ -0,0 +1 @@ +module.exports.subscriber = require('./subscriber'); \ No newline at end of file diff --git a/microservices/th/src/subscriber/subscriber.js b/microservices/th/src/subscriber/subscriber.js new file mode 100644 index 0000000..48ad9f0 --- /dev/null +++ b/microservices/th/src/subscriber/subscriber.js @@ -0,0 +1,60 @@ + +const thService = require('../services/services'); +const rabbitmq = require('@microservices-suite/broker/rabbitmq'); + +const subscribe = async ({ channel, config, routing_key }) => { + try { + const q = await channel.assertQueue('', { exclusive: true }); + console.log(`⚡️ ${routing_key}: successfully subscribed to exchange: ${config.exchange}`); + await channel.bindQueue(q.queue, config.exchange, routing_key); + await channel.consume(q.queue, async(msg) => { + if (msg !== null) { + const service = msg.fields.routingKey; + console.log("Message received [x] %s: '%s'", msg.fields.routingKey, msg.content.toString()); + await subscriberHandler({ channel, msg, service, config }); + } + }, { noAck: false }); + } catch (error) { + throw new APIError(500, `Failed to set up subscriber ${error.message}`); + } +}; + +const subscriberHandler = async ({ channel, msg, service, config }) => { + const messageContent = JSON.parse(msg.content.toString()); // Parse the message content + const { action, body } = messageContent; // Destructure type and body from the parsed content + let data; + let auth; + switch (action) { + case 'create': + try { + await thService.createTh({ body }) + } catch (error) { + //TODO: handle this case. Eg do we roll back or what next.. + console.log(`th: subscriber-failed to create th: ${error.message}`); + + console.log({ error }); + } + break; + // TODO: use rpc for read operations + case 'read': + const { ths } = await thService.getThs(); + data = ths; + await rabbitmq.workerQueue.sendToQueue({ data, queue: service, config }); + break; + case 'read:id': + th = await thService.getThById({ id: body.id }); + th = th.th; + await rabbitmq.workerQueue.sendToQueue({ data, queue: service, config }); + break; + case 'update': + break; + case 'delete': + break; + default: + channel.ack(msg); + } +} +module.exports = { + subscriberHandler, + subscribe +}; diff --git a/microservices/user/ecosystem.config.js b/microservices/user/ecosystem.config.js index 7e9f240..93e6e42 100644 --- a/microservices/user/ecosystem.config.js +++ b/microservices/user/ecosystem.config.js @@ -9,16 +9,16 @@ module.exports = { instances:4, env_production: { NODE_ENV: "prod", - DATABASE_URL="mongodb://mongodb:27017/microservices-suite_user_proddb", - EXCHANGE="@monorepo", - AMQP_HOST="amqp://rabbitmq:5672", + DATABASE_URL:"mongodb://mongodb:27017/microservices-suite_user_proddb", + EXCHANGE:"@microservices-suite", + AMQP_HOST:"amqp://rabbitmq:5672", PORT:9011 }, env_development: { NODE_ENV: "dev", - DATABASE_URL="mongodb://mongodb:27017/microservices-suite_user_devdb", - EXCHANGE="@monorepo", - AMQP_HOST="amqp://rabbitmq:5672", + DATABASE_URL:"mongodb://mongodb:27017/microservices-suite_user_devdb", + EXCHANGE:"@microservices-suite", + AMQP_HOST:"amqp://rabbitmq:5672", PORT:9011 } }] diff --git a/suite.json b/suite.json index f8ce2c8..be68160 100644 --- a/suite.json +++ b/suite.json @@ -11,6 +11,10 @@ "private": true, "default_broker": "rabbitmq", "services": [ + { + "name": "hd", + "port": null + }, { "name": "customer-service", "port": 9000 @@ -78,12 +82,132 @@ { "name": "upload", "port": 9019 + }, + { + "name": "th", + "port": 9020 + }, + { + "name": "kjhgf", + "port": 9021 + }, + { + "name": "hhgfdsdfghj", + "port": 9022 + }, + { + "name": "ghjk", + "port": 9023 + }, + { + "name": "shjksgd", + "port": 30067 + }, + { + "name": "test", + "port": 30068 } ], "apps": [ { - "name": "uber-eats", + "name": "orders", + "GATEWAY_PORT": 8006, + "services": [ + "hd", + "customer-service", + "product-service", + "rbac-service", + "payment-service", + "notification-service", + "email-service", + "cart-service", + "cart", + "user", + "customer", + "email", + "notification", + "payment", + "product", + "rbac", + "supplier", + "upload", + "th", + "kjhgf", + "hhgfdsdfghj", + "ghjk", + "shjksgd" + ] + }, + { + "name": "dnmw", + "GATEWAY_PORT": 9000, + "services": [ + "hd", + "customer-service", + "product-service", + "rbac-service", + "payment-service", + "notification-service", + "email-service", + "cart-service", + "cart", + "user", + "customer", + "email", + "notification", + "payment", + "product", + "rbac", + "supplier", + "upload", + "th", + "kjhgf", + "hhgfdsdfghj", + "ghjk", + "shjksgd" + ] + }, + { + "name": "hkd", + "GATEWAY_PORT": 9001, + "services": [ + "hd", + "customer-service", + "product-service", + "rbac-service", + "payment-service", + "notification-service", + "email-service", + "cart-service", + "cart", + "user", + "customer", + "email", + "notification", + "payment", + "product", + "rbac", + "supplier", + "upload", + "th", + "kjhgf", + "hhgfdsdfghj", + "ghjk", + "shjksgd" + ] + }, + { + "name": "name", + "GATEWAY_PORT": 9002, "services": [ + "hd", + "customer-service", + "product-service", + "rbac-service", + "payment-service", + "notification-service", + "email-service", + "cart-service", "cart", "user", "customer", @@ -93,12 +217,26 @@ "product", "rbac", "supplier", - "upload" + "upload", + "th", + "kjhgf", + "hhgfdsdfghj", + "ghjk", + "shjksgd" ] }, { - "name": "uber-eats", + "name": "app", + "GATEWAY_PORT": 7890, "services": [ + "hd", + "customer-service", + "product-service", + "rbac-service", + "payment-service", + "notification-service", + "email-service", + "cart-service", "cart", "user", "customer", @@ -108,7 +246,12 @@ "product", "rbac", "supplier", - "upload" + "upload", + "th", + "kjhgf", + "hhgfdsdfghj", + "ghjk", + "shjksgd" ] } ],