mirror of
https://github.com/microsoft/playwright.git
synced 2024-12-14 21:53:35 +03:00
841bb92049
Node.js 20 was promoted to LTS on 2023-10-24. Fixes https://github.com/microsoft/playwright/issues/27812
49 lines
1.9 KiB
Docker
49 lines
1.9 KiB
Docker
FROM ubuntu:focal
|
|
|
|
ARG DEBIAN_FRONTEND=noninteractive
|
|
ARG TZ=America/Los_Angeles
|
|
ARG DOCKER_IMAGE_NAME_TEMPLATE="mcr.microsoft.com/playwright:v%version%-focal"
|
|
|
|
# === INSTALL Node.js ===
|
|
|
|
RUN apt-get update && \
|
|
# Install Node.js
|
|
apt-get install -y curl wget gpg ca-certificates && \
|
|
mkdir -p /etc/apt/keyrings && \
|
|
curl -sL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg && \
|
|
echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_20.x nodistro main" >> /etc/apt/sources.list.d/nodesource.list && \
|
|
apt-get update && \
|
|
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.
|
|
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 && \
|
|
npm i /tmp/playwright-core.tar.gz && \
|
|
npm exec --no -- playwright-core mark-docker-image "${DOCKER_IMAGE_NAME_TEMPLATE}" && \
|
|
npm exec --no -- playwright-core install --with-deps && rm -rf /var/lib/apt/lists/* && \
|
|
rm /tmp/playwright-core.tar.gz && \
|
|
rm -rf /ms-playwright-agent && \
|
|
rm -rf ~/.npm/ && \
|
|
chmod -R 777 /ms-playwright
|