Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support ContainerEnvironmentVariables #181

Merged
merged 12 commits into from
Oct 13, 2022
Merged

Support ContainerEnvironmentVariables #181

merged 12 commits into from
Oct 13, 2022

Conversation

benvillalobos
Copy link
Member

@benvillalobos benvillalobos commented Sep 28, 2022

Fixes #179

Changes Made

Containerize, CreateNewImage, CreateNewImage (the tool task), and the targets have been modified to flow Environment Variables.

Also added a unit test that verifies it works by Console.Writing the value of the environment variable manually passed into the ParseContainerProeprties task.

Recommend a commit-by-commit review

@benvillalobos
Copy link
Member Author

@@ -220,6 +220,10 @@ public void Label(string name, string value)

public void AddEnvironmentVariable(string envVarName, string value)
{
if (environmentVariables.ContainsKey(envVarName))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should overwrite here and make folks aware that this is the semantic. Otherwise, people can't do things like overwriting the ASPNETCORE_URLS variable on their own, since the dotnet/runtime-deps container includes that definition by default.

@benvillalobos
Copy link
Member Author

benvillalobos commented Oct 12, 2022

This one's new. Something new about the web template? I'm confused about what could have changed here.

C:\Program Files\Microsoft Visual Studio\2022\Dogfood>docker run localhost:5010/endtoend_noapi:1.0
Unhandled exception. System.InvalidOperationException: Unable to configure HTTPS endpoint. No server certificate was specified, and the default developer certificate could not be found or is out of date.
To generate a developer certificate run 'dotnet dev-certs https'. To trust the certificate (Windows and macOS only) run 'dotnet dev-certs https --trust'.
For more information on configuring HTTPS see https://go.microsoft.com/fwlink/?linkid=848054.
   at Microsoft.AspNetCore.Hosting.ListenOptionsHttpsExtensions.UseHttps(ListenOptions listenOptions, Action`1 configureOptions)
   at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.AddressBinder.AddressesStrategy.BindAsync(AddressBindContext context, CancellationToken cancellationToken)
   at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.AddressBinder.BindAsync(IEnumerable`1 listenOptions, AddressBindContext context, CancellationToken cancellationToken)
   at Microsoft.AspNetCore.Server.Kestrel.Core.KestrelServerImpl.BindAsync(CancellationToken cancellationToken)
   at Microsoft.AspNetCore.Server.Kestrel.Core.KestrelServerImpl.StartAsync[TContext](IHttpApplication`1 application, CancellationToken cancellationToken)
   at Microsoft.AspNetCore.Hosting.GenericWebHostService.StartAsync(CancellationToken cancellationToken)
   at Microsoft.Extensions.Hosting.Internal.Host.StartAsync(CancellationToken cancellationToken)
   at Microsoft.Extensions.Hosting.HostingAbstractionsHostExtensions.RunAsync(IHost host, CancellationToken token)
   at Microsoft.Extensions.Hosting.HostingAbstractionsHostExtensions.RunAsync(IHost host, CancellationToken token)
   at Microsoft.Extensions.Hosting.HostingAbstractionsHostExtensions.Run(IHost host)
   at Program.<Main>$(String[] args) in C:\Users\bevillal\AppData\Local\Temp\CreateNewImageTest\Program.cs:line 25

@benvillalobos
Copy link
Member Author

Turns out it was the default value we were setting ASPNETCORE_URLS to...

I stole the value it is set to by default: http://+:80, cc @baronfel

@benvillalobos
Copy link
Member Author

Cleaned up the commit history, should be ready to merge. Un-drafting

@benvillalobos benvillalobos marked this pull request as ready for review October 12, 2022 23:11
Copy link
Member

@baronfel baronfel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work! Thanks for knocking this out.

@benvillalobos benvillalobos merged commit 9aca15f into main Oct 13, 2022
@benvillalobos benvillalobos deleted the bv/env-vars branch October 13, 2022 22:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support Container Environment Variables
2 participants