Fixed puppeteer not executing in docker container

This commit is contained in:
William Lewis 2024-04-10 16:22:18 -05:00
parent 09a1c516a4
commit 86d3cb9937
2 changed files with 26 additions and 37 deletions

View File

@ -1,6 +1,24 @@
FROM mcr.microsoft.com/dotnet/sdk:7.0 AS build-env FROM mcr.microsoft.com/dotnet/aspnet:7.0 AS base
WORKDIR /App #####################
#PUPPETEER RECIPE
#####################
RUN apt-get update && apt-get -f install && apt-get -y install wget gnupg2 apt-utils
RUN wget -q -O - https://dl.google.com/linux/linux_signing_key.pub | apt-key add -
RUN echo 'deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main' >> /etc/apt/sources.list
RUN apt-get update \
&& apt-get install -y google-chrome-stable --no-install-recommends --allow-downgrades fonts-ipafont-gothic fonts-wqy-zenhei fonts-thai-tlwg fonts-kacst fonts-freefont-ttf
######################
#END PUPPETEER RECIPE
######################
ENV PUPPETEER_EXECUTABLE_PATH "/usr/bin/google-chrome-stable"
WORKDIR /app
EXPOSE 80
EXPOSE 443
FROM mcr.microsoft.com/dotnet/sdk:7.0 AS build
WORKDIR /app
# Copy everything # Copy everything
COPY . ./ COPY . ./
@ -9,37 +27,7 @@ RUN dotnet restore
# Build and publish a release # Build and publish a release
RUN dotnet publish -c Release -o out RUN dotnet publish -c Release -o out
# Build runtime image FROM base AS final
FROM mcr.microsoft.com/dotnet/aspnet:7.0 WORKDIR /app
#RUN apt-get update -yq && apt-get upgrade -yq && apt-get install -yq npm COPY --from=build /app/out .
#####################
#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"] ENTRYPOINT ["dotnet", "AAIntegration.SimmonsBank.API.dll"]

View File

@ -1,5 +1,6 @@
#!/bin/bash #!/bin/bash
cd AAIntegration.SimmonsBank.API/ cd AAIntegration.SimmonsBank.API/
docker build -t aaisb_test -f Dockerfile . name="activeallocator-integration-simmonsbank"
docker build -t $name:latest -t $name:1.0.0 -f Dockerfile .
cd ../ cd ../