Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 11 additions & 6 deletions .github/workflows/test_docker.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Test Docker
name: Docker
on:
push:
paths:
Expand All @@ -18,13 +18,18 @@ on:
- release-*
jobs:
test:
timeout-minutes: 60
runs-on: ubuntu-20.04
name: Test
timeout-minutes: 120
runs-on: ubuntu-22.04
strategy:
fail-fast: false
matrix:
flavor: [focal, jammy]
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: Build Docker image
run: bash utils/docker/build.sh --amd64 focal playwright-java:localbuild-focal
run: bash utils/docker/build.sh --amd64 ${{ matrix.flavor }} playwright-java:localbuild-${{ matrix.flavor }}
- name: Test
run: |
CONTAINER_ID="$(docker run --rm --ipc=host -v $(pwd):/root/playwright --name playwright-docker-test -d -t playwright-java:localbuild-focal /bin/bash)"
CONTAINER_ID="$(docker run --rm --ipc=host -v $(pwd):/root/playwright --name playwright-docker-test -d -t playwright-java:localbuild-${{ matrix.flavor }} /bin/bash)"
docker exec "${CONTAINER_ID}" /root/playwright/tools/test-local-installation/create_project_and_run_tests.sh
57 changes: 57 additions & 0 deletions utils/docker/Dockerfile.jammy
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
FROM ubuntu:jammy

ARG DEBIAN_FRONTEND=noninteractive
ARG TZ=America/Los_Angeles
ARG DOCKER_IMAGE_NAME_TEMPLATE="mcr.microsoft.com/playwright/java:v%version%-jammy"

# === INSTALL JDK and Maven ===

RUN apt-get update && \
# Install install jdk 17 in a separate apt-get command so that
# installing maven doesn't bring in jdk 11
apt-get install -y --no-install-recommends openjdk-17-jdk && \
apt-get install -y --no-install-recommends \
# Ubuntu 22.04 and earlier come with Maven 3.6.3 which fails with
# Java 17, so we install latest Maven from Apache instead.
# maven \
# Install utilities required for downloading browsers
curl \
# Install utilities required for downloading driver
unzip \
# For the MSEdge install script
gpg && \
rm -rf /var/lib/apt/lists/* && \
# Create the pwuser
adduser pwuser

RUN VERSION=3.8.8 && \
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

jammy may have fresh enough Maven and we may be able to drop this lines

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will keep them in sync for now!

curl -o - https://archive.apache.org/dist/maven/maven-3/$VERSION/binaries/apache-maven-$VERSION-bin.tar.gz | tar zxfv - -C /opt/ && \
ln -s /opt/apache-maven-$VERSION/bin/mvn /usr/local/bin/

ARG PW_TARGET_ARCH
ENV JAVA_HOME=/usr/lib/jvm/java-17-openjdk-${PW_TARGET_ARCH}

# === BAKE BROWSERS INTO IMAGE ===

# Browsers will remain downloaded in `/ms-playwright`.
# Note: make sure to set 777 to the registry so that any user can access
# registry.

ENV PLAYWRIGHT_BROWSERS_PATH=/ms-playwright

RUN mkdir /ms-playwright && \
mkdir /tmp/pw-java

COPY . /tmp/pw-java

RUN cd /tmp/pw-java && \
./scripts/download_driver_for_all_platforms.sh && \
mvn install -D skipTests --no-transfer-progress && \
DEBIAN_FRONTEND=noninteractive mvn exec:java -e -D exec.mainClass=com.microsoft.playwright.CLI \
-D exec.args="install-deps" -f playwright/pom.xml --no-transfer-progress && \
mvn exec:java -e -D exec.mainClass=com.microsoft.playwright.CLI \
-D exec.args="install" -f playwright/pom.xml --no-transfer-progress && \
mvn exec:java -e -D exec.mainClass=com.microsoft.playwright.CLI \
-D exec.args="mark-docker-image '${DOCKER_IMAGE_NAME_TEMPLATE}'" -f playwright/pom.xml --no-transfer-progress && \
rm -rf /tmp/pw-java && \
chmod -R 777 $PLAYWRIGHT_BROWSERS_PATH
2 changes: 1 addition & 1 deletion utils/docker/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ set -e
set +x

if [[ ($1 == '--help') || ($1 == '-h') || ($1 == '') || ($2 == '') ]]; then
echo "usage: $(basename $0) {--arm64,--amd64} {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"
Expand Down
37 changes: 21 additions & 16 deletions utils/docker/publish_docker.sh
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,6 @@ 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}"
Expand All @@ -55,6 +47,15 @@ if [[ "$RELEASE_CHANNEL" == "stable" ]]; then
FOCAL_TAGS+=("v${PW_VERSION}")
fi

JAMMY_TAGS=(
"next-jammy"
"v${PW_VERSION}-jammy"
)

if [[ "$RELEASE_CHANNEL" == "stable" ]]; then
JAMMY_TAGS+=("jammy")
fi

tag_and_push() {
local source="$1"
local target="$2"
Expand All @@ -66,12 +67,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=("${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
local ARCH="$2"
Expand All @@ -92,12 +93,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

Expand All @@ -119,3 +120,7 @@ publish_docker_manifest () {
publish_docker_images_with_arch_suffix focal amd64
publish_docker_images_with_arch_suffix focal arm64
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