在 docker 容器中运行 .NET 单元测试(包括 jsreport 测试)

问题描述 投票:0回答:0

我有一个单元测试,使用 jsreport 从 html 测试 pdf 生成。 测试在本地是绿色的,但是当我在 docker 容器中运行它时,我遇到了依赖问题

错误: 无法从“https://api.nuget.org/v3-flatcontainer/ironpdf.slim/2023.5.8/ironpdf.slim.2023.5.8.nupkg”下载包“IronPdf.Slim.2023.5.8”。 => => # 'https://api.nuget.org/v3-flatcontainer/ironpdf.slim/2023.5.8/ironpdf.slim.2023.5.8.nupkg'的下载超时,因为60000ms没有收到数据. => => # 引发了“System.TimeoutException”类型的异常。 => => # 为源“https://api.nuget.org/v3-flatcontainer/runtime.native.system.security.cryptography.openssl/index.json”重试“FindPackagesByIdAsync”。 => => # 资源暂时不可用 (api.nuget.org:443) => => # 资源暂时不可用

Docker文件

FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build
WORKDIR /app

RUN apt update && apt install -y gconf-service libgbm-dev libasound2 libatk1.0-0 libc6 libcairo2 libcups2 libdbus-1-3 libexpat1 libfontconfig1 libgcc1 libgconf-2-4 libgdk-pixbuf2.0-0 libglib2.0-0 libgtk-3-0 libnspr4 libpango-1.0-0 libpangocairo-1.0-0 libstdc++6 libx11-6 libx11-xcb1 libxcb1 libxcomposite1 libxcursor1 libxdamage1 libxext6 libxfixes3 libxi6 libxrandr2 libxrender1 libxss1 libxtst6 ca-certificates fonts-liberation libappindicator1 libnss3 lsb-release xdg-utils
ENV chrome_launchOptions_args --no-sandbox,--disable-dev-shm-usage

RUN mkdir jsreport
RUN chmod +rwx ./jsreport

COPY . .
RUN dotnet restore

WORKDIR /app/src/jsreport.tests

RUN dotnet build

FROM build AS test
RUN dotnet test --logger:trx
.net docker xunit jsreport
© www.soinside.com 2019 - 2024. All rights reserved.