DEV Community

Chris Richmond
Chris Richmond

Posted on

1

Authorizing Docker Nugets

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
Enter fullscreen mode Exit fullscreen mode

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay