Skip to content

Commit 0bfbff9

Browse files
authored
Merge pull request #5 from umihico/feature/reduce-code
style: reduce code2
2 parents 6dca9ac + f4747a3 commit 0bfbff9

File tree

2 files changed

+10
-12
lines changed

2 files changed

+10
-12
lines changed

Dockerfile

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,14 @@
11
FROM public.ecr.aws/lambda/python:3.8 as build
2-
RUN mkdir -p /opt/bin/ && \
3-
mkdir -p /tmp/downloads && \
4-
yum install -y unzip && \
5-
curl -SL https://chromedriver.storage.googleapis.com/2.37/chromedriver_linux64.zip > /tmp/downloads/chromedriver.zip && \
6-
curl -SL https://github.com/adieuadieu/serverless-chrome/releases/download/v1.0.0-37/stable-headless-chromium-amazonlinux-2017-03.zip > /tmp/downloads/headless-chromium.zip && \
7-
unzip /tmp/downloads/chromedriver.zip -d /opt/bin/ && \
8-
unzip /tmp/downloads/headless-chromium.zip -d /opt/bin/
2+
RUN yum install -y unzip && \
3+
curl -SL https://chromedriver.storage.googleapis.com/2.37/chromedriver_linux64.zip > /tmp/chromedriver.zip && \
4+
curl -SL https://github.com/adieuadieu/serverless-chrome/releases/download/v1.0.0-37/stable-headless-chromium-amazonlinux-2017-03.zip > /tmp/headless-chromium.zip && \
5+
unzip /tmp/chromedriver.zip -d /opt/ && \
6+
unzip /tmp/headless-chromium.zip -d /opt/
97

108
FROM public.ecr.aws/lambda/python:3.8
11-
RUN mkdir -p /opt/bin && pip install selenium
129
RUN yum install -y https://dl.google.com/linux/direct/google-chrome-stable_current_x86_64.rpm
13-
COPY --from=build /opt/bin/headless-chromium /opt/bin/
14-
COPY --from=build /opt/bin/chromedriver /opt/bin/
10+
RUN pip install selenium
11+
COPY --from=build /opt/headless-chromium /opt/
12+
COPY --from=build /opt/chromedriver /opt/
1513
COPY test.py ./
1614
CMD [ "test.handler" ]

test.py

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

44
def handler(event=None, context=None):
55
options = webdriver.ChromeOptions()
6-
options.binary_location = "/opt/bin/headless-chromium"
6+
options.binary_location = "/opt/headless-chromium"
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-
chrome = webdriver.Chrome("/opt/bin/chromedriver",
13+
chrome = webdriver.Chrome("/opt/chromedriver",
1414
options=options)
1515
chrome.get("https://umihi.co/")
1616
return chrome.find_element_by_xpath("//html").text

0 commit comments

Comments
 (0)