Further simplified the sample

This commit is contained in:
Mete Atamel 2019-03-04 17:13:22 +00:00
parent a3d7f029f8
commit 647bd917d2
2 changed files with 6 additions and 8 deletions

View File

@ -18,5 +18,8 @@ RUN dotnet publish -c Release -o out
# This default value facilitates local development. # This default value facilitates local development.
ENV PORT 8080 ENV PORT 8080
# Make sure the app binds to $PORT
ENV ASPNETCORE_URLS http://*:${PORT}
# Run the web service on container startup. # Run the web service on container startup.
CMD ["dotnet", "out/helloworld-csharp.dll"] CMD ["dotnet", "out/helloworld-csharp.dll"]

View File

@ -11,13 +11,8 @@ namespace helloworld_csharp
CreateWebHostBuilder(args).Build().Run(); CreateWebHostBuilder(args).Build().Run();
} }
public static IWebHostBuilder CreateWebHostBuilder(string[] args) public static IWebHostBuilder CreateWebHostBuilder(string[] args) =>
{ WebHost.CreateDefaultBuilder(args)
string port = Environment.GetEnvironmentVariable("PORT") ?? "8080"; .UseStartup<Startup>();
string url = String.Concat("http://0.0.0.0:", port);
return WebHost.CreateDefaultBuilder(args)
.UseStartup<Startup>().UseUrls(url);
}
} }
} }