From af000bda7d91273ce480193add5bbe68deb0862f Mon Sep 17 00:00:00 2001 From: Jim Woodroffe <2574460+sjw7444@users.noreply.github.com> Date: Tue, 24 Feb 2026 19:12:17 +0000 Subject: [PATCH 01/10] Fix image --- docker-compose.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker-compose.yml b/docker-compose.yml index b7972e9..ca32345 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -3,7 +3,7 @@ services: build: context: . dockerfile: Dockerfile - image: sjw744/lambda-playwright-python:latest + image: sjw7444/lambda-playwright-python:latest platform: linux/arm64 volumes: - .:/var/task From 369389057e899bcc381ba9d74754fab1812ca5aa Mon Sep 17 00:00:00 2001 From: Jim Woodroffe <2574460+sjw7444@users.noreply.github.com> Date: Tue, 24 Feb 2026 19:16:27 +0000 Subject: [PATCH 02/10] Upgrade Docker Buildx action to v6 in deploy workflow --- .github/workflows/deploy.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 028aaf3..5e7281c 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -54,10 +54,11 @@ jobs: registry-type: public - name: Build and push to DockerHub - uses: docker/build-push-action@v4 + uses: docker/build-push-action@v6 with: context: . push: true + platforms: linux/arm64 tags: | ${{ secrets.DOCKERHUB_USERNAME }}/lambda-playwright-python:latest ${{ secrets.DOCKERHUB_USERNAME }}/lambda-playwright-python:${{ github.sha }} @@ -66,7 +67,7 @@ jobs: cache-to: type=gha,mode=max - name: Build and push to Amazon ECR Public - uses: docker/build-push-action@v4 + uses: docker/build-push-action@v6 with: context: . push: true From bc5296a1366b25ca361bf0d7f211461d6efc1eb3 Mon Sep 17 00:00:00 2001 From: Jim Woodroffe <2574460+sjw7444@users.noreply.github.com> Date: Tue, 24 Feb 2026 19:18:03 +0000 Subject: [PATCH 03/10] Update playwright version to 1.58.0 in requirements.txt --- requirements.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/requirements.txt b/requirements.txt index ddff0b1..0986bce 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,3 +1,3 @@ -playwright == 1.54.0 +playwright==1.58.0 pytest-playwright==0.7.2 -pytest == 9.0.2 +pytest==9.0.2 From ac99db30ae021b059d598c57f7e326a78e30d38f Mon Sep 17 00:00:00 2001 From: Jim Woodroffe <2574460+sjw7444@users.noreply.github.com> Date: Tue, 24 Feb 2026 19:18:47 +0000 Subject: [PATCH 04/10] Add recommendations for remote containers and debugpy; update container descriptions --- .vscode/extensions.json | 5 +++-- .vscode/settings.json | 3 +++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/.vscode/extensions.json b/.vscode/extensions.json index d6604f8..c175a4c 100644 --- a/.vscode/extensions.json +++ b/.vscode/extensions.json @@ -1,14 +1,15 @@ { "recommendations": [ + "ms-vscode-remote.remote-containers", "ms-python.python", "ms-python.vscode-pylance", "ms-azuretools.vscode-docker", "ms-python.black-formatter", "ms-python.flake8", "ms-python.pylint", + "ms-python.debugpy", "njpwerner.autodocstring", "kevinrose.vsc-python-indent", - "visualstudioexptteam.vscodeintellicode", - "ev.container-lambda-playwright-python" + "github.vscode-github-actions" ] } \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json index 856e1ed..cdfcb8f 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -42,5 +42,8 @@ "docker.defaultPlatform": "linux/arm64", "docker.containers.description": { "lambda-playwright": "Playwright Python Lambda Base Image" + }, + "containers.containers.description": { + "lambda-playwright": "Playwright Python Lambda Base Image" } } \ No newline at end of file From 44798a4d7a299c664ef9e4c0757d4fd536d22d06 Mon Sep 17 00:00:00 2001 From: Jim Woodroffe <2574460+sjw7444@users.noreply.github.com> Date: Tue, 24 Feb 2026 19:19:04 +0000 Subject: [PATCH 05/10] Refactor devcontainer configuration: update Python interpreter path and enhance post-create command --- .devcontainer/devcontainer.json | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index b771c27..e298dde 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -18,13 +18,11 @@ "ms-python.pylint", "njpwerner.autodocstring", "kevinrose.vsc-python-indent", - "visualstudioexptteam.vscodeintellicode", - "ev.container-lambda-playwright-python", "github.vscode-github-actions", "ms-python.debugpy" ], "settings": { - "python.defaultInterpreterPath": "/usr/local/bin/python", + "python.defaultInterpreterPath": "${workspaceFolder}/.venv/bin/python", "python.testing.pytestEnabled": true, "python.testing.unittestEnabled": false, "python.testing.nosetestsEnabled": false, @@ -37,6 +35,6 @@ "forwardPorts": [ 5678 ], - "postCreateCommand": "pip install -r requirements.txt", + "postCreateCommand": "set -e; PYVER=$(/var/lang/bin/python -c 'import sys; print(f\"{sys.version_info.major}.{sys.version_info.minor}\")'); if [ \"$PYVER\" != \"3.14\" ]; then echo \"WARNING: Expected Python 3.14 in container, got $PYVER. Run: Dev Containers: Rebuild Container\"; fi; /var/lang/bin/python -m venv .venv; ./.venv/bin/python -m pip install -U pip setuptools wheel; ./.venv/bin/python -m pip install -r requirements.txt", "remoteUser": "root" } \ No newline at end of file From d8315d02f15e822dac0841a1f9b11a869e8599cf Mon Sep 17 00:00:00 2001 From: Jim Woodroffe <2574460+sjw7444@users.noreply.github.com> Date: Tue, 24 Feb 2026 19:19:15 +0000 Subject: [PATCH 06/10] Update Python version to 3.14 in README.md --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index e3db6fe..b19f556 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,7 @@ This repository contains a base Docker image for running Playwright with Python ## Features -- Python 3.13 support with latest performance improvements +- Python 3.14 support with latest performance improvements - Playwright with headless Chromium browser - AWS Lambda ARM64 compatibility - Optimized for serverless environments @@ -28,7 +28,7 @@ This repository contains a base Docker image for running Playwright with Python - Docker - VS Code with Remote - Containers extension - AWS CLI (for ECR deployment) -- Python 3.13+ +- Python 3.14+ ### VS Code Dev Container From 6147ccf0c85a69853c18a065a830cd2795ca1d6f Mon Sep 17 00:00:00 2001 From: Jim Woodroffe <2574460+sjw7444@users.noreply.github.com> Date: Tue, 24 Feb 2026 19:19:33 +0000 Subject: [PATCH 07/10] Upgrade base image to AWS Lambda Python 3.14 and refine Playwright installation commands --- Dockerfile | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/Dockerfile b/Dockerfile index 4de74b3..cc9abdb 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,11 +1,9 @@ -# Use AWS Lambda Python 3.13 base image -FROM public.ecr.aws/lambda/python:3.13-arm64 +# Use AWS Lambda Python 3.14 base image +FROM public.ecr.aws/lambda/python:3.14-arm64 # Set environment variables ENV PYTHONUNBUFFERED=1 \ - DEBIAN_FRONTEND=noninteractive \ PLAYWRIGHT_BROWSERS_PATH=/opt/playwright \ - PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=1 \ PLAYWRIGHT_CHROMIUM_EXECUTABLE_PATH=/opt/playwright/chromium-*/chrome # Install system dependencies for Chromium only @@ -46,12 +44,12 @@ RUN microdnf install -y \ # Install Python dependencies COPY requirements.txt . -RUN pip install --no-cache-dir --upgrade pip && \ - pip install --no-cache-dir -r requirements.txt && \ +RUN python -m pip install --no-cache-dir --upgrade pip setuptools wheel && \ + python -m pip install --no-cache-dir -r requirements.txt && \ rm -rf /root/.cache/pip # Install Playwright browsers and set proper permissions -RUN playwright install chromium && \ +RUN python -m playwright install chromium && \ chmod -R 777 /opt/playwright && \ find /opt/playwright -type f -name "chrome" -exec chmod +x {} \; && \ # Create necessary directories From 85e34a8a1978043b47ab86a5ddf2dc7283c70cae Mon Sep 17 00:00:00 2001 From: Jim Woodroffe <2574460+sjw7444@users.noreply.github.com> Date: Tue, 24 Feb 2026 19:44:43 +0000 Subject: [PATCH 08/10] Refactor Playwright tests to use centralized launch arguments and update default formatter for Dockerfiles --- .vscode/extensions.json | 1 + .vscode/settings.json | 2 +- tests/test_basic.py | 11 ++++++++++- tests/test_playwright.py | 11 ++++++++++- 4 files changed, 22 insertions(+), 3 deletions(-) diff --git a/.vscode/extensions.json b/.vscode/extensions.json index c175a4c..80cd6c9 100644 --- a/.vscode/extensions.json +++ b/.vscode/extensions.json @@ -4,6 +4,7 @@ "ms-python.python", "ms-python.vscode-pylance", "ms-azuretools.vscode-docker", + "foxundermoon.shell-format", "ms-python.black-formatter", "ms-python.flake8", "ms-python.pylint", diff --git a/.vscode/settings.json b/.vscode/settings.json index cdfcb8f..7845b5f 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -17,7 +17,7 @@ } }, "[dockerfile]": { - "editor.defaultFormatter": "ms-azuretools.vscode-docker" + "editor.defaultFormatter": "foxundermoon.shell-format" }, "python.analysis.typeCheckingMode": "basic", "python.analysis.autoImportCompletions": true, diff --git a/tests/test_basic.py b/tests/test_basic.py index 1f4c3d8..58ed8cc 100644 --- a/tests/test_basic.py +++ b/tests/test_basic.py @@ -2,10 +2,19 @@ from playwright.sync_api import sync_playwright +LAUNCH_ARGS = [ + "--no-sandbox", + "--disable-setuid-sandbox", + "--disable-dev-shm-usage", + "--disable-gpu", + "--no-zygote", + "--single-process", +] + def test_playwright_installation(): """Test that Playwright and Chromium are properly installed.""" with sync_playwright() as p: - browser = p.chromium.launch(headless=True) + browser = p.chromium.launch(headless=True, args=LAUNCH_ARGS) assert browser is not None browser.close() diff --git a/tests/test_playwright.py b/tests/test_playwright.py index acfc7f1..af30622 100644 --- a/tests/test_playwright.py +++ b/tests/test_playwright.py @@ -2,11 +2,20 @@ from playwright.sync_api import sync_playwright +LAUNCH_ARGS = [ + "--no-sandbox", + "--disable-setuid-sandbox", + "--disable-dev-shm-usage", + "--disable-gpu", + "--no-zygote", + "--single-process", +] + def test_basic_navigation(): """Test basic browser navigation.""" with sync_playwright() as p: - browser = p.chromium.launch(headless=True) + browser = p.chromium.launch(headless=True, args=LAUNCH_ARGS) page = browser.new_page() page.goto("https://example.com") assert page.title() == "Example Domain" From 15f1a07547de5a84cb5484d28e17306e10988303 Mon Sep 17 00:00:00 2001 From: Jim Woodroffe <2574460+sjw7444@users.noreply.github.com> Date: Tue, 24 Feb 2026 19:45:10 +0000 Subject: [PATCH 09/10] Add pytest-cov to requirements for improved test coverage reporting --- requirements.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/requirements.txt b/requirements.txt index 0986bce..a6345d5 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,3 +1,4 @@ playwright==1.58.0 pytest-playwright==0.7.2 pytest==9.0.2 +pytest-cov>=6.0.0 From 24ab1aa97793dbf7fd9a581b66460d9ad174ba4e Mon Sep 17 00:00:00 2001 From: Jim Woodroffe <2574460+sjw7444@users.noreply.github.com> Date: Tue, 24 Feb 2026 19:50:23 +0000 Subject: [PATCH 10/10] Update default Python interpreter path in devcontainer and VSCode settings --- .devcontainer/devcontainer.json | 2 +- .vscode/settings.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index e298dde..a6c074e 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -22,7 +22,7 @@ "ms-python.debugpy" ], "settings": { - "python.defaultInterpreterPath": "${workspaceFolder}/.venv/bin/python", + "python.defaultInterpreterPath": "/workspaces/lambda-playwright-python/.venv/bin/python", "python.testing.pytestEnabled": true, "python.testing.unittestEnabled": false, "python.testing.nosetestsEnabled": false, diff --git a/.vscode/settings.json b/.vscode/settings.json index 7845b5f..8762d8b 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,5 +1,5 @@ { - "python.defaultInterpreterPath": "${workspaceFolder}/.venv/bin/python", + "python.defaultInterpreterPath": "/workspaces/lambda-playwright-python/.venv/bin/python", "editor.formatOnSave": true, "editor.rulers": [ 100