Sign inSign up

tranlight/seleniumbase-api

By tranlight

•Updated 7 months ago

SeleniumBase API: Backend for n8n-nodes-seleniumbase

Image
Web servers
0

563

tranlight/seleniumbase-api repository overview

⁠SeleniumBase API Docker Hub Image

This guide documents how to build, push, pull, and run the API image published to Docker Hub.

⁠n8n Integration Note

This image is deeply integrated with the SeleniumBase n8n node workflow and is intended to be used as the API backend for n8n automation pipelines.

Reference node package: n8n-nodes-seleniumbase⁠

⁠Image Summary

  • Base command: uvicorn api.api_server:app --host 0.0.0.0 --port 8000
  • API port: 8000
  • Runtime services started by entrypoint: Xvfb, cron
  • Persistent data paths in container: /app/jobs, /app/artifacts, /app/attachments, /app/profiles, /app/db

⁠Build And Push To Docker Hub

export DOCKERHUB_USER="<your-dockerhub-username>"
export IMAGE_NAME="seleniumbase-api"
export TAG="latest"

docker login
docker build -t "${DOCKERHUB_USER}/${IMAGE_NAME}:${TAG}" .
docker push "${DOCKERHUB_USER}/${IMAGE_NAME}:${TAG}"

Optional immutable tag:

export SHA_TAG="$(git rev-parse --short HEAD)"
docker tag "${DOCKERHUB_USER}/${IMAGE_NAME}:${TAG}" \
  "${DOCKERHUB_USER}/${IMAGE_NAME}:${SHA_TAG}"
docker push "${DOCKERHUB_USER}/${IMAGE_NAME}:${SHA_TAG}"

⁠Pull And Run

mkdir -p ./data/jobs ./data/artifacts ./data/attachments ./data/profiles ./data/db

docker run -d \
  --name seleniumbase-api \
  -p 8000:8000 \
  -v "$(pwd)/data/jobs:/app/jobs" \
  -v "$(pwd)/data/artifacts:/app/artifacts" \
  -v "$(pwd)/data/attachments:/app/attachments" \
  -v "$(pwd)/data/profiles:/app/profiles" \
  -v "$(pwd)/data/db:/app/db" \
  --restart unless-stopped \
  "<your-dockerhub-username>/seleniumbase-api:latest"

⁠Docker Compose Guide

Create docker-compose.yml:

services:
  seleniumbase-api:
    image: "<your-dockerhub-username>/seleniumbase-api:latest"
    container_name: seleniumbase-api
    restart: unless-stopped
    ports:
      - "8000:8000"
    environment:
      JOB_TIMEOUT_SECONDS: "900"
      MAX_CONCURRENT_JOBS: "5"
    volumes:
      - ./data/jobs:/app/jobs
      - ./data/artifacts:/app/artifacts
      - ./data/attachments:/app/attachments
      - ./data/profiles:/app/profiles
      - ./data/db:/app/db

Start:

mkdir -p ./data/jobs ./data/artifacts ./data/attachments ./data/profiles ./data/db
docker compose up -d

Useful commands:

docker compose logs -f seleniumbase-api
docker compose pull
docker compose up -d
docker compose down

⁠Health Check

curl http://localhost:8000/health

Expected JSON includes status: "healthy".

⁠API Endpoints

  • GET /health
  • POST /attachments
  • GET /attachments
  • GET /attachments/{attachment_id}
  • POST /submit
  • GET /status/{job_id}
  • GET /result/{job_id}
  • GET /artifacts/{job_id}/{filename}
  • DELETE /job/{job_id}
  • GET /jobs
  • GET /profiles
  • DELETE /profile/{profile_name}

Interactive docs are also available at http://localhost:8000/docs.

⁠Runtime Environment Variables

  • BASE_DIR (default: current working directory, /app in this image)
  • DB_PATH (default: ${BASE_DIR}/db/seleniumbase_api.db)
  • JOBS_DIR (default: ${BASE_DIR}/jobs)
  • ARTIFACTS_DIR (default: ${BASE_DIR}/artifacts)
  • ATTACHMENTS_DIR (default: ${BASE_DIR}/attachments)
  • PROFILES_DIR (default: ${BASE_DIR}/profiles)
  • ATTACHMENT_TTL_SECONDS (default: 3600)
  • ATTACHMENT_MAX_SIZE_BYTES (default: 52428800)
  • JOB_TIMEOUT_SECONDS (default: 600)
  • MAX_CONCURRENT_JOBS (default: 3)

Example overrides:

docker run -d \
  --name seleniumbase-api \
  -p 8000:8000 \
  -e JOB_TIMEOUT_SECONDS=900 \
  -e MAX_CONCURRENT_JOBS=5 \
  "<your-dockerhub-username>/seleniumbase-api:latest"

⁠Quick Smoke Test

Submit a simple job:

curl -X POST "http://localhost:8000/submit" \
  -H "Content-Type: application/json" \
  -d '{"script":"from seleniumbase import SB\nwith SB(test=True, uc=True) as sb:\n    sb.open(\"https://example.com\")\n    print(sb.get_title())","params":{}}'

Then poll status:

curl "http://localhost:8000/status/<job_id>"
curl "http://localhost:8000/result/<job_id>"

⁠Source repository

https://github.com/tranngoclai/seleniumbase-api⁠

Tag summary

Content type

Image

Digest

sha256:166a9a4d3…

Size

481.7 MB

Last updated

7 months ago

docker pull tranlight/seleniumbase-api