【问题标题】:Safe way to include a NuGet private source in a Docker container在 Docker 容器中包含 NuGet 私有源的安全方法
【发布时间】:2019-06-25 00:49:20
【问题描述】:

我正在为我的 ASP.NET Core 服务器设置一个 Docker 容器,并且需要在构建和运行项目之前找到一种安全的方式来恢复 NuGet 包。

我已经设法安装了一个驱动器,其中包含一个专门为此目的创建的新 NuGet.config 文件,因为我的团队没有将该配置文件作为 Git 存储库的一部分包含在内,但感觉不对。
由于 .NET Core 运行时/sdk 的官方 Docker 映像不包含 nuget 作为库的一部分,因此有些人建议下载 Windows 映像只是为了运行 nuget source add,但这似乎也很糟糕。

我的 Dockerfile:

FROM mcr.microsoft.com/dotnet/core/aspnet:2.2 AS base
WORKDIR /app
EXPOSE 5050

FROM mcr.microsoft.com/dotnet/core/sdk:2.2 AS build
WORKDIR /src
COPY . .

#Config file needs to be in root of solution or in User/share
RUN dotnet restore "MyProject.csproj"

无需下载 2GB 的 Windows 映像或复制包含密码的现有配置文件即可添加私有 NuGet 源。

【问题讨论】:

    标签: docker .net-core nuget


    【解决方案1】:

    有一个 nuget.config 文件,其中仅列出包源,而不是凭据,该文件在您的存储库中与您的源代码一起提交。

    使用 cross platform authentication providers 允许开发人员和 CI 机器对您的私人提要进行身份验证。

    【讨论】:

      【解决方案2】:

      设置nuget的源码路径不够好?

      RUN dotnet restore -s https://api.nuget.org/v3/index.json -s https://my-local-private-nuget-source/nuget/nuget
      

      【讨论】:

      • 你能指定那个特定包的用户名和密码吗?
      • @Atli,哦.. 不,我做不到。对不起我的错,谢谢你指出我
      猜你喜欢
      • 2022-11-14
      • 1970-01-01
      • 2020-07-11
      • 2014-10-28
      • 1970-01-01
      • 2019-08-16
      • 1970-01-01
      • 2021-07-08
      • 2022-07-21
      相关资源
      最近更新 更多