我现在做的是一个多阶段的构建,第一阶段用我的内部repos的凭证编译,我只是按照这个例子保存二进制文件:https://github.com/dotnet/dotnet-docker/blob/master/documentation/scenarios/nuget-credentials.md
但是我想在CI服务器上运行,并且需要为CI服务器提供测试和覆盖报告。在构建层中完成这一点会是最优雅的,但是我如何在构建期间从Docker映像中获取文件?
例如:
FROM mcr.microsoft.com/dotnet/core/sdk:3.1 AS build
WORKDIR /app
# Copy csproj and restore as distinct layers
COPY *.csproj .
COPY ./nuget.config .
RUN dotnet restore
# Copy and publish app and libraries
COPY . .
############ Get this files out #####################
# Generate test report. copy this to external directory
RUN dotnet test --logger trx
# Generate coverage report. copy this to external directory
RUN dotCover.sh dotnet --output=myRep.html --reportType=HTML -- test
#######################################################
RUN dotnet publish -c Release -o out --no-restore
FROM mcr.microsoft.com/dotnet/core/runtime:3.1 AS runtime
WORKDIR /app/
COPY --from=build /app/out ./
ENTRYPOINT ["dotnet", "dotnetapp.dll"]
所以我希望能够运行docker build,并让它将测试和覆盖报告转储到运行docker build命令的当前目录中。这可能吗?这将使CI无缝连接,因为所有服务器必须运行docker build并获得报告
1条答案
按热度按时间zf9nrax11#
docker build
支持--output
标志。我 * 认为 * 它需要BuildKit(DOCKER_BUILDKIT=1
)。下面是一个示例用法。--output