microsoft / playwright-dotnet

.NET version of the Playwright testing and automation library.
https://playwright.dev/dotnet/
MIT License
2.47k stars 235 forks source link

[Question] azure - Executable doesn't exist at /ms-playwright/chromium-1097/chrome-linux/chrome #2886

Closed Hubert409 closed 7 months ago

Hubert409 commented 7 months ago

Hi, I want to use playwright with azure, locally everything works. Application deployment is done using pipelines. After running on Azure and running the function, I get the following message:

Executable doesn't exist at /ms-playwright/chromium-1097/chrome-linux/chrome Looks like Playwright was just installed or updated. Please run the following command to download new browsers: pwsh bin/Debug/netX/playwright.ps1 install

My docker: `FROM mcr.microsoft.com/azure-functions/dotnet:4 AS base WORKDIR /home/site/wwwroot EXPOSE 80

RUN apt-get update -yq \ && apt-get install wget -yq \ && wget -q https://packages.microsoft.com/config/ubuntu/20.04/packages-microsoft-prod.deb \ && dpkg -i packages-microsoft-prod.deb \ && apt-get update -yq \ && apt-get install powershell -yq

RUN apt-get update \ && apt-get install -y \ build-essential \ cmake \ git \ wget \ unzip \ unixodbc-dev \ && rm -rf /var/lib/apt/lists/*

FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build WORKDIR /src COPY ["src/Monitoring/Monitoring.csproj", "Monitoring/"] COPY ["src/Monitoring/", "Monitoring/"] RUN dotnet restore "Monitoring/Monitoring.csproj" COPY . . WORKDIR "/src/Monitoring" RUN dotnet build "Monitoring.csproj" -c Release -o /app/build

WORKDIR "/app/build"

RUN pwsh ./playwright.ps1 install RUN pwsh ./playwright.ps1 install chromium RUN pwsh ./playwright.ps1 install-deps chromium

WORKDIR "/src/Monitoring"

FROM build AS publish RUN dotnet publish "Monitoring.csproj" -c Release -o /app/publish /p:UseAppHost=false

FROM base AS final WORKDIR /home/site/wwwroot COPY --from=publish /app/publish . ENV AzureWebJobsScriptRoot=/home/site/wwwroot \ AzureFunctionsJobHostLoggingConsole__IsEnabled=true`

Anyone had a similar problem?

mxschmitt commented 7 months ago

Looks like you don't run the RUN pwsh ./playwright.ps1 install chromium command inside the final image.

Hubert409 commented 7 months ago

Thanks, everything works fine now

FROM base AS final
WORKDIR /home/site/wwwroot
COPY --from=publish /app/publish .

COPY --from=build /app/build/Microsoft.Playwright.dll .
COPY --from=build /app/build/playwright.ps1 .
RUN pwsh ./playwright.ps1 install
RUN pwsh ./playwright.ps1 install chromium
RUN pwsh ./playwright.ps1 install-deps chromium