如何使用Dockerfile复制单个文件?
我正在尝试使用dockerfile
来构建ASP.NET核心项目。我需要使用多个软件包来还原项目。因此,我将包裹定义为nuget.config
文件。
使用Docker,我想将nuget.config
文件复制到我的工作目录,以便dotnet Restore
命令可以使用它来还原。
这是我的dockerfile
看起来
FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build-env
LABEL stage=build-env
WORKDIR /app
# Copy and build
COPY ./src /app
COPY ./NuGet.config /app
RUN dotnet restore /app/Project.Web --configfile ./app/NuGet.config
RUN dotnet publish /app/Project.Web -c Release -o ./build/release --framework net6.0 --no-restore
不幸的是,此行上的以上脚本错误copy ./nuget.config/app
=>错误[build-env 4/6]复制./nuget.config/app 无法计算缓存键:“/nuget.config”:找不到:找不到
如何正确将nuget.config
文件正确复制到我的工作目录中?
I am trying to build an ASP.NET Core project using Dockerfile
. I need to use multiple package-sources to restore the project. so I defined the package-sources into a NuGet.config
file.
Using docker, I want to copy the NuGet.config
file to my working directory so that the dotnet restore
command can use it to restore from.
Here is how my Dockerfile
look like
FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build-env
LABEL stage=build-env
WORKDIR /app
# Copy and build
COPY ./src /app
COPY ./NuGet.config /app
RUN dotnet restore /app/Project.Web --configfile ./app/NuGet.config
RUN dotnet publish /app/Project.Web -c Release -o ./build/release --framework net6.0 --no-restore
Unfortunately, the above script errors on this line COPY ./NuGet.config /app
=> ERROR [build-env 4/6] COPY ./NuGet.config /app
failed to compute cache key: "/NuGet.config" not found: not found
How can I correctly copy the NuGet.config
file over to my working directory?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论