You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I understand that in order to build the install script we need the sdk, and that the main use case for Playwright is testing, which also requires it, but for my use case (making a webserver that takes screenshots of pages) I only need the runtime. Currently I have these two images:
playwright:0.1.0
FROM mcr.microsoft.com/dotnet/sdk:7.0-jammy AS base
ENV PLAYWRIGHT_BROWSERS_PATH=/ms-playwright
RUN mkdir /ms-playwright && \
mkdir /ms-playwright-agent && \
cd /ms-playwright-agent && \
dotnet new console && \
echo '<?xml version="1.0" encoding="utf-8"?><configuration><packageSources><add key="local" value="/tmp/"/></packageSources></configuration>' > nuget.config && \
dotnet add package Microsoft.Playwright --version 1.39.0 && \
dotnet build && \
./bin/Debug/net7.0/playwright.ps1 install chromium --with-deps && \
rm -rf /var/lib/apt/lists/* && \
rm -rf /tmp/* && \
rm -rf /ms-playwright-agent && \
chmod -R 777 /ms-playwright
COPY ublock/ /ublock/ # these are unpacked browser extensions, not relevant for the question
COPY isdcac/ /isdcac/
FROM playwright:0.1.0 AS base
FROM mcr.microsoft.com/dotnet/sdk:7.0-jammy AS build
WORKDIR /src
COPY ["./Screenshot.csproj", "Screenshot.csproj"]
RUN dotnet restore
COPY . .
RUN dotnet build --no-restore -c Release -o /app/build
FROM build AS publish
RUN dotnet publish --no-restore -c Release -o /app/publish
FROM base AS final
WORKDIR /app
RUN mkdir /screenshots
EXPOSE 5000
ENV ASPNETCORE_URLS=http://+:5000
ENV ASPNETCORE_ENVIRONMENT=Development
COPY --from=publish /app/publish .
ENTRYPOINT ["xvfb-run", "dotnet", "Screenshot.dll"]
This works fine, but the final image is >2Gb, which is not ideal. I tried changing the base image like this:
FROM mcr.microsoft.com/dotnet/sdk:7.0-jammy AS base
ENV PLAYWRIGHT_BROWSERS_PATH=/ms-playwright
RUN mkdir /ms-playwright && \
mkdir /ms-playwright-agent && \
cd /ms-playwright-agent && \
dotnet new console && \
echo '<?xml version="1.0" encoding="utf-8"?><configuration><packageSources><add key="local" value="/tmp/"/></packageSources></configuration>' > nuget.config && \
dotnet add package Microsoft.Playwright --version 1.39.0 && \
dotnet build && \
./bin/Debug/net7.0/playwright.ps1 install chromium --with-deps && \
rm -rf /var/lib/apt/lists/* && \
rm -rf /tmp/* && \
rm -rf /ms-playwright-agent
FROM mcr.microsoft.com/dotnet/aspnet:7.0-jammy AS final
ENV PLAYWRIGHT_BROWSERS_PATH=/ms-playwright
COPY --from=base /ms-playwright /ms-playwright
RUN chmod -R 777 /ms-playwright
COPY ublock/ /ublock/
COPY isdcac/ /isdcac/
But then starting the final image errors with [FATAL tini (7)] exec xvfb-run failed: No such file or directory, so I guess simply copying /ms-playwright is not enough. Any help?
EDIT: Also tried copying the install script from the sdk image to the runtime one and running it there, but no luck:
FROM mcr.microsoft.com/dotnet/sdk:7.0-jammy AS base
RUN mkdir /ms-playwright-agent && \
cd /ms-playwright-agent && \
dotnet new console && \
echo '<?xml version="1.0" encoding="utf-8"?><configuration><packageSources><add key="local" value="/tmp/"/></packageSources></configuration>' > nuget.config && \
dotnet add package Microsoft.Playwright --version 1.39.0 && \
dotnet build
FROM mcr.microsoft.com/dotnet/aspnet:7.0 AS final
# Need to install powershellRUN apt-get update -y
RUN apt-get install -y wget
RUN wget https://github.com/PowerShell/PowerShell/releases/download/v7.3.9/powershell_7.3.9-1.deb_amd64.deb
RUN dpkg -i powershell_7.3.9-1.deb_amd64.deb
RUN apt-get install -f -y
RUN rm powershell_7.3.9-1.deb_amd64.deb
ENV PLAYWRIGHT_BROWSERS_PATH=/ms-playwright
COPY --from=base /ms-playwright-agent/bin/Debug/net7.0/playwright.ps1 /ms-playwright-agent/playwright.ps1
RUN mkdir /ms-playwright && \
/ms-playwright-agent/playwright.ps1 install chromium --with-deps && \
rm -rf /var/lib/apt/lists/* && \
rm -rf /tmp/* && \
rm -rf /ms-playwright-agent && \
chmod -R 777 /ms-playwright
COPY ublock/ /ublock/
COPY isdcac/ /isdcac/
The image builds with no errors but it seems like the install script doesn't really run, because there's no browser install progress bar like usual, and running the final image gives the same error about xvfb.
The text was updated successfully, but these errors were encountered:
I understand that in order to build the install script we need the sdk, and that the main use case for Playwright is testing, which also requires it, but for my use case (making a webserver that takes screenshots of pages) I only need the runtime. Currently I have these two images:
playwright:0.1.0
This works fine, but the final image is >2Gb, which is not ideal. I tried changing the base image like this:
But then starting the final image errors with
[FATAL tini (7)] exec xvfb-run failed: No such file or directory
, so I guess simply copying /ms-playwright is not enough. Any help?EDIT: Also tried copying the install script from the sdk image to the runtime one and running it there, but no luck:
The image builds with no errors but it seems like the install script doesn't really run, because there's no browser install progress bar like usual, and running the final image gives the same error about xvfb.
The text was updated successfully, but these errors were encountered: