我正在尝试与剧作家一起创建 .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 吗?