Skip to content

Commit 61abe94

Browse files
Merge pull request #46 from Sourov72/azure_module
Add Dockerfile for Headless Chrome
2 parents c506814 + 243d764 commit 61abe94

File tree

2 files changed

+79
-0
lines changed

2 files changed

+79
-0
lines changed
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# Dockerfile
2+
FROM debian:bullseye
3+
4+
# Install system dependencies, including ca-certificates
5+
RUN apt-get update && apt-get install -y \
6+
wget \
7+
curl \
8+
gnupg \
9+
ca-certificates \
10+
unzip \
11+
fonts-liberation \
12+
libappindicator3-1 \
13+
libasound2 \
14+
libatk-bridge2.0-0 \
15+
libatk1.0-0 \
16+
libcups2 \
17+
libdbus-1-3 \
18+
libgdk-pixbuf2.0-0 \
19+
libnspr4 \
20+
libnss3 \
21+
libx11-xcb1 \
22+
libxcomposite1 \
23+
libxdamage1 \
24+
libxrandr2 \
25+
xdg-utils \
26+
--no-install-recommends && \
27+
rm -rf /var/lib/apt/lists/*
28+
29+
# Install Google Chrome
30+
RUN apt-get update && \
31+
curl -fsSL https://dl.google.com/linux/linux_signing_key.pub | gpg --dearmor -o /usr/share/keyrings/google-linux-keyring.gpg && \
32+
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 && \
33+
apt-get update && apt-get install -y google-chrome-stable && \
34+
rm -rf /var/lib/apt/lists/*
35+
36+
# Create non-root user
37+
RUN useradd -m chromeuser
38+
39+
# Switch to non-root user
40+
USER chromeuser
41+
42+
# Set Chrome as entrypoint with headless configuration
43+
ENTRYPOINT ["google-chrome", "--headless", "--no-sandbox", "--disable-gpu", "--remote-debugging-port=9222", "--disable-dev-shm-usage"]
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# .github/workflows/chrome-test.yml
2+
name: Run Chrome Headless Test
3+
4+
on: [push]
5+
6+
jobs:
7+
headless-test:
8+
runs-on: ubuntu-latest
9+
10+
steps:
11+
- name: Checkout code
12+
uses: actions/checkout@v3
13+
14+
- name: Set up Docker
15+
run: sudo apt-get update && sudo apt-get install -y docker.io
16+
17+
- name: Build Chrome Docker image
18+
run: docker build -t headless-chrome .
19+
20+
- name: Run screenshot test
21+
run: |
22+
mkdir screenshots
23+
docker run --rm \
24+
-v ${{ github.workspace }}/screenshots:/screenshots \
25+
headless-chrome \
26+
--headless \
27+
--disable-gpu \
28+
--no-sandbox \
29+
--screenshot=/screenshots/test.png \
30+
https://google.com
31+
32+
- name: Upload screenshot artifact
33+
uses: actions/upload-artifact@v3
34+
with:
35+
name: screenshot
36+
path: screenshots/test.png

0 commit comments

Comments
 (0)