File tree Expand file tree Collapse file tree 2 files changed +10
-12
lines changed Expand file tree Collapse file tree 2 files changed +10
-12
lines changed Original file line number Diff line number Diff line change 1
1
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/
9
7
10
8
FROM public.ecr.aws/lambda/python:3.8
11
- RUN mkdir -p /opt/bin && pip install selenium
12
9
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/
15
13
COPY test.py ./
16
14
CMD [ "test.handler" ]
Original file line number Diff line number Diff line change 3
3
4
4
def handler (event = None , context = None ):
5
5
options = webdriver .ChromeOptions ()
6
- options .binary_location = "/opt/bin/ headless-chromium"
6
+ options .binary_location = "/opt/headless-chromium"
7
7
options .add_argument ('--headless' )
8
8
options .add_argument ('--no-sandbox' )
9
9
options .add_argument ("--disable-gpu" )
10
10
options .add_argument ("--window-size=1280x1696" )
11
11
options .add_argument ("--single-process" )
12
12
options .add_argument ("--disable-dev-shm-usage" )
13
- chrome = webdriver .Chrome ("/opt/bin/ chromedriver" ,
13
+ chrome = webdriver .Chrome ("/opt/chromedriver" ,
14
14
options = options )
15
15
chrome .get ("https://umihi.co/" )
16
16
return chrome .find_element_by_xpath ("//html" ).text
You can’t perform that action at this time.
0 commit comments