question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Docker: How to build a functional Dockerfile

See original GitHub issue

I’m trying to understand how to run PlaywrightSharp in a docker container. I started with the basic, the Net Core image and got:

PlaywrightSharp.PlaywrightSharpException: 'Host system is missing dependencies!

  Missing libraries are:
      libgobject-2.0.so.0
      libglib-2.0.so.0
      libnss3.so
      libnssutil3.so
      libsmime3.so
      libnspr4.so
      libatk-1.0.so.0
      libatk-bridge-2.0.so.0
      libx11.so.6
      libx11-xcb.so.1
      libxcb.so.1
      libcups.so.2
      libdbus-1.so.3
      libgio-2.0.so.0
      libexpat.so.1
      libdrm.so.2
      libxkbcommon.so.0
      libxcomposite.so.1
      libxdamage.so.1
      libxext.so.6
      libxfixes.so.3
      libxrandr.so.2
      libgtk-3.so.0
      libgdk-3.so.0
      libpango-1.0.so.0
      libcairo.so.2
      libgdk_pixbuf-2.0.so.0
      libgbm.so.1
      libasound.so.2
      libatspi.so.0

I know documentation on this topic is missing, but I would like wich is the best way to start:

Option A: The Playwright image and install Net Core dependencies Option B: The Net Core image and install Playwright dependencies

I took a look at the Dockerfile from the Playwright project but could not make it work.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:16 (4 by maintainers)

github_iconTop GitHub Comments

3reactions
GaryYu2by2commented, Mar 25, 2021

Our client only allows Debian images in their k8s, they require a gRPC service to capture PDFs from one of their in-house developed web app. This is the complete Docker file, works with both asp.net core 3.1 and 5.0. For Playwright 0.162.0 and Chromium only.

FROM mcr.microsoft.com/dotnet/aspnet:5.0 AS base

RUN apt-get update && apt-get install -y --no-install-recommends \
    xvfb

RUN apt-get update && apt-get install -y --no-install-recommends \
    fonts-liberation\
    libasound2\
    libatk-bridge2.0-0\
    libatk1.0-0\
    libatspi2.0-0\
    libcairo2\
    libcups2\
    libdbus-1-3\
    libdrm2\
    libgbm1\
    libglib2.0-0\
    libgtk-3-0\
    libnspr4\
    libnss3\
    libpango-1.0-0\
    libx11-6\
    libxcb1\
    libxcomposite1\
    libxdamage1\
    libxext6\
    libxfixes3\
    libxrandr2

 RUN apt-get update && apt-get install -y npm && \
     npm i playwright-chromium@1.6.2 && \
     npm i playwright-firefox@1.6.2 && \
     npm i playwright-webkit@1.6.2
 RUN apt-get remove nodejs -y

WORKDIR /app
EXPOSE 80

FROM mcr.microsoft.com/dotnet/sdk:5.0 AS build
WORKDIR /src
COPY ["MyApp.Api/MyApp.Api.csproj", "MyApp.Api/"]
RUN dotnet restore "MyApp.Api/MyApp.Api.csproj"
COPY . .
WORKDIR "/src/MyApp.Api"
RUN dotnet build "MyApp.Api.csproj" -c Release -o /app/build

FROM build AS publish
RUN dotnet publish "MyApp.Api.csproj" -c Release -o /app/publish

FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "MyApp.Api.dll"]
2reactions
pablopiolicommented, Mar 9, 2021

And this is for Playwright 0.191 on Net 5. It´s a little different since the platform runtimes are copied at build time.

FROM mcr.microsoft.com/dotnet/sdk:5.0 as build
WORKDIR /src
COPY ["MyApp.csproj", ""]
RUN dotnet restore "./MyApp.csproj"
COPY . .
WORKDIR "/src/."
RUN dotnet publish /src/MyApp/MyApp.csproj -c Release -o /publish \
    && mkdir /publish/.playwright \
    && cp -r /src/MyApp/bin/Release/net5.0/.playwright/unix /publish/.playwright 
    
FROM mcr.microsoft.com/playwright:v1.9.1-focal AS playwright
RUN apt-get update \
    && apt-get install -y wget \
    && wget https://packages.microsoft.com/config/ubuntu/20.04/packages-microsoft-prod.deb -O packages-microsoft-prod.deb \
    && dpkg -i packages-microsoft-prod.deb \
    && apt-get update \
    && apt-get install -y apt-transport-https \
    && apt-get install -y aspnetcore-runtime-5.0 \
    && apt-get remove -y wget
EXPOSE 80
COPY --from=build /publish/ /app/
RUN chown -R pwuser:pwuser /app
ENTRYPOINT ["dotnet", "/app/MyApp.dll"]
Read more comments on GitHub >

github_iconTop Results From Across the Web

docker build
The docker build command builds Docker images from a Dockerfile and a "context". A build's context is the set of files located in...
Read more >
Docker Build: A Beginner's Guide to Building Docker Images
With Dockerfile written, you can build the image using the following command: $ docker build . We can see the image we just...
Read more >
How To Build Docker Image [Comprehensive Beginners ...
Build Docker Image Using Dockerfile · Step 1: Create the required Files and folders · Step 2: Create a sample HTML file &...
Read more >
How to Build an Image with the Dockerfile
We'll create a directory called my_image in our home directory, use it as our working directory, and place the Dockerfile in there:
Read more >
What is a Dockerfile? A Step-by-Step Guide [2023 Updated]
To create a Dockerfile, set up Docker and Docker Hub. Create the original Docker container and then create a file on it. Make...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found