microsoft / playwright

Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.
https://playwright.dev
Apache License 2.0
65.6k stars 3.57k forks source link

[Feature] Docker image future features #3791

Closed mxschmitt closed 3 years ago

mxschmitt commented 4 years ago

Issue about which changes in the Docker image are needed / requested by the community.

domderen commented 3 years ago

I think this could work as a base image for Playwright-Python:

FROM python:3.7-buster

# 1. Install WebKit dependencies
RUN apt-get update && apt-get install -y --no-install-recommends \
    libwoff1 \
    libopus0 \
    libwebp6 \
    libwebpdemux2 \
    libenchant1c2a \
    libgudev-1.0-0 \
    libsecret-1-0 \
    libhyphen0 \
    libgdk-pixbuf2.0-0 \
    libegl1 \
    libnotify4 \
    libxslt1.1 \
    libevent-2.1-6 \
    libgles2 \
    libvpx5 \
    libxcomposite1 \
    libatk1.0-0 \
    libatk-bridge2.0-0 \
    libepoxy0 \
    libgtk-3-0 \
    libharfbuzz-icu0

# 2. Install gstreamer and plugins to support video playback in WebKit.
RUN apt-get update && apt-get install -y --no-install-recommends \
    libgstreamer-gl1.0-0 \
    libgstreamer-plugins-bad1.0-0 \
    gstreamer1.0-plugins-good \
    gstreamer1.0-libav

# 3. Install Chromium dependencies
RUN apt-get update && apt-get install -y --no-install-recommends \
    libnss3 \
    libxss1 \
    libasound2 \
    fonts-noto-color-emoji \
    libxtst6

# 4. Install Firefox dependencies
RUN apt-get update && apt-get install -y --no-install-recommends \
    libdbus-glib-1-2 \
    libxt6

# 5. Install ffmpeg to bring in audio and video codecs necessary for playing videos in Firefox.
RUN apt-get update && apt-get install -y --no-install-recommends \
    ffmpeg

# 6. (Optional) Install XVFB if there's a need to run browsers in headful mode
RUN apt-get update && apt-get install -y --no-install-recommends \
    xvfb

# 7. Install playwright for python
RUN pip install playwright

# 8. Download browsers into the image
RUN python -m playwright install

Though I'm assuming you might want to customize it with user defined Python version? For example create those base images for different Python/Playwright versions. What do you think about that?

domderen commented 3 years ago

Here's a PR that would generate Python 3.7 & Python 3.8 docker images with Playwright-Python baked in: https://github.com/microsoft/playwright-python/pull/197

At the moment it attempts to run unit tests before building the docker image, and those fail inside docker, so needs further investigation.

pavelfeldman commented 3 years ago

Looks like it is now tracked in Python land, thanks!