ARG ACR_CACHE_PREFIX FROM ${ACR_CACHE_PREFIX}ubuntu:jammy ARG DEBIAN_FRONTEND=noninteractive ARG TZ=America/Los_Angeles ARG DOCKER_IMAGE_NAME_TEMPLATE="mcr.microsoft.com/playwright/python:v%version%-jammy" ARG UBUNTU_MIRROR_PREFIX ENV LANG=C.UTF-8 ENV LC_ALL=C.UTF-8 # === INSTALL Python === RUN --mount=type=secret,id=pipconf,target=/etc/pip.conf,required=false \ find /etc/apt -type f \( -name '*.list' -o -name '*.sources' \) \ -exec sed -i "s|http://archive.ubuntu.com|http://${UBUNTU_MIRROR_PREFIX}archive.ubuntu.com|g; s|http://ports.ubuntu.com|http://${UBUNTU_MIRROR_PREFIX}ports.ubuntu.com|g" {} + && \ 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 --mount=type=secret,id=pipconf,target=/etc/pip.conf,required=false \ 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