Description
openedon Apr 1, 2020
Context
- Playwright Version:
v0.12.1
- Operating System: Mac & Docker locally and in CI (buildkite)
- Extra: N/A
Code Snippet
Using the example Docker file: docs/docker/Dockerfile.bionic
docker-compose.yml
playwright:
image: <private repo image name> # we have private node modules/repos added in image
security_opt:
- "seccomp:./chrome-seccomp.json"
volumes:
- ./playwright:/work
- /work/node_modules/ # prevents local node_modules from overridding image node_modules to speed up builds
Firefox test file
const playwright = require('playwright')
const run = async () => {
const browser = await playwright['firefox'].launch()
const context = await browser.newContext({
viewport: {
height: 1080,
width: 1600,
}
})
const page = await context.newPage()
page.goto('http://www.google.com')
browser.close()
}
run()
Describe the bug
TL;DR;
- Main Issue - We are unable to run Firefox (headless) in a docker image using the example Dockerfile. However, after adding a lot of dependencies we were able to get it to run. Can these additional dependencies be added to the example Dockerfile and/or vetted to make sure they are all needed?
- Chrome was unable to run using less than privileged user
pwuser
in CI (buildkite), able to run when including a seccomp.json file. Locally image is using logged in user (who has elevated privileges) and notpwuser
Using the example file we were able to launch chrome just fine after including a seccomp.json file. Locally we found that the docker image took our local user instead of the defined USER pwuser
in the dockerfile. In CI (buildkite), I'm assuming, it acted the same way taking the user in the build agent and adding CAPS_ADD
to the docker-compose file did not help . However, forgoing the less than privileged user and including a seccomp.json file allowed chrome to run.
Firefox however was not able to run (headless) regardless of our permissioning locally or in CI.
After combining a lot of information from the internet we were able to get Firefox running both locally and in CI with the following dependencies. I'm not sure if any of the additional dependencies can be paired down at all, but this is what allowed us to get Firefox running in an image.
Dependency installation in Dockerfile
FROM ubuntu:bionic
# Install node12
RUN apt-get update \
&& apt-get install -y curl \
&& curl -sL https://deb.nodesource.com/setup_12.x | bash - \
&& apt-get install -y nodejs \
# Install yarn
&& npm install -g yarn \
# Install WebKit dependencies
&& apt-get install -y 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 \
# Install Chromium dependencies
&& apt-get install -y libnss3 \
libxss1 \
libasound2 \
# Install Firefox dependencies
&& apt-get install -y libdbus-glib-1-2 \
xvfb \
gconf-service \
libatk1.0-0 \
libc6 \
libcairo2 \
libcups2 \
libdbus-1-3 \
libexpat1 \
libfontconfig1 \
libgcc1 \
libgconf-2-4 \
libgdk-pixbuf2.0-0 \
libglib2.0-0 \
libgtk-3-0 \
libnspr4 \
libpango-1.0-0 \
libpangocairo-1.0-0 \
libstdc++6 \
libx11-6 \
libx11-xcb1 \
libxcb1 \
libxcomposite1 \
libxcursor1 \
libxdamage1 \
libxext6 \
libxfixes3 \
libxi6 \
libxrandr2 \
libxrender1 \
libxss1 \
libxtst6 \
ca-certificates \
fonts-liberation \
libappindicator1 \
libnss3 \
lsb-release \
xdg-utils \
# Install encodings for audio and video files
ffmpeg