question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Question]: Retrieve installation script playwright.ps1 out of project-bound context

See original GitHub issue

Your 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:closed
  • Created 2 months ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
mxschmittcommented, Jul 11, 2023

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.

0reactions
mu88commented, Jul 11, 2023

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…

Read more comments on GitHub >

github_iconTop Results From Across the Web

[Feature] More intuitive setup and installation of Playwright
I'd expect dotnet Microsoft.Playwright.dll to do the same as the PowerShell script, but it does error.
Read more >
.net - Cannot install playwright: Couldn't find project using ...
Playwright . This method calls the exe located in the .playwright folder. This folder is copied to the build folder when building the...
Read more >
Continuous Integration
Playwright tests can be executed in CI environments. ... 3 steps to get your tests running on CI: ... Install Playwright browsers and...
Read more >
Untitled
Abstract paintings brisbane, Luminus devices, Bears seahawks game score, Unadopted roads in kent, Scripting ai in unity, Pro wrestling guerrilla dvds uk, ...
Read more >
Untitled
Jual tombol on off. Emre ozdemir beni birakin mp3, Mmmp. Anwesenheitskontrolle app, Entretien du centre d'appel au maroc, Tw13 golf shoes size 13, ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found