1

我正在为 Amazon ECS 容器部署一个快速网关,我试图找出如果 gateway.config.yml 覆盖 serviceEndpoint 部分的最佳方法,因为服务 URL 明显不同。

我需要改变这个

serviceEndpoints:
  user:
    url: 'http://localhost:3001'
  auth:
    url: 'http://localhost:3004'
  customer:
    url: 'http://localhost:3002'

对此:

serviceEndpoints:
  user:
    url: 'http://user.service:3001'
  auth:
    url: 'http://auth.service:3004'
  customer:
    url: 'http://customer.sevice:3002'

等等。

我假设我可以维护 2 个配置文件的副本并在 Docker 构建中交换它们,但我认为这不是最好的选择,我认为实现服务发现将是另一种选择。

有任何想法吗?

蒂亚!

4

1 回答 1

1

我找到了解决方案,配置现在使用 ENVIRONMENT 变量作为:

serviceEndpoints: 用户: url: 'http://${USER_SERVICE:-localhost}:${USER_SERVICE_PORT:-3001}' auth: url: 'http://${AUTH_SERVICE:-localhost}:${AUTH_SERVICE_PORT:-3004 }' 客户: url: 'http://${CUSTIMER_SERVICE:-localhost}:${CUTOMER_SERVICE_PORT:-3002}'

一切正常。

问候。

于 2019-12-19T16:47:16.500 回答