|
| 1 | +FROM ubuntu:resolute |
| 2 | + |
| 3 | +ARG DEBIAN_FRONTEND=noninteractive |
| 4 | +ARG TZ=America/Los_Angeles |
| 5 | +ARG DOCKER_IMAGE_NAME_TEMPLATE="mcr.microsoft.com/playwright/python:v%version%-resolute" |
| 6 | + |
| 7 | +ENV LANG=C.UTF-8 |
| 8 | +ENV LC_ALL=C.UTF-8 |
| 9 | + |
| 10 | +# === INSTALL Python === |
| 11 | + |
| 12 | +RUN apt-get update && \ |
| 13 | + # Install Python |
| 14 | + apt-get install -y python3 curl && \ |
| 15 | + # Align with upstream Python image and don't be externally managed: |
| 16 | + # https://github.com/docker-library/python/issues/948 |
| 17 | + rm -f /usr/lib/python3.*/EXTERNALLY-MANAGED && \ |
| 18 | + update-alternatives --install /usr/bin/python python /usr/bin/python3 1 && \ |
| 19 | + curl -sSL https://bootstrap.pypa.io/get-pip.py -o get-pip.py && \ |
| 20 | + python get-pip.py && \ |
| 21 | + rm get-pip.py && \ |
| 22 | + # Feature-parity with node.js base images. |
| 23 | + apt-get install -y --no-install-recommends git openssh-client gpg && \ |
| 24 | + # clean apt cache |
| 25 | + rm -rf /var/lib/apt/lists/* && \ |
| 26 | + # Create the pwuser |
| 27 | + useradd -m -s /bin/bash pwuser |
| 28 | + |
| 29 | +# === BAKE BROWSERS INTO IMAGE === |
| 30 | + |
| 31 | +ENV PLAYWRIGHT_BROWSERS_PATH=/ms-playwright |
| 32 | + |
| 33 | +# 1. Add tip-of-tree Playwright package to install its browsers. |
| 34 | +# The package should be built beforehand from tip-of-tree Playwright. |
| 35 | +COPY ./dist/*-manylinux*.whl /tmp/ |
| 36 | + |
| 37 | +# 2. Bake in browsers & deps. |
| 38 | +# Browsers will be downloaded in `/ms-playwright`. |
| 39 | +# Note: make sure to set 777 to the registry so that any user can access |
| 40 | +# registry. |
| 41 | +RUN mkdir /ms-playwright && \ |
| 42 | + mkdir /ms-playwright-agent && \ |
| 43 | + cd /ms-playwright-agent && \ |
| 44 | + pip install virtualenv && \ |
| 45 | + virtualenv venv && \ |
| 46 | + . venv/bin/activate && \ |
| 47 | + # if its amd64 then install the manylinux1_x86_64 pip package |
| 48 | + if [ "$(uname -m)" = "x86_64" ]; then pip install /tmp/*manylinux1_x86_64*.whl; fi && \ |
| 49 | + # if its arm64 then install the manylinux1_aarch64 pip package |
| 50 | + if [ "$(uname -m)" = "aarch64" ]; then pip install /tmp/*manylinux_2_17_aarch64*.whl; fi && \ |
| 51 | + playwright mark-docker-image "${DOCKER_IMAGE_NAME_TEMPLATE}" && \ |
| 52 | + playwright install --with-deps && rm -rf /var/lib/apt/lists/* && \ |
| 53 | + rm /tmp/*.whl && \ |
| 54 | + rm -rf /ms-playwright-agent && \ |
| 55 | + chmod -R 777 /ms-playwright |
0 commit comments