Sign inSign up

sjw7444/lambda-playwright-python

By sjw7444

•Updated about 1 month ago

Base Docker image for running Playwright with Python on AWS Lambda with ARM support

Image
Developer tools
1

2.5K

sjw7444/lambda-playwright-python repository overview

This repository contains a base Docker image for running Playwright with Python on AWS Lambda with ARM support. The image is optimized for serverless environments and includes all necessary dependencies for headless Chromium browser automation.

Github: lambda-playwright-python⁠

⁠Features

  • Python 3.13 support with latest performance improvements
  • Playwright with headless Chromium browser
  • AWS Lambda ARM64 compatibility
  • Optimized for serverless environments
  • Minimal dependencies for Chromium only
  • Uses AWS Lambda's microdnf package manager
  • Enhanced type system and better type checking
  • Improved memory management and performance
  • VS Code dev container support with development tools

⁠Usage as Base Image

⁠Pulling the Base Image
# From DockerHub
docker pull sjw7444/lambda-playwright-python:latest

# From AWS ECR
aws ecr-public get-login-password --region us-east-1 | docker login --username AWS --password-stdin public.ecr.aws/j9p6g6v0/lambda-playwright-python
docker pull public.ecr.aws/j9p6g6v0/lambda-playwright-python:latest
⁠Using as Base Image

Create a new Dockerfile in your project:

FROM sjw7444/lambda-playwright-python:latest

# Copy your Lambda function code
COPY your_lambda_function.py ${LAMBDA_TASK_ROOT}

# Set the CMD to your handler
CMD [ "your_lambda_function.handler" ]
⁠Example Lambda Function with Headless Chromium
from playwright.sync_api import sync_playwright

def handler(event, context):
    with sync_playwright() as p:
        # Launch headless Chromium
        browser = p.chromium.launch(headless=True)
        page = browser.new_page()
        
        # Your automation code here
        page.goto('https://example.com')
        title = page.title()
        
        browser.close()
        return {'statusCode': 200, 'body': title}

Tag summary

Content type

Image

Digest

sha256:17b175eca…

Size

674.5 MB

Last updated

about 1 month ago

docker pull sjw7444/lambda-playwright-python