From 09a1c516a4a862354ba488fad53cec7cff550c13 Mon Sep 17 00:00:00 2001 From: William Lewis Date: Wed, 10 Apr 2024 13:15:46 -0500 Subject: [PATCH] Status thus far --- .../AAIntegration.SimmonsBank.API.csproj | 4 +- AAIntegration.SimmonsBank.API/Dockerfile | 45 +++++++++++++++++++ .../Services/PuppeteerService.cs | 1 + DockerBuild.sh | 5 +++ 4 files changed, 53 insertions(+), 2 deletions(-) create mode 100644 AAIntegration.SimmonsBank.API/Dockerfile create mode 100644 DockerBuild.sh diff --git a/AAIntegration.SimmonsBank.API/AAIntegration.SimmonsBank.API.csproj b/AAIntegration.SimmonsBank.API/AAIntegration.SimmonsBank.API.csproj index c6baf26..5145e94 100644 --- a/AAIntegration.SimmonsBank.API/AAIntegration.SimmonsBank.API.csproj +++ b/AAIntegration.SimmonsBank.API/AAIntegration.SimmonsBank.API.csproj @@ -8,12 +8,12 @@ enable - + diff --git a/AAIntegration.SimmonsBank.API/Dockerfile b/AAIntegration.SimmonsBank.API/Dockerfile new file mode 100644 index 0000000..55b3acb --- /dev/null +++ b/AAIntegration.SimmonsBank.API/Dockerfile @@ -0,0 +1,45 @@ +FROM mcr.microsoft.com/dotnet/sdk:7.0 AS build-env + +WORKDIR /App + +# Copy everything +COPY . ./ +# Restore as distinct layers +RUN dotnet restore +# Build and publish a release +RUN dotnet publish -c Release -o out + +# Build runtime image +FROM mcr.microsoft.com/dotnet/aspnet:7.0 +#RUN apt-get update -yq && apt-get upgrade -yq && apt-get install -yq npm + +##################### +#PUPPETEER RECIPE +##################### +# Install latest chrome dev package and fonts to support major charsets (Chinese, Japanese, Arabic, Hebrew, Thai and a few others) +# Note: this installs the necessary libs to make the bundled version of Chromium that Puppeteer +# installs, work. +#ARG CHROME_VERSION="121.0.6167.139" +RUN apt-get update && apt-get -f install && apt-get -y install wget gnupg2 apt-utils +RUN wget --no-verbose -O /tmp/chrome.deb https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb \ +&& apt-get update \ +&& apt-get install -y /tmp/chrome.deb --no-install-recommends --allow-downgrades fonts-ipafont-gothic fonts-wqy-zenhei fonts-thai-tlwg fonts-kacst fonts-freefont-ttf \ +&& rm /tmp/chrome.deb + +# Add user, so we don't need --no-sandbox. +# same layer as npm install to keep re-chowned files from using up several hundred MBs more space +RUN groupadd -r pptruser && useradd -r -g pptruser -G audio,video pptruser \ + && mkdir -p /home/pptruser/Downloads \ + && chown -R pptruser:pptruser /home/pptruser + +# Run everything after as non-privileged user. +USER pptruser +##################### +#END PUPPETEER RECIPE +##################### + +ENV PUPPETEER_EXECUTABLE_PATH "/usr/bin/google-chrome-stable" + +WORKDIR /App +COPY --from=build-env /App/out . +ENTRYPOINT ["dotnet", "AAIntegration.SimmonsBank.API.dll"] diff --git a/AAIntegration.SimmonsBank.API/Services/PuppeteerService.cs b/AAIntegration.SimmonsBank.API/Services/PuppeteerService.cs index 70a74ba..a5c5f5d 100644 --- a/AAIntegration.SimmonsBank.API/Services/PuppeteerService.cs +++ b/AAIntegration.SimmonsBank.API/Services/PuppeteerService.cs @@ -333,6 +333,7 @@ public class PuppeteerService : IPuppeteerService var options = new LaunchOptions { Headless = _config.Headless, IgnoreHTTPSErrors = true, + Args = new [] { "--no-sandbox" } }; IBrowser browser = await Puppeteer.LaunchAsync(options).WaitAsync(TimeSpan.FromSeconds(_config.BrowserOperationTimeoutSeconds), cancellationToken); diff --git a/DockerBuild.sh b/DockerBuild.sh new file mode 100644 index 0000000..c04ca6b --- /dev/null +++ b/DockerBuild.sh @@ -0,0 +1,5 @@ +#!/bin/bash + +cd AAIntegration.SimmonsBank.API/ +docker build -t aaisb_test -f Dockerfile . +cd ../ \ No newline at end of file