链接两个未公开的 dokku 应用程序

问题描述 投票:0回答:1

我有两个应用程序部署到同一个 dokku 实例,一个从外部 API 提取数据的

api
服务,以及一个访问
emailer
服务上的端点并根据端点数据发送电子邮件的
api
服务。如何链接
emailer
应用程序以使用
api
应用程序(可能使用
API_URL
应用程序中的环境变量
emailer
之类的内容?

问题是这两个服务都不需要暴露到网络上,所以我不想暴露

api
服务(它只需要被
emailer
服务使用)

dokku
1个回答
0
投票

您可以将两个应用程序连接到网络以启用应用程序间路由,根据要路由到的应用程序/进程类型/端口组合的名称将 API_URL 环境变量设置为正确的值,然后禁用公共应用程序代理。以下是如何执行此任务的示例。

# create a service named internal-network
dokku network:create internal-network

# attach the apps to the internal-network network
dokku network:set api attach-post-deploy internal-network
dokku network:set emailer attach-post-deploy internal-network

# set the environment variable to talk to api
# it listens on whatever the container PORT is configured to, usually 5000
dokku config:set emailer API_URL=http://api.web:5000

# disable public proxying of the services
dokku proxy:disable api
dokku proxy:disable emailer

# rebuild the apps so the containers are attached to the internal-network network
dokku ps:rebuild api
dokku ps:rebuild emailer
© www.soinside.com 2019 - 2024. All rights reserved.