|
| 1 | +FROM ubuntu:focal |
| 2 | + |
| 3 | +# 1. Install latest Python |
| 4 | +RUN apt-get update && apt-get install -y python3 python3-pip && \ |
| 5 | + update-alternatives --install /usr/bin/pip pip /usr/bin/pip3 1 && \ |
| 6 | + update-alternatives --install /usr/bin/python python /usr/bin/python3 1 |
| 7 | + |
| 8 | +# 2. Install WebKit dependencies |
| 9 | +RUN apt-get update && DEBIAN_FRONTEND="noninteractive" apt-get install -y --no-install-recommends \ |
| 10 | + libwoff1 \ |
| 11 | + libopus0 \ |
| 12 | + libwebp6 \ |
| 13 | + libwebpdemux2 \ |
| 14 | + libenchant1c2a \ |
| 15 | + libgudev-1.0-0 \ |
| 16 | + libsecret-1-0 \ |
| 17 | + libhyphen0 \ |
| 18 | + libgdk-pixbuf2.0-0 \ |
| 19 | + libegl1 \ |
| 20 | + libnotify4 \ |
| 21 | + libxslt1.1 \ |
| 22 | + libevent-2.1-7 \ |
| 23 | + libgles2 \ |
| 24 | + libxcomposite1 \ |
| 25 | + libatk1.0-0 \ |
| 26 | + libatk-bridge2.0-0 \ |
| 27 | + libepoxy0 \ |
| 28 | + libgtk-3-0 \ |
| 29 | + libharfbuzz-icu0 |
| 30 | + |
| 31 | +# 3. Install gstreamer and plugins to support video playback in WebKit. |
| 32 | +RUN apt-get update && apt-get install -y --no-install-recommends \ |
| 33 | + libgstreamer-gl1.0-0 \ |
| 34 | + libgstreamer-plugins-bad1.0-0 \ |
| 35 | + gstreamer1.0-plugins-good \ |
| 36 | + gstreamer1.0-libav |
| 37 | + |
| 38 | +# 4. Install Chromium dependencies |
| 39 | +RUN apt-get update && apt-get install -y --no-install-recommends \ |
| 40 | + libnss3 \ |
| 41 | + libxss1 \ |
| 42 | + libasound2 \ |
| 43 | + fonts-noto-color-emoji \ |
| 44 | + libxtst6 |
| 45 | + |
| 46 | +# 5. Install Firefox dependencies |
| 47 | +RUN apt-get update && apt-get install -y --no-install-recommends \ |
| 48 | + libdbus-glib-1-2 \ |
| 49 | + libxt6 |
| 50 | + |
| 51 | +# 6. Install ffmpeg to bring in audio and video codecs necessary for playing videos in Firefox. |
| 52 | +RUN apt-get update && apt-get install -y --no-install-recommends \ |
| 53 | + ffmpeg |
| 54 | + |
| 55 | +# 7. (Optional) Install XVFB if there's a need to run browsers in headful mode |
| 56 | +RUN apt-get update && apt-get install -y --no-install-recommends \ |
| 57 | + xvfb |
| 58 | + |
| 59 | +# 8. Feature-parity with node.js base images. |
| 60 | +RUN apt-get update && apt-get install -y --no-install-recommends git ssh |
| 61 | + |
| 62 | +# 9. Create the pwuser (we internally create a symlink for the pwuser and the root user) |
| 63 | +RUN adduser pwuser |
| 64 | + |
| 65 | +# === BAKE BROWSERS INTO IMAGE === |
| 66 | + |
| 67 | +# 1. Add tip-of-tree Playwright Python package to install its browsers. |
| 68 | +# The package should be built beforehand from tip-of-tree Playwright. |
| 69 | +COPY ./dist/playwright*manylinux1*.whl /tmp/playwright-1.0-py3-none-manylinux1_x86_64.whl |
| 70 | + |
| 71 | +# 2. Install playwright and then delete the installation. |
| 72 | +# Browsers will remain downloaded in `/home/pwuser/.cache/ms-playwright`. |
| 73 | +RUN su pwuser -c "mkdir /tmp/pw && cd /tmp/pw && \ |
| 74 | + pip install /tmp/playwright-1.0-py3-none-manylinux1_x86_64.whl && \ |
| 75 | + python -m playwright install" && \ |
| 76 | + rm -rf /tmp/pw && rm /tmp/playwright-1.0-py3-none-manylinux1_x86_64.whl |
| 77 | + |
| 78 | +# 3. Symlink downloaded browsers for root user |
| 79 | +RUN mkdir /root/.cache/ && \ |
| 80 | + ln -s /home/pwuser/.cache/ms-playwright/ /root/.cache/ms-playwright |
0 commit comments