diff --git a/docker-modules/Headless-Google-Chrome/Dockerfile b/docker-modules/Headless-Google-Chrome/Dockerfile new file mode 100644 index 0000000..3cb280b --- /dev/null +++ b/docker-modules/Headless-Google-Chrome/Dockerfile @@ -0,0 +1,43 @@ +# Dockerfile +FROM debian:bullseye + +# Install system dependencies, including ca-certificates +RUN apt-get update && apt-get install -y \ + wget \ + curl \ + gnupg \ + ca-certificates \ + unzip \ + fonts-liberation \ + libappindicator3-1 \ + libasound2 \ + libatk-bridge2.0-0 \ + libatk1.0-0 \ + libcups2 \ + libdbus-1-3 \ + libgdk-pixbuf2.0-0 \ + libnspr4 \ + libnss3 \ + libx11-xcb1 \ + libxcomposite1 \ + libxdamage1 \ + libxrandr2 \ + xdg-utils \ + --no-install-recommends && \ + rm -rf /var/lib/apt/lists/* + +# Install Google Chrome +RUN apt-get update && \ + curl -fsSL https://dl.google.com/linux/linux_signing_key.pub | gpg --dearmor -o /usr/share/keyrings/google-linux-keyring.gpg && \ + echo "deb [arch=amd64 signed-by=/usr/share/keyrings/google-linux-keyring.gpg] http://dl.google.com/linux/chrome/deb/ stable main" > /etc/apt/sources.list.d/google-chrome.list && \ + apt-get update && apt-get install -y google-chrome-stable && \ + rm -rf /var/lib/apt/lists/* + +# Create non-root user +RUN useradd -m chromeuser + +# Switch to non-root user +USER chromeuser + +# Set Chrome as entrypoint with headless configuration +ENTRYPOINT ["google-chrome", "--headless", "--no-sandbox", "--disable-gpu", "--remote-debugging-port=9222", "--disable-dev-shm-usage"] diff --git a/docker-modules/Headless-Google-Chrome/Github-action-workflow.yml b/docker-modules/Headless-Google-Chrome/Github-action-workflow.yml new file mode 100644 index 0000000..5fc79e5 --- /dev/null +++ b/docker-modules/Headless-Google-Chrome/Github-action-workflow.yml @@ -0,0 +1,36 @@ +# .github/workflows/chrome-test.yml +name: Run Chrome Headless Test + +on: [push] + +jobs: + headless-test: + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: Set up Docker + run: sudo apt-get update && sudo apt-get install -y docker.io + + - name: Build Chrome Docker image + run: docker build -t headless-chrome . + + - name: Run screenshot test + run: | + mkdir screenshots + docker run --rm \ + -v ${{ github.workspace }}/screenshots:/screenshots \ + headless-chrome \ + --headless \ + --disable-gpu \ + --no-sandbox \ + --screenshot=/screenshots/test.png \ + https://google.com + + - name: Upload screenshot artifact + uses: actions/upload-artifact@v3 + with: + name: screenshot + path: screenshots/test.png