Skip to content

Commit 93c1461

Browse files
committed
1 parent 0283eb5 commit 93c1461

File tree

2 files changed

+14
-7
lines changed

2 files changed

+14
-7
lines changed

Dockerfile

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,17 @@
11
FROM public.ecr.aws/lambda/python:3.9 as build
22
RUN yum install -y unzip && \
3-
curl -SL https://chromedriver.storage.googleapis.com/2.43/chromedriver_linux64.zip > /tmp/chromedriver.zip && \
4-
curl -SL https://github.com/adieuadieu/serverless-chrome/releases/download/v1.0.0-55/stable-headless-chromium-amazonlinux-2017-03.zip > /tmp/headless-chromium.zip && \
3+
curl -SL https://chromedriver.storage.googleapis.com/89.0.4389.23/chromedriver_linux64.zip > /tmp/chromedriver.zip && \
4+
curl -SL https://www.googleapis.com/download/storage/v1/b/chromium-browser-snapshots/o/Linux_x64%2F843831%2Fchrome-linux.zip?alt=media > /tmp/chrome-linux.zip && \
55
unzip /tmp/chromedriver.zip -d /opt/ && \
6-
unzip /tmp/headless-chromium.zip -d /opt/
6+
unzip /tmp/chrome-linux.zip -d /opt/
77

88
FROM public.ecr.aws/lambda/python:3.9
9-
RUN yum install -y https://dl.google.com/linux/direct/google-chrome-stable_current_x86_64.rpm
9+
RUN yum install atk cups-libs gtk3 libXcomposite alsa-lib \
10+
libXcursor libXdamage libXext libXi libXrandr libXScrnSaver \
11+
libXtst pango at-spi2-atk libXt xorg-x11-server-Xvfb \
12+
xorg-x11-xauth dbus-glib dbus-glib-devel -y
1013
RUN pip install selenium
11-
COPY --from=build /opt/headless-chromium /opt/
14+
COPY --from=build /opt/chrome-linux /opt/chrome
1215
COPY --from=build /opt/chromedriver /opt/
1316
COPY test.py ./
1417
CMD [ "test.handler" ]

test.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,18 @@
33

44
def handler(event=None, context=None):
55
options = webdriver.ChromeOptions()
6-
options.binary_location = "/opt/headless-chromium"
6+
options.binary_location = '/opt/chrome/chrome'
77
options.add_argument('--headless')
88
options.add_argument('--no-sandbox')
99
options.add_argument("--disable-gpu")
1010
options.add_argument("--window-size=1280x1696")
1111
options.add_argument("--single-process")
1212
options.add_argument("--disable-dev-shm-usage")
13+
options.add_argument("--disable-dev-tools")
14+
options.add_argument("--no-zygote")
15+
options.add_argument("--user-data-dir=/tmp/chrome-user-data")
16+
options.add_argument("--remote-debugging-port=9222")
1317
chrome = webdriver.Chrome("/opt/chromedriver",
1418
options=options)
15-
chrome.get("https://umihi.co/")
19+
chrome.get("https://example.com/")
1620
return chrome.find_element_by_xpath("//html").text

0 commit comments

Comments
 (0)