From ab2ec6717bd70739633fdb3bdddc557fb020f58c Mon Sep 17 00:00:00 2001 From: Piotr Biernat Date: Sun, 25 Jun 2023 00:48:39 +0200 Subject: [PATCH] Update env --- deploy/.env.dist | 0 deploy/.env.local | 4 + deploy/egommerce-stack.dev.local.yml | 65 +++++++++++----- deploy/egommerce-stack.dev.yml | 4 +- deploy/egommerce-stack.yml | 9 +-- deploy/nginx-vhost.local.conf | 109 +++++++++++++++++++++++++++ 6 files changed, 165 insertions(+), 26 deletions(-) create mode 100644 deploy/.env.dist create mode 100644 deploy/.env.local create mode 100644 deploy/nginx-vhost.local.conf diff --git a/deploy/.env.dist b/deploy/.env.dist new file mode 100644 index 0000000..e69de29 diff --git a/deploy/.env.local b/deploy/.env.local new file mode 100644 index 0000000..563d63f --- /dev/null +++ b/deploy/.env.local @@ -0,0 +1,4 @@ +API_GATEWAY_PORT=48443 +API_GATEWAY_UI_PORT=48444 +API_REGISTRY_UI_PORT=48445 +API_EVENTBUS_UI_PORT=48446 diff --git a/deploy/egommerce-stack.dev.local.yml b/deploy/egommerce-stack.dev.local.yml index 8eb0ef1..919d840 100644 --- a/deploy/egommerce-stack.dev.local.yml +++ b/deploy/egommerce-stack.dev.local.yml @@ -2,25 +2,39 @@ version: "3.9" services: api-gateway: + env_file: .env.local environment: - APP_DOMAIN=egommerce.local + # - APP_PORT=48443 ports: - - '8443:443' - - '8888:8080' - - '5672:5672' + - target: 443 + published: 48443 + mode: host + - target: 8080 + published: 48444 + mode: host + # - 48443:443 + # - 48444:8080 + # - 5672:5672 api-registry: command: ["-ui-content-path=/registry"] + env_file: .env.local environment: - APP_DOMAIN=registry.egommerce.local + # - APP_PORT=48445 ports: - - '8500:8500' - # - '8600:8600' - # - '8600:8600/udp' + - target: 8500 + published: 48445 + mode: host + # - 48445:8500 + # - 8600:8600/udp api-eventbus: + env_file: .env.local environment: - APP_DOMAIN=eventbus.egommerce.local + # - APP_PORT=48446 labels: - traefik.enable=true - traefik.tcp.routers.eventbus.rule=HostSNI(`*`) @@ -28,111 +42,124 @@ services: - traefik.tcp.routers.eventbus.service=eventbus - traefik.tcp.services.eventbus.loadbalancer.server.port=5672 ports: - - '18084:8084' - - '15672:15672' + - 48446:8084 + - 15672:15672 api-cache: + env_file: .env.local environment: - APP_DOMAIN=redis.egommerce.local command: ["redis-server", "/etc/redis.conf", "--requirepass", "12345678"] ports: - - '6379:6379' + - 6379:6379 api-logger: + env_file: .env.local environment: - APP_DOMAIN=logger.egommerce.local ports: - - '24224:24224' + - 24224:24224 # api-prometheus: # environment: # - APP_DOMAIN=prometheus.egommerce.local # ports: - # - '9090:9090' + # - 9090:9090 # api-grafana: # environment: # - APP_DOMAIN=grafana.egommerce.local # ports: - # - '3000:3000' + # - 3000:3000 postgres-db: + env_file: .env.local environment: - APP_DOMAIN=postgres.egommerce.local ports: - - '5432:5432' + - 5432:5432 mongo-db: + env_file: .env.local environment: - APP_DOMAIN=mongo.egommerce.local ports: - - '27017:27017' + - 27017:27017 identity-svc: + env_file: .env.local environment: - APP_DOMAIN=identity.api.egommerce.local - DATABASE_URL=postgres://postgres:12345678@postgres-db:5432/egommerce - MONGODB_URL=mongodb://mongodb:12345678@mongo-db:27017 - EVENTBUS_URL=amqp://guest:guest@api-eventbus:5672 ports: - - '8080:80' + - 8080:80 basket-svc: + env_file: .env.local environment: - APP_DOMAIN=basket.api.egommerce.local - DATABASE_URL=postgres://postgres:12345678@postgres-db:5432/egommerce - MONGODB_URL=mongodb://mongodb:12345678@mongo-db:27017 - EVENTBUS_URL=amqp://guest:guest@api-eventbus:5672 ports: - - '8001:80' + - 8001:80 catalog-svc: + env_file: .env.local environment: - APP_DOMAIN=catalog.api.egommerce.local - DATABASE_URL=postgres://postgres:12345678@postgres-db:5432/egommerce - MONGODB_URL=mongodb://mongodb:12345678@mongo-db:27017 - EVENTBUS_URL=amqp://guest:guest@api-eventbus:5672 ports: - - '8002:80' + - 8002:80 order-svc: + env_file: .env.local environment: - APP_DOMAIN=order.api.egommerce.local - DATABASE_URL=postgres://postgres:12345678@postgres-db:5432/egommerce - MONGODB_URL=mongodb://mongodb:12345678@mongo-db:27017 - EVENTBUS_URL=amqp://guest:guest@api-eventbus:5672 ports: - - '8003:80' + - 8003:80 pricing-svc: + env_file: .env.local environment: - APP_DOMAIN=pricing.api.egommerce.local - DATABASE_URL=postgres://postgres:12345678@postgres-db:5432/egommerce - MONGODB_URL=mongodb://mongodb:12345678@mongo-db:27017 - EVENTBUS_URL=amqp://guest:guest@api-eventbus:5672 ports: - - '8004:80' + - 8004:80 # Workers (EventBus) basket-worker: + env_file: .env.local environment: - DATABASE_URL=postgres://postgres:12345678@postgres-db:5432/egommerce - MONGODB_URL=mongodb://mongodb:12345678@mongo-db:27017 - EVENTBUS_URL=amqp://guest:guest@api-eventbus:5672 catalog-worker: + env_file: .env.local environment: - DATABASE_URL=postgres://postgres:12345678@postgres-db:5432/egommerce - MONGODB_URL=mongodb://mongodb:12345678@mongo-db:27017 - EVENTBUS_URL=amqp://guest:guest@api-eventbus:5672 pricing-worker: + env_file: .env.local environment: - DATABASE_URL=postgres://postgres:12345678@postgres-db:5432/egommerce - MONGODB_URL=mongodb://mongodb:12345678@mongo-db:27017 - EVENTBUS_URL=amqp://guest:guest@api-eventbus:5672 order-worker: + env_file: .env.local environment: - DATABASE_URL=postgres://postgres:12345678@postgres-db:5432/egommerce - MONGODB_URL=mongodb://mongodb:12345678@mongo-db:27017 diff --git a/deploy/egommerce-stack.dev.yml b/deploy/egommerce-stack.dev.yml index 83247b6..1cd1e36 100644 --- a/deploy/egommerce-stack.dev.yml +++ b/deploy/egommerce-stack.dev.yml @@ -13,6 +13,8 @@ services: environment: - APP_DOMAIN=api-registry - CONSUL_HTTP_TOKEN=devop + volumes: + - ./certs/api-registry:/consul/data/certs api-eventbus: image: git.pbiernat.dev/egommerce/api-eventbus:dev @@ -47,8 +49,6 @@ services: environment: - APP_DOMAIN=postgres-db - POSTGRES_PASSWORD=12345678 - # ports: - # - '5432:5432' mongo-db: environment: diff --git a/deploy/egommerce-stack.yml b/deploy/egommerce-stack.yml index af38dcf..7d3c888 100644 --- a/deploy/egommerce-stack.yml +++ b/deploy/egommerce-stack.yml @@ -11,6 +11,7 @@ services: - APP_DOMAIN - API_REGISTRY_REFRESH_INTERVAL=5s volumes: + - ./certs/api-gateway:/etc/traefik/certs - /var/run/docker.sock:/var/run/docker.sock networks: - api-gateway-network @@ -25,6 +26,7 @@ services: - CONSUL_HTTP_TOKEN=VeryS3cr3tTok3N volumes: - registry_data:/consul/data + - ./certs/api-registry:/consul/data/certs networks: - api-registry-network - api-logger-network @@ -314,6 +316,7 @@ volumes: #grafana-db: ~ networks: + # Infrastructure networks api-gateway-network: driver: overlay #internal: true @@ -350,7 +353,7 @@ networks: driver: overlay #internal: true - # api micro-services networks + # Micro-services networks identity-svc-network: driver: overlay #internal: true @@ -372,10 +375,6 @@ networks: #internal: true # Workers networks - # identity-worker-network: - # driver: overlay - # internal: true - basket-worker-network: driver: overlay #internal: true diff --git a/deploy/nginx-vhost.local.conf b/deploy/nginx-vhost.local.conf new file mode 100644 index 0000000..cd4ea5e --- /dev/null +++ b/deploy/nginx-vhost.local.conf @@ -0,0 +1,109 @@ +upstream egommerce-api-gw { + server 127.0.0.1:48443; +} + +upstream egommerce-api-gw-dashboard { + server 127.0.0.1:48444; +} + +upstream egommerce-api-registry-ui { + server 127.0.0.1:48445; +} + +upstream egommerce-api-eventbus-mngmt { + server 127.0.0.1:48446; +} + +server { + listen 443 ssl; + ssl_certificate /home/keedosn/workspace/golang/src/git.pbiernat.dev/egommerce/stack/deploy/certs/api-gateway/localhost.cert; + ssl_certificate_key /home/keedosn/workspace/golang/src/git.pbiernat.dev/egommerce/stack/deploy/certs/api-gateway/localhost.key; + + server_name egommerce.local; + + # Traefik redirects + location /dashboard { + if ($http_referer ~ (/gateway)) { + proxy_pass http://egommerce-api-gw-dashboard; + } + } + location /api { + if ($http_referer ~ (/gateway)) { + proxy_pass http://egommerce-api-gw-dashboard; + } + } + + location /gateway/ { + proxy_pass http://egommerce-api-gw-dashboard/dashboard/; + proxy_pass_header Server; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + client_max_body_size 0; + } + + # Consul redirects + location /ui { + if ($http_referer ~ (/registry)) { + proxy_pass http://egommerce-api-registry-ui; + } + } + + location /v1 { + if ($http_referer ~ (/registry)) { + proxy_pass http://egommerce-api-registry-ui; + } + } + + location /registry { + proxy_pass http://egommerce-api-registry-ui; + proxy_pass_header Server; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + client_max_body_size 0; + } + + + # RabbitMQ Mngmt redirects + location /eventbus { + return 302 /eventbus/; + } + location ~* /eventbus/api/(.*?)/(.*) { + proxy_pass http://egommerce-api-eventbus-mngmt/api/$1/%2F/$2?$query_string; + proxy_buffering off; + proxy_pass_header Server; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + location ~* /eventbus/(.*) { + rewrite ^/eventbus/(.*)$ /$1 break; + proxy_pass http://egommerce-api-eventbus-mngmt; + proxy_buffering off; + proxy_pass_header Server; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + # Pass all requests to the API Gateway + location / { + proxy_pass https://egommerce-api-gw; + proxy_http_version 1.1; + proxy_pass_header Server; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + client_max_body_size 0; + } + + error_log /var/log/nginx/egommerce.local-error.log; + access_log /var/log/nginx/egommerce.local-access.log combined; +} +