2

我正在尝试与剧作家一起创建 .net 5.0 docker 映像。这是我的 DockerFile:

FROM mcr.microsoft.com/dotnet/runtime:5.0-buster-slim AS base
WORKDIR /app

FROM mcr.microsoft.com/dotnet/sdk:5.0-buster-slim AS build
WORKDIR /src
COPY ["Agent.csproj", "Agent/"]
RUN dotnet restore "Agent/Agent.csproj"
COPY . "/src/Agent"
WORKDIR "/src/Agent"
RUN apt-get update -yq && apt-get upgrade -yq && apt-get install -yq curl git nano
RUN curl -sL https://deb.nodesource.com/setup_16.x | bash - && apt-get install -yq nodejs build-essential
RUN npm install -g npm

RUN dotnet add package Microsoft.Playwright
RUN dotnet build "Agent.csproj" -c Release -o /app/build
RUN npx playwright install

但是一旦我在我的图像命令中运行dotnet run Agent它就会给我以下错误:

Executable doesn't exist at /root/.cache/ms-playwright/chromium-907428/chrome-linux/chrome
Please run the following command to download new browsers:              
║                                                                         
║     npx playwright install

即使我的 dockerfile 包含RUN npx playwright install似乎没有安装它。当我将它从我的 dockerfile 中删除并在运行图像上手动执行时,它似乎没问题。有什么想法可以使用 dockerfile 正确执行 playwright install 吗?

4

2 回答 2

1

我认为这是Playwright. 你可以在这里看到详细的讨论,特别是看到这个评论

我看到的最有效的解决方案是node_modules完全删除然后重新安装它,或者如果是 docker 映像,请尝试此链接中提到的解决方案,方法是将 playwright 浏览器设置为特定路径

于 2021-10-07T04:30:33.407 回答
0

我的问题是我安装了不同版本的 chromium v​​s playwright

于 2021-10-28T19:54:42.730 回答