произошла ошибка, пытаясь запустить процесс «USR/bin/Google-chrome-stable 'с рабочим каталогом'/app '. Нет такого файла или каталога at system.diagnostics.process.forkandexecess (processTartinfo startInfo, строки ressolenme-ressolenme-resostrame. Envp, String Cwd, Boolean Setcredentials, Uint32 userId, Uint32 GroupId, Uint32 [] Groups, Int32 & Stdinfd, Int32 & Stdoutfd, Int32 & Stderrfd, Boolean usesterminal, boolean drowonnoexec)
at system.diagnostics.process.startartartartartartartartartartr startInfo)
at puppeteersharp.states.processstartingstate.startcoreasync (Launcherbase P) в /HOME/Runner/work/puppeteer-sharp/puppeteer-sharp/lib/puppeteersharp/states/processstartstate.cs:lie 68
in puppeteersharp.launcherc. /home/runner/work/puppeteer-sharp/puppeteer-sharp/lib/puppeteersharp/launcher.cs:line 110
at pdfapi.controllers.weatherforecastController.get (String Key13) в C: \ projects \ converthtmptopdfnepnew \ controllers. 58 < /p>
) < /p>
В журнале системы нет ошибок.
журнал информации: файл не существует. Это означает, что Chrome не был загружен.
Каковы его причины? Любые идеи. < /P>
Код: Выделить всё
# Use .NET 9.0 ASP.NET base image
FROM mcr.microsoft.com/dotnet/aspnet:9.0
# Set the working directory to /app
WORKDIR /app
# Expose ports for the application
EXPOSE 8080
EXPOSE 8081
# Install dependencies and Chrome
RUN apt-get update -y && \
apt-get install -yqq \
unzip \
wget \
curl \
libgdiplus \
libc6-dev \
libx11-dev && \
wget -q https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb && \
apt-get install -y ./google-chrome-stable_current_amd64.deb && \
# Get the latest ChromeDriver version number
CHROME_DRIVER_VERSION=$(curl -sS https://chromedriver.storage.googleapis.com/LATEST_RELEASE) && \
wget -q -O /tmp/chromedriver.zip https://chromedriver.storage.googleapis.com/${CHROME_DRIVER_VERSION}/chromedriver_linux64.zip && \
unzip -q /tmp/chromedriver.zip chromedriver -d /usr/local/bin/ && \
rm -f /tmp/chromedriver.zip google-chrome-stable_current_amd64.deb && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*
# Set the environment path
ENV PATH="/usr/local/bin/chromedriver:${PATH}"
# Entry point for the .NET application
ENTRYPOINT ["dotnet", "PdfApi.dll"]
< /code>
[HttpGet(Name = "GetWeatherForecast")]
public async Task Get()
{
byte[] screenshot;
string chromePath = "/usr/bin/google-chrome-stable";
bool exists = System.IO.File.Exists(chromePath);
if (exists)
{
_logger.LogInformation("file exist");
}
else
{
_logger.LogInformation("file not exist");
}
try
{
using var browser = await Puppeteer.LaunchAsync(new LaunchOptions
{
Headless = true,
ExecutablePath = Environment.GetEnvironmentVariable("PUPPETEER_EXECUTABLE_PATH") ?? chromePath,
Args = new[] { "--no-sandbox", "--disable-setuid-sandbox" }
});
using var page = await browser.NewPageAsync();
await page.GoToAsync("https://example.com");
screenshot = await page.ScreenshotDataAsync();
}
catch (Exception ex)
{
return BadRequest(ex.Message + ex.StackTrace);
}
return File(screenshot, "image/png");
Подробнее здесь: https://stackoverflow.com/questions/794 ... tainer-app