Skip to content

Puppeteer-sharp not working on linux docker container #1180

Closed
@brechtvhb

Description

@brechtvhb

Docker base image is: mcr.microsoft.com/dotnet/core/aspnet:2.2-alpine3.9

I'm gettting this error
[12:17:23 INF] Starting to initialize puppeteer
[12:17:23 INF] Saving puppeteer to /app/puppeteer
[12:17:36 INF] puppeteer executable path is /app/puppeteer/Linux-662092/chrome-linux/chrome
[12:17:36 INF] Puppeteer initialized

System.ComponentModel.Win32Exception (2): No such file or directory
at Interop.Sys.ForkAndExecProcess(String filename, String[] argv, String[] envp, String cwd, Boolean redirectStdin, Boolean redirectStdout, Boolean redirectStderr, Boolean setUser, UInt32 userId, UInt32 groupId, Int32& lpChildPid, Int32& stdinFd, Int32& stdoutFd, Int32& stderrFd, Boolean shouldThrow)
at System.Diagnostics.Process.StartCore(ProcessStartInfo startInfo)
at System.Diagnostics.Process.Start()
at PuppeteerSharp.ChromiumProcess.State.StartingState.StartCoreAsync(ChromiumProcess p)
at PuppeteerSharp.Launcher.LaunchAsync(LaunchOptions options)
at PuppeteerSharp.Launcher.LaunchAsync(LaunchOptions options)

Code is :
Log.Information("Starting to initialize puppeteer");

        if (!Directory.Exists(_pdfSettings.PuppeteerPath))
            Directory.CreateDirectory(_pdfSettings.PuppeteerPath);

        Log.Information("Saving puppeteer to {path}", _pdfSettings.PuppeteerPath);

        var browserFetcher = new BrowserFetcher(new BrowserFetcherOptions
        {
            Path = _pdfSettings.PuppeteerPath
        });

        await browserFetcher.DownloadAsync(BrowserFetcher.DefaultRevision);

        var executablePath = browserFetcher.GetExecutablePath(BrowserFetcher.DefaultRevision);

        Log.Information("puppeteer executable path is {path}", executablePath);

        var launchOptions = new LaunchOptions
        {
            ExecutablePath = executablePath,
            Headless = true,
            LogProcess = true,
            Args = new[]
            {
                "--no-sandbox"
            }
        };

        Log.Information("Puppeteer initialized");

        await Puppeteer.LaunchAsync(launchOptions);

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions