Sign inSign up

killdozerx2/lambda-chromium

By killdozerx2

•Updated over 5 years ago

Image
0

1.7K

killdozerx2/lambda-chromium repository overview

⁠lambda-chromium

Base image to be used to create other containers that can be deployed to AWS Ecr and used as lambdas

⁠Why?

Scale your scraping and web automations using AWS lambda

⁠Supported runtime

  • Python 3.6
  • TODO: node and java

⁠How to use this image?

You should use this image as a base image to create other images that can be deployed to ecr and used as lambdas.

FROM killdozerx2/lambda-chromium:latest
# Copy your source code and requirements file
COPY . ${LAMBDA_TASK_ROOT}
# Install dependencies
RUN pip install -r requirements.txt

# Set the entrypoint like so
ENTRYPOINT [ "/usr/bin/python", "-m", "awslambdaric" ]

# Set the cmd to run
CMD [ "<path_to_your_lambda_file>.<name_of_the_function>" ]

The path to the chrome binary and webdriver are already available as envrionment variables

  • CHROME_DRIVER_PATH: Path to chrome webdriver
  • CHROME_BINARY_PATH: Path to chromium binary

⁠Updates required in code.

Earlier your would run chromium in headless mode using the --headless flag, you don't need that anymore, instead you need to use pyvirtualdisplay.

# Previously
from selenium import webdriver
from selenium.webdriver.chrome.options import Options

chrome_options = webdriver.ChromeOptions()
chrome_option.add_argument("--headless")
chrome_option.add_argument("--disable-gpu")
chrome_option.add_argument("--no-sandbox")
# Now you can simple remove the headless and disable-gpu flag
from selenium import webdriver
from pyvirtualdisplay import Display
display = Display(visible=0, size=(1280, 1696))
display.start()

chrome_options = webdriver.ChromeOptions()
chrome_option.add_argument("--no-sandbox")

Tag summary

Content type

Image

Digest

Size

460 MB

Last updated

over 5 years ago

docker pull killdozerx2/lambda-chromium