【发布时间】:2021-03-29 09:41:59
【问题描述】:
实际上在带有 net core 的 mi Apigateway 中,我有下一个文件夹结构:
在 Program.cs 中我需要参考文件配置,例如 _pathConfigOcelot:
public static void Main(string[] args)
{
string _pathConfigOcelot = Environment.GetEnvironmentVariable("OcelotConfigPath");
CreateHostBuilder(args, _pathConfigOcelot).Build().Run();
}
public static IHostBuilder CreateHostBuilder(string[] args, string pathConfigOcelot) =>
Host.CreateDefaultBuilder(args)
.ConfigureAppConfiguration(
ic => ic.AddJsonFile(Path.Combine(pathConfigOcelot,
"configuration.json")))
.ConfigureWebHostDefaults(webBuilder =>
{
webBuilder.UseStartup<Startup>();
});
其实我使用 docker-compose 来使用volumes:
services:
tresfilos.webapigateway:
image: ${DOCKER_REGISTRY-}tresfilosapigateway
build:
context: .
dockerfile: tresfilos.ApiGateway/ApiGw-Base/Dockerfile
environment:
- ASPNETCORE_ENVIRONMENT=Development
- IdentityUrl=http://identity-api
ports:
- "7000:80"
- "7001:443"
volumes:
- ./tresfilos.ApiGateway/Web.Bff:/app/configuration
我不知道如何在项目中使用 docker volume like reference for configuration.js,有什么想法吗?
【问题讨论】:
标签: docker asp.net-core environment-variables volumes