From 8333a7c6aa1ca8733b8922b0e7893d0795482966 Mon Sep 17 00:00:00 2001 From: Max Schmitt Date: Thu, 24 Nov 2022 15:23:37 -1000 Subject: [PATCH 1/2] chore: introduce Docker Jammy images --- utils/docker/Dockerfile.jammy | 41 ++++++++++++++++++++++++++++++++++ utils/docker/build.sh | 2 +- utils/docker/publish_docker.sh | 33 +++++++++++++-------------- 3 files changed, 58 insertions(+), 18 deletions(-) create mode 100644 utils/docker/Dockerfile.jammy diff --git a/utils/docker/Dockerfile.jammy b/utils/docker/Dockerfile.jammy new file mode 100644 index 0000000000..6c6b2041b9 --- /dev/null +++ b/utils/docker/Dockerfile.jammy @@ -0,0 +1,41 @@ +FROM mcr.microsoft.com/dotnet/sdk:6.0-jammy + +ARG DEBIAN_FRONTEND=noninteractive +ARG TZ=America/Los_Angeles +ARG DOCKER_IMAGE_NAME_TEMPLATE="mcr.microsoft.com/playwright/dotnet:v%version%-jammy" + +# === INSTALL dependencies === + +RUN apt-get update && \ + # Feature-parity with node.js base images. + apt-get install -y --no-install-recommends git openssh-client curl 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/* /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 && \ + dotnet new console && \ + echo '' > nuget.config && \ + dotnet add package Microsoft.Playwright --prerelease && \ + dotnet build && \ + ./bin/Debug/net6.0/playwright.ps1 install --with-deps && \ + ./bin/Debug/net6.0/playwright.ps1 mark-docker-image "${DOCKER_IMAGE_NAME_TEMPLATE}" && \ + rm -rf /var/lib/apt/lists/* && \ + rm -rf /tmp/* && \ + rm -rf /ms-playwright-agent && \ + chmod -R 777 /ms-playwright diff --git a/utils/docker/build.sh b/utils/docker/build.sh index 42019313f0..7e6e06dec5 100755 --- a/utils/docker/build.sh +++ b/utils/docker/build.sh @@ -3,7 +3,7 @@ set -e set +x if [[ ($1 == '--help') || ($1 == '-h') || ($1 == '') || ($2 == '') ]]; then - echo "usage: $(basename $0) {--arm64,--amd64} {bionic,focal} playwright:localbuild-focal" + echo "usage: $(basename $0) {--arm64,--amd64} {focal,jammy} playwright:localbuild-focal" echo echo "Build Playwright docker image and tag it as 'playwright:localbuild-focal'." echo "Once image is built, you can run it with" diff --git a/utils/docker/publish_docker.sh b/utils/docker/publish_docker.sh index 322486e3a3..8ba4d2a284 100755 --- a/utils/docker/publish_docker.sh +++ b/utils/docker/publish_docker.sh @@ -28,20 +28,11 @@ if [[ -z "${GITHUB_SHA}" ]]; then exit 1 fi -BIONIC_TAGS=( - "next-bionic" - "v${PW_VERSION}-bionic" -) -if [[ "$RELEASE_CHANNEL" == "stable" ]]; then - BIONIC_TAGS+=("bionic") -fi - FOCAL_TAGS=( "next" "sha-${GITHUB_SHA}" "next-focal" ) - if [[ "$RELEASE_CHANNEL" == "stable" ]]; then FOCAL_TAGS+=("latest") FOCAL_TAGS+=("focal") @@ -49,6 +40,14 @@ if [[ "$RELEASE_CHANNEL" == "stable" ]]; then FOCAL_TAGS+=("v${PW_VERSION}") fi +JAMMY_TAGS=( + "next-jammy" +) +if [[ "$RELEASE_CHANNEL" == "stable" ]]; then + JAMMY_TAGS+=("jammy") + JAMMY_TAGS+=("v${PW_VERSION}-jammy") +fi + tag_and_push() { local source="$1" local target="$2" @@ -60,12 +59,12 @@ tag_and_push() { publish_docker_images_with_arch_suffix() { local FLAVOR="$1" local TAGS=() - if [[ "$FLAVOR" == "bionic" ]]; then - TAGS=("${BIONIC_TAGS[@]}") - elif [[ "$FLAVOR" == "focal" ]]; then + if [[ "$FLAVOR" == "focal" ]]; then TAGS=("${FOCAL_TAGS[@]}") + elif [[ "$FLAVOR" == "jammy" ]]; then + TAGS=("${_TAGS[@]}") else - echo "ERROR: unknown flavor - $FLAVOR. Must be either 'bionic' or 'focal'" + echo "ERROR: unknown flavor - $FLAVOR. Must be either 'focal' or 'jammy'" exit 1 fi local ARCH="$2" @@ -86,12 +85,12 @@ publish_docker_images_with_arch_suffix() { publish_docker_manifest () { local FLAVOR="$1" local TAGS=() - if [[ "$FLAVOR" == "bionic" ]]; then - TAGS=("${BIONIC_TAGS[@]}") - elif [[ "$FLAVOR" == "focal" ]]; then + if [[ "$FLAVOR" == "focal" ]]; then TAGS=("${FOCAL_TAGS[@]}") + elif [[ "$FLAVOR" == "jammy" ]]; then + TAGS=("${JAMMY_TAGS[@]}") else - echo "ERROR: unknown flavor - $FLAVOR. Must be either 'bionic' or 'focal'" + echo "ERROR: unknown flavor - $FLAVOR. Must be either 'focal' or 'jammy'" exit 1 fi From 8fa96b4948df8d3fbd4dba1aa48f0b027aad4947 Mon Sep 17 00:00:00 2001 From: Max Schmitt Date: Mon, 28 Nov 2022 08:45:44 -1000 Subject: [PATCH 2/2] Update utils/docker/publish_docker.sh --- utils/docker/publish_docker.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/utils/docker/publish_docker.sh b/utils/docker/publish_docker.sh index 8ba4d2a284..ab34ab6efd 100755 --- a/utils/docker/publish_docker.sh +++ b/utils/docker/publish_docker.sh @@ -62,7 +62,7 @@ publish_docker_images_with_arch_suffix() { if [[ "$FLAVOR" == "focal" ]]; then TAGS=("${FOCAL_TAGS[@]}") elif [[ "$FLAVOR" == "jammy" ]]; then - TAGS=("${_TAGS[@]}") + TAGS=("$JAMMY_TAGS[@]}") else echo "ERROR: unknown flavor - $FLAVOR. Must be either 'focal' or 'jammy'" exit 1