From c9d9272f6b75eb60ef05a9681d3b4ae1ebeaea5b Mon Sep 17 00:00:00 2001 From: Max Schmitt Date: Mon, 12 Aug 2024 15:47:05 +0200 Subject: [PATCH 1/3] devops: add Ubuntu 24.04 (noble) Docker images --- .github/workflows/publish_docker.yml | 9 ------ utils/docker/Dockerfile.noble | 45 ++++++++++++++++++++++++++++ utils/docker/publish_docker.sh | 36 +++++++++++----------- 3 files changed, 63 insertions(+), 27 deletions(-) create mode 100644 utils/docker/Dockerfile.noble diff --git a/.github/workflows/publish_docker.yml b/.github/workflows/publish_docker.yml index 87db48384..d0db5543d 100644 --- a/.github/workflows/publish_docker.yml +++ b/.github/workflows/publish_docker.yml @@ -2,12 +2,6 @@ name: "publish release - Docker" on: workflow_dispatch: - inputs: - is_release: - required: false - type: boolean - description: "Is this a release image?" - release: types: [published] @@ -44,6 +38,3 @@ jobs: pip install -r local-requirements.txt pip install -e . - run: ./utils/docker/publish_docker.sh stable - if: (github.event_name != 'workflow_dispatch' && !github.event.release.prerelease) || (github.event_name == 'workflow_dispatch' && github.event.inputs.is_release == 'true') - - run: ./utils/docker/publish_docker.sh canary - if: (github.event_name != 'workflow_dispatch' && github.event.release.prerelease) || (github.event_name == 'workflow_dispatch' && github.event.inputs.is_release != 'true') diff --git a/utils/docker/Dockerfile.noble b/utils/docker/Dockerfile.noble new file mode 100644 index 000000000..054ed3e9e --- /dev/null +++ b/utils/docker/Dockerfile.noble @@ -0,0 +1,45 @@ +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" + +# === INSTALL Python === + +RUN apt-get update && \ + # Install Python + apt-get install -y python3 python3-pip python3-virtualenv curl && \ + update-alternatives --install /usr/bin/python python /usr/bin/python3 1 && \ + # 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 && \ + python -m 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 diff --git a/utils/docker/publish_docker.sh b/utils/docker/publish_docker.sh index 2b4e73a53..309edb63a 100755 --- a/utils/docker/publish_docker.sh +++ b/utils/docker/publish_docker.sh @@ -15,35 +15,27 @@ if [[ "${RELEASE_CHANNEL}" == "stable" ]]; then echo "ERROR: cannot publish stable docker with Playwright version '${PW_VERSION}'" exit 1 fi -elif [[ "${RELEASE_CHANNEL}" == "canary" ]]; then - if [[ "${PW_VERSION}" != *dev* ]]; then - echo "ERROR: cannot publish canary docker with Playwright version '${PW_VERSION}'" - exit 1 - fi else echo "ERROR: unknown release channel - ${RELEASE_CHANNEL}" echo "Must be either 'stable' or 'canary'" exit 1 fi +# Ubuntu 20.04 FOCAL_TAGS=( - "next-focal" + "v${PW_VERSION}-focal" ) -if [[ "$RELEASE_CHANNEL" == "stable" ]]; then - FOCAL_TAGS+=("focal") - FOCAL_TAGS+=("v${PW_VERSION}-focal") -fi +# Ubuntu 22.04 JAMMY_TAGS=( - "next" - "next-jammy" + "v${PW_VERSION}-jammy" +) + +# Ubuntu 24.04 +NOBLE_TAGS=( + "v${PW_VERSION}" + "v${PW_VERSION}-noble" ) -if [[ "$RELEASE_CHANNEL" == "stable" ]]; then - JAMMY_TAGS+=("latest") - JAMMY_TAGS+=("jammy") - JAMMY_TAGS+=("v${PW_VERSION}-jammy") - JAMMY_TAGS+=("v${PW_VERSION}") -fi tag_and_push() { local source="$1" @@ -81,6 +73,8 @@ publish_docker_images_with_arch_suffix() { TAGS=("${FOCAL_TAGS[@]}") elif [[ "$FLAVOR" == "jammy" ]]; then TAGS=("${JAMMY_TAGS[@]}") + elif [[ "$FLAVOR" == "noble" ]]; then + TAGS=("${NOBLE_TAGS[@]}") else echo "ERROR: unknown flavor - $FLAVOR. Must be either 'focal', or 'jammy'" exit 1 @@ -107,6 +101,8 @@ publish_docker_manifest () { TAGS=("${FOCAL_TAGS[@]}") elif [[ "$FLAVOR" == "jammy" ]]; then TAGS=("${JAMMY_TAGS[@]}") + elif [[ "$FLAVOR" == "noble" ]]; then + TAGS=("${NOBLE_TAGS[@]}") else echo "ERROR: unknown flavor - $FLAVOR. Must be either 'focal', or 'jammy'" exit 1 @@ -136,3 +132,7 @@ publish_docker_manifest focal amd64 arm64 publish_docker_images_with_arch_suffix jammy amd64 publish_docker_images_with_arch_suffix jammy arm64 publish_docker_manifest jammy amd64 arm64 + +publish_docker_images_with_arch_suffix noble amd64 +publish_docker_images_with_arch_suffix noble arm64 +publish_docker_manifest noble amd64 arm64 From d99b5fa7eedd087d25d10d6bee4eb067e0ca161b Mon Sep 17 00:00:00 2001 From: Max Schmitt Date: Mon, 12 Aug 2024 15:53:30 +0200 Subject: [PATCH 2/3] add noble tests --- .github/workflows/test_docker.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test_docker.yml b/.github/workflows/test_docker.yml index 5a3266197..178200f75 100644 --- a/.github/workflows/test_docker.yml +++ b/.github/workflows/test_docker.yml @@ -19,13 +19,14 @@ on: jobs: build: timeout-minutes: 120 - runs-on: ubuntu-22.04 + runs-on: ubuntu-24.04 strategy: fail-fast: false matrix: docker-image-variant: - focal - jammy + - noble steps: - uses: actions/checkout@v3 - name: Set up Python From d1876f5f668b45fbfb027d3d91485e11fc820ac1 Mon Sep 17 00:00:00 2001 From: Max Schmitt Date: Tue, 13 Aug 2024 11:27:57 +0200 Subject: [PATCH 3/3] fix things --- utils/docker/Dockerfile.noble | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/utils/docker/Dockerfile.noble b/utils/docker/Dockerfile.noble index 054ed3e9e..8262bf6a9 100644 --- a/utils/docker/Dockerfile.noble +++ b/utils/docker/Dockerfile.noble @@ -8,8 +8,14 @@ ARG DOCKER_IMAGE_NAME_TEMPLATE="mcr.microsoft.com/playwright/python:v%version%-n RUN apt-get update && \ # Install Python - apt-get install -y python3 python3-pip python3-virtualenv curl && \ + 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 @@ -32,7 +38,8 @@ COPY ./dist/*-manylinux*.whl /tmp/ RUN mkdir /ms-playwright && \ mkdir /ms-playwright-agent && \ cd /ms-playwright-agent && \ - python -m virtualenv venv && \ + 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 && \