forked from microsoft/playwright-python
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile.jammy
58 lines (51 loc) · 2.37 KB
/
Dockerfile.jammy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
FROM ubuntu:jammy
ARG DEBIAN_FRONTEND=noninteractive
ARG TZ=America/Los_Angeles
ARG DOCKER_IMAGE_NAME_TEMPLATE="mcr.microsoft.com/playwright/python:v%version%-jammy"
# === INSTALL Python ===
RUN apt-get update && \
# Install Python
apt-get install -y python3 python3-distutils curl && \
update-alternatives --install /usr/bin/python python /usr/bin/python3 1 && \
curl -sSL https://bootstrap.pypa.io/get-pip.py -o get-pip.py && \
python get-pip.py && \
rm get-pip.py && \
# Feature-parity with node.js base images.
apt-get install -y --no-install-recommends git openssh-client gpg && \
# 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 ./dist/*-manylinux*.whl /tmp/
# 2. Bake in browsers & deps.
# 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 && \
pip install virtualenv && \
virtualenv venv && \
. venv/bin/activate && \
# if its amd64 then install the manylinux1_x86_64 pip package
if [ "$(uname -m)" = "x86_64" ]; then pip install /tmp/*manylinux1_x86_64*.whl; fi && \
# if its arm64 then install the manylinux1_aarch64 pip package
if [ "$(uname -m)" = "aarch64" ]; then pip install /tmp/*manylinux_2_17_aarch64*.whl; fi && \
playwright mark-docker-image "${DOCKER_IMAGE_NAME_TEMPLATE}" && \
playwright install --with-deps && rm -rf /var/lib/apt/lists/* && \
# Workaround for https://github.com/microsoft/playwright/issues/27313
# While the gstreamer plugin load process can be in-process, it ended up throwing
# an error that it can't have libsoup2 and libsoup3 in the same process because
# libgstwebrtc is linked against libsoup2. So we just remove the plugin.
if [ "$(uname -m)" = "aarch64" ]; then \
rm /usr/lib/aarch64-linux-gnu/gstreamer-1.0/libgstwebrtc.so; \
else \
rm /usr/lib/x86_64-linux-gnu/gstreamer-1.0/libgstwebrtc.so; \
fi && \
rm /tmp/*.whl && \
rm -rf /ms-playwright-agent && \
chmod -R 777 /ms-playwright