Skip to content

Instantly share code, notes, and snippets.

@mxschmitt
Last active May 31, 2022 21:53
Show Gist options
  • Save mxschmitt/900aa310730bfac360717796b62ad072 to your computer and use it in GitHub Desktop.
Save mxschmitt/900aa310730bfac360717796b62ad072 to your computer and use it in GitHub Desktop.
Outdated! Playwright Python Dockerfile for https://github.com/microsoft/playwright-python see here https://playwright.dev/docs/docker
################################################
# Compile with:
# docker build -t mcr.microsoft.com/playwright:python-buster -f Dockerfile.buster .
#
# Run with:
# docker run -d -p --rm --name playwright mcr.microsoft.com/playwright:python-buster
#
#################################################
FROM python:3.8-slim-buster
# Install dependencies
RUN apt-get update && \
apt-get install -y \
# WebKit dependencies
libwoff1 \
libopus0 \
libwebp6 \
libwebpdemux2 \
libenchant1c2a \
libgudev-1.0-0 \
libsecret-1-0 \
libhyphen0 \
libgdk-pixbuf2.0-0 \
libegl1 \
libxslt1.1 \
libgles2 \
# gstreamer and plugins to support video playback in WebKit
libgstreamer-gl1.0-0 \
libgstreamer-plugins-bad1.0-0 \
gstreamer1.0-plugins-good \
# Chromium dependencies
libnss3 \
libxss1 \
libasound2 \
fonts-noto-color-emoji \
libatk1.0-0 \
libatk-bridge2.0-0 \
libxcomposite1 \
libcups2 \
libgtk-3-0 \
# Firefox dependencies
libdbus-glib-1-2 \
libxt6 \
# FFmpeg to bring in audio and video codecs necessary for playing videos in Firefox
ffmpeg \
# (Optional) XVFB if there's a need to run browsers in headful mode
xvfb \
# For compiling libjpeg for WebKit
curl \
gcc \
make
# Compiling libjpeg for WebKit
RUN cd /tmp && \
curl -s http://www.ijg.org/files/jpegsrc.v8d.tar.gz | tar zx && \
cd jpeg-8d && \
./configure && \
make && \
make install
# Add directory in which libjpeg was built to the search path
ENV LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH
# Add user so we don't need --no-sandbox in Chromium
RUN groupadd -r pwuser && useradd -r -g pwuser -G audio,video pwuser \
&& mkdir -p /home/pwuser/Downloads \
&& chown -R pwuser:pwuser /home/pwuser
# Run everything after as non-privileged user
USER pwuser
@Bashorun97
Copy link

This Docker image is outdated, please refer to the official one: https://playwright.dev/docs/dockerC

This page says not found

@mxschmitt
Copy link
Author

Thanks, I fixed the broken link.

@DiMiTriFrog
Copy link

Works with headful mode and lambda?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment