FROM mcr.microsoft.com/dotnet/aspnet:6.0
ENV nacos.server.addresses='http://192.168.103.126:9848'
ENV nacos.server.namespace='Test'
EXPOSE 80
EXPOSE 443
WORKDIR /app
COPY . .
ENTRYPOINT dotnet web.Api.dll #这种写法读取不到环境变量
ENTRYPOINT ["dotnet", "web.Api.dll"] #可以读取到环境变量
string GetNacosEnvironment(string key, string defaultValue)
{
var value = Environment.GetEnvironmentVariable(key);
return value.IsNotNullOrWhiteSpace() ? value : defaultValue;
}
List<string> GetNacosEnvironment(string key, List<string> defaultValue)
{
var value = Environment.GetEnvironmentVariable(key);
return value.IsNotNullOrWhiteSpace() ? value.Split(",").ToList() : defaultValue;
}