PuppeteerSharp: Failed to launch browser after switching to Alpine Linux

I had the PuppeteerSharp working with the Debian distro but now I need to run with a wolfi-base distro that is Alpine. You can read more about it here.

On my docker file, I had installed the following dependencies:

RUN apt-get update && apt-get install -y xorg openbox libnss3 libasound2

And this worked fine. I look what I can install that is similar and got:

RUN apk update && apk add xorg-server openbox nss alsa-lib

But now I cannot launch the browser and I believe this because now I have missing dependencies:

Unhandled exception. PuppeteerSharp.ProcessException: Failed to launch browser!

Here is how I launch it on my .net 8 application:

private static async Task<IBrowser> GetAndLaunchOsMatchingBrowser()
{
    var browserFetcher = new BrowserFetcher();

    await browserFetcher.DownloadAsync(BrowserFetcher.DefaultChromiumRevision);

    var launchOptions = new LaunchOptions
    {
        Args = new[] { "--no-sandbox", "--disable-setuid-sandbox" },
        Headless = true,
        ExecutablePath = Path.Combine(browserFetcher.RevisionInfo(BrowserFetcher.DefaultChromiumRevision).ExecutablePath)
    };

    return await Puppeteer.LaunchAsync(launchOptions);
}

I cannot download Chromium directly and point to the path to launch it. Are there any dependencies I need to run it?
Thank you!

Edit: After digging in the logs I got

error while loading shared libraries: libnss3.so: cannot open shared object file: No such file or directory

Leave a Comment