Sign inSign up

gschaetz/web-automation

By gschaetz

Updated about 1 month ago

Image
0

3.1K

gschaetz/web-automation repository overview

Quick reference

What is web-automation?

The image web-automation is based on gschaetz/base-ubuntu and provides a comprehensive environment for web scraping and browser automation tasks. The image contains the following:

  • Non root user developer as the default user (inherited from base-ubuntu)
  • Chrome for Testing (Chromium builds) with auto-matched ChromeDriver
    • Latest stable Chrome/Chromium from Google's Chrome for Testing project
    • Chrome installed at /opt/chrome/chrome (symlinked to /usr/local/bin/chrome and /usr/local/bin/chromium)
    • ChromeDriver installed at /usr/local/bin/chromedriver (with symlink at /usr/bin/chromedriver)
    • Version automatically matched between browser and ChromeDriver
  • All necessary X11 and graphics libraries for headless browser operations
  • Python packages for web automation:
    • Selenium 4.15.2
    • BeautifulSoup4 for HTML parsing
    • Requests for HTTP operations
    • WebDriver Manager for automated driver management
    • Additional utilities (pydantic, click, tenacity, python-dateutil)

The image is built for the following architecture:

  • linux/amd64

Note: ARM64 is not supported because Chrome for Testing doesn't provide linux-arm64 builds. The image can still run on ARM64 hosts (e.g., Apple Silicon) using Docker's platform emulation with --platform linux/amd64.

How to use this image

Usage

Use like you would any other base image:

FROM gschaetz/web-automation:latest

Environment Variables

The following environment variables are pre-configured:

  • CHROME_BIN=/usr/local/bin/chrome - Path to Chrome binary
  • CHROMIUM_BIN=/usr/local/bin/chromium - Path to Chromium binary (same as chrome)
  • DISPLAY=:99 - Display setting for headless operation

Example: Running Selenium with Chromium

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

options = Options()
options.add_argument('--headless')
options.add_argument('--no-sandbox')
options.add_argument('--disable-dev-shm-usage')

# ChromeDriver will automatically use /usr/bin/chromium via CHROME_BIN env var
driver = webdriver.Chrome(options=options)
driver.get('https://example.com')
print(driver.title)
driver.quit()

Example: Explicitly specifying Chrome/Chromium binary and ChromeDriver

from selenium import webdriver
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.chrome.service import Service

options = Options()
options.binary_location = '/usr/local/bin/chrome'  # or '/usr/local/bin/chromium'
options.add_argument('--headless')
options.add_argument('--no-sandbox')
options.add_argument('--disable-dev-shm-usage')

service = Service('/usr/local/bin/chromedriver')
driver = webdriver.Chrome(service=service, options=options)
driver.get('https://example.com')
print(driver.title)
driver.quit()

License

My contributions are under MIT License

As with all Docker images, these likely also contain other software which may be under other licenses (such as Bash, Python, Chromium, Google Chrome, etc from the base distribution, along with any direct or indirect dependencies of the primary software being contained).

As for any pre-built image usage, it is the image user's responsibility to ensure that any use of this image complies with any relevant licenses for all software contained within.

Tag summary

Content type

Image

Digest

sha256:75b0e3956

Size

583.1 MB

Last updated

about 1 month ago

docker pull gschaetz/web-automation