Closed erikrose100 closed 2 months ago
Is ${{ env.TEST_TAG }}
the name of the docker image top be run? This needs to come after all of the other options in the docker command. i.e. it needs to go at the very end
So change
docker run --rm ${{ env.TEST_TAG }} -e METADATA_API_CONFIG_CACHE_EXPIRATION=1 -e METADATA_API_CONFIG_CONNECTION_STRING="${{ env.METADATA_API_CONFIG_CONNECTION_STRING }}" -e ASPNETCORE_ENVIRONMENT=Development -v ${HOME}/.aspnet/https:/https/ --stop-timeout 30
to
docker run --rm -e METADATA_API_CONFIG_CACHE_EXPIRATION=1 -e METADATA_API_CONFIG_CONNECTION_STRING="${{ env.METADATA_API_CONFIG_CONNECTION_STRING }}" -e ASPNETCORE_ENVIRONMENT=Development -v ${HOME}/.aspnet/https:/https/ --stop-timeout 30 ${{ env.TEST_TAG }}
@bduffany that was it, thank you so much! somehow missed that
Describe the bug I have created an ASP.NET application that I am able to run locally, both containerized and natively. I am using the
Environment.GetEnvironmentVariable()
method to retrieve environment variables during DI setup. Locally I am able to get this to work by setting the env vars in my shell or passing them in using the-e
option with docker run.I have a CI workflow I am trying to create where the last step uses
docker run
to check that the container will run. I have set it up to grab the env variables from repo secrets. When the workflow hits that step, I get the following error:Relevant section of code:
workflow step:
I have tried passing in the environment variable both in the
env:
for the workflow, envs for the script step, and by adding the-e
options in the shell step. I have tried both bash and pwsh. None of these have worked.The secrets are not null and can be shown to have a value when referenced in bash directly. Seems somehow the dotnet environment in the container is not able to reach the environment vars of the host runner.
To Reproduce Steps to reproduce the behavior:
Expected behavior Container should run successfully as it does locally using the same options.
Runner Version and Platform
ubuntu-latest
Job Log Output