56 lines
2.0 KiB
Docker
56 lines
2.0 KiB
Docker
FROM ubuntu:noble
|
|
|
|
ARG DEBIAN_FRONTEND=noninteractive
|
|
ARG TZ=America/Los_Angeles
|
|
ARG DOCKER_IMAGE_NAME_TEMPLATE="mcr.microsoft.com/playwright/python:v%version%-noble"
|
|
|
|
ENV LANG=C.UTF-8
|
|
ENV LC_ALL=C.UTF-8
|
|
|
|
# === INSTALL Python ===
|
|
|
|
RUN apt-get update && \
|
|
# Install Python
|
|
apt-get install -y python3 curl && \
|
|
# Align with upstream Python image and don't be externally managed:
|
|
# https://github.com/docker-library/python/issues/948
|
|
rm /usr/lib/python3.12/EXTERNALLY-MANAGED && \
|
|
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/* && \
|
|
rm /tmp/*.whl && \
|
|
rm -rf /ms-playwright-agent && \
|
|
chmod -R 777 /ms-playwright
|