Problem:
Your docker container relies on a private nuget feed and you don't want to expose your credentials in the Dockerfile.
Solution:
Include an arg for the PAT token and inject that in when you build the docker container. Do this after you copy the config into the container, but before the restore.
COPY ["Nuget.Config", "."]
ARG PAT=nokeypassed
RUN sed -i "s|</configuration>|<packageSourceCredentials>
<Base><add key=\"Username\" value=\"PAT\" /><add key=\"ClearTextPassword\" value=\"${PAT}\" /></Base></packageSourceCredentials></configuration>|" Nuget.Config
RUN dotnet restore "<projfile>" --configfile Nuget.Config
Top comments (0)