playwright/utils/docker/Dockerfile.focal

44 lines
1.5 KiB
Docker
Raw Normal View History

FROM ubuntu:focal
ARG DEBIAN_FRONTEND=noninteractive
ARG TZ=America/Los_Angeles
feat: detect docker version and Playwright version mismatch (#12806) This patch prints a friendly instructions in case Docker image version mismatches Playwright version and there are missing browser dependencies. With this patch, Playwright will yield the following error: ``` root@f0774d2b2097:~# node a.mjs node:internal/process/promises:279 triggerUncaughtException(err, true /* fromPromise */); ^ browserType.launch: ╔════════════════════════════════════════════════════════════════════════════════════════════╗ ║ Host system is missing dependencies to run browsers. ║ ║ This is most likely due to docker image version not matching Playwright version: ║ ║ - Playwright: 1.22.0 ║ ║ - Docker: 1.21.0 ║ ║ ║ ║ Either: ║ ║ - (recommended) use docker image "mcr.microsoft.com/playwright:v1.22.0-focal" ║ ║ - (alternative 1) run the following command inside docker to install missing dependencies: ║ ║ ║ ║ npx playwright install-deps ║ ║ ║ ║ - (alternative 2) use Aptitude inside docker: ║ ║ ║ ║ apt-get install libgbm1 ║ ║ ║ ║ <3 Playwright Team ║ ╚════════════════════════════════════════════════════════════════════════════════════════════╝ at file:///root/a.mjs:3:10 { name: 'Error' }``` Fixes #12796 Co-authored-by: Dmitry Gozman <dgozman@gmail.com>
2022-03-26 00:45:53 +03:00
ARG DOCKER_IMAGE_NAME_TEMPLATE="mcr.microsoft.com/playwright:v%version%-focal"
# === INSTALL Node.js ===
RUN apt-get update && \
# Install node16
apt-get install -y curl wget gpg && \
curl -sL https://deb.nodesource.com/setup_18.x | bash - && \
apt-get install -y nodejs && \
# Feature-parity with node.js base images.
apt-get install -y --no-install-recommends git openssh-client && \
npm install -g yarn && \
# clean apt cache
rm -rf /var/lib/apt/lists/* && \
# Create the pwuser
adduser pwuser
# === BAKE BROWSERS INTO IMAGE ===
ENV PLAYWRIGHT_BROWSERS_PATH=/ms-playwright
# 1. Add tip-of-tree Playwright package to install its browsers.
# The package should be built beforehand from tip-of-tree Playwright.
2021-10-11 17:52:17 +03:00
COPY ./playwright-core.tar.gz /tmp/playwright-core.tar.gz
# 2. Bake in Playwright Agent.
# Playwright Agent is used to bake in browsers and browser dependencies,
# and run docker server later on.
# Browsers will be downloaded in `/ms-playwright`.
# Note: make sure to set 777 to the registry so that any user can access
# registry.
RUN mkdir /ms-playwright && \
mkdir /ms-playwright-agent && \
cd /ms-playwright-agent && npm init -y && \
2021-10-11 17:52:17 +03:00
npm i /tmp/playwright-core.tar.gz && \
feat: detect docker version and Playwright version mismatch (#12806) This patch prints a friendly instructions in case Docker image version mismatches Playwright version and there are missing browser dependencies. With this patch, Playwright will yield the following error: ``` root@f0774d2b2097:~# node a.mjs node:internal/process/promises:279 triggerUncaughtException(err, true /* fromPromise */); ^ browserType.launch: ╔════════════════════════════════════════════════════════════════════════════════════════════╗ ║ Host system is missing dependencies to run browsers. ║ ║ This is most likely due to docker image version not matching Playwright version: ║ ║ - Playwright: 1.22.0 ║ ║ - Docker: 1.21.0 ║ ║ ║ ║ Either: ║ ║ - (recommended) use docker image "mcr.microsoft.com/playwright:v1.22.0-focal" ║ ║ - (alternative 1) run the following command inside docker to install missing dependencies: ║ ║ ║ ║ npx playwright install-deps ║ ║ ║ ║ - (alternative 2) use Aptitude inside docker: ║ ║ ║ ║ apt-get install libgbm1 ║ ║ ║ ║ <3 Playwright Team ║ ╚════════════════════════════════════════════════════════════════════════════════════════════╝ at file:///root/a.mjs:3:10 { name: 'Error' }``` Fixes #12796 Co-authored-by: Dmitry Gozman <dgozman@gmail.com>
2022-03-26 00:45:53 +03:00
npx playwright mark-docker-image "${DOCKER_IMAGE_NAME_TEMPLATE}" && \
npx playwright install --with-deps && rm -rf /var/lib/apt/lists/* && \
rm /tmp/playwright-core.tar.gz && \
chmod -R 777 /ms-playwright