[Question]: Retrieve installation script playwright.ps1 out of project-bound context
See original GitHub issueYour question
Hi 👋🏻
In this project, I use Playwright inside an ASP.NET Core application to create screenshots of a website. As my app runs inside Docker, I have to install Playwright when building the image (see here for complete file):
FROM --platform=$TARGETARCH mcr.microsoft.com/dotnet/aspnet:7.0 AS base
ARG TARGETARCH
WORKDIR /app
COPY src/ScreenshotCreator.Api/install-powershell-$TARGETARCH.sh /scripts/install-powershell-$TARGETARCH.sh
RUN chmod +x /scripts/install-powershell-$TARGETARCH.sh
RUN /scripts/install-powershell-$TARGETARCH.sh
...other stuff
FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
RUN ["pwsh", "playwright.ps1", "install", "chromium"]
RUN ["pwsh", "playwright.ps1", "install-deps", "chromium"]
ENTRYPOINT ["dotnet", "ScreenshotCreator.Api.dll"]
Since playwright.ps1
is only present after calling dotnet publish
, it is the very last step of the Dockerfile
, leading to the disadvantage that Docker cannot cache this (probably not really changing) layer when the previous layers (my app’s code) changes. That significantly slows down my development process, as installing Playwright becomes necessary on every single iteration.
Therefore it would be nice if I could install Playwright at the very beginning after installing PowerShell, e. g.:
FROM --platform=$TARGETARCH mcr.microsoft.com/dotnet/aspnet:7.0 AS base
ARG TARGETARCH
WORKDIR /app
COPY src/ScreenshotCreator.Api/install-powershell-$TARGETARCH.sh /scripts/install-powershell-$TARGETARCH.sh
RUN chmod +x /scripts/install-powershell-$TARGETARCH.sh
RUN /scripts/install-powershell-$TARGETARCH.sh
RUN ["pwsh", "playwright.ps1", "install", "chromium"]
RUN ["pwsh", "playwright.ps1", "install-deps", "chromium"]
...other stuff
FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "ScreenshotCreator.Api.dll"]
But for this to work, I need to fetch playwright.ps1
somehow from somewhere, e. g. by using wget
. Is there any way of doing this without relying on dotnet publish
?
Thx and have a nice weeekend!
Issue Analytics
- State:
- Created 2 months ago
- Comments:5 (3 by maintainers)
There are no plans as of today. If you want to have a different base image, we recommend creating your own. If you suggest changing it, I recommend creating another issue which we can label as a feature request, and based on the users we can change that. But we need to be careful, since this might be a breaking change.
Ah that explains why the Playwright Docker image is so big, because the SDK is used as base image. Are you planning to change that and shrink the image size? It is really huge to work with it…