Reputation: 161
Pyppeteer (python port of puppeteer) is trying to download linux-chrome but fails to download.
This is a python project, that I have dockerized and used serverless to deploy into an AWS Lambda. I'm using serverless to deploy the python dependencies into a lambda layer.
I can't find anything definitive on google that shows me how to setup a proper lambda for chrome browser automation using a python a runtime.
serverless
provider:
name: aws
runtime: python3.7
functions:
main:
handler: main.handler
package:
include:
- src/main.py
layers:
- {Ref: PythonRequirementsLambdaLayer}
environment:
REGION_NAME: us-west-2
custom:
pythonRequirements:
dockerizePip: true
zip: true
dockerImage: mydocker:latest
layer: true
plugins:
- serverless-python-requirements
pyppeteer
self.browser = await pyppeteer.launch({
'headless': True,
'args': [
'--no-sandbox',
'--disabled-setuid-sandbox',
'--disable-dev-profile',
'--user-data-dir=/tmp'
]
})
dockerfile
FROM python:3.7-slim
RUN apt-get -y update
RUN apt-get -y install curl
RUN apt-get install -y git
RUN apt-get install -y gconf-service libasound2 libatk1.0-0 libc6 libcairo2 libcups2 libdbus-1-3 libexpat1 libfontconfig1 libgcc1 libgconf-2-4 libgdk-pixbuf2.0-0 libglib2.0-0 libgtk-3-0 libnspr4 libpango-1.0-0 libpangocairo-1.0-0 libstdc++6 libx11-6 libx11-xcb1 libxcb1 libxcomposite1 libxcursor1 libxdamage1 libxext6 libxfixes3 libxi6 libxrandr2 libxrender1 libxss1 libxtst6 ca-certificates fonts-liberation libappindicator1 libnss3 lsb-release xdg-utils wget
ENV REGION_NAME='us-west-2'
ENV XDG_CACHE_HOME='/tmp/.cache'
ENV PYPPETEER_HOME='tmp/'
COPY . src/
WORKDIR src
RUN pip3 install -r requirements.txt
RUN python3 -c 'import pyppeteer; pyppeteer.chromium_downloader.download_chromium()'
error message
{
"statusCode": 400,
"message": "[Errno 30] Read-only file system: '/home/sbx_user1051'",
"trace": [
"Traceback (most recent call last):\n",
" File \"/var/task/main.py\", line 18, in handler\n result = loop.run_until_complete(main())\n",
" File \"/var/lang/lib/python3.7/asyncio/base_events.py\", line 584, in run_until_complete\n return future.result()\n",
" File \"/var/task/main.py\", line 68, in main\n ring_results = await pyp_client.get_ring_results()\n",
" File \"/var/task/clients/pyppeteer_client.py\", line 40, in get_ring_results\n await self.ready_the_browser()\n",
" File \"/var/task/clients/pyppeteer_client.py\", line 18, in ready_the_browser\n await self.__create_browser_instance()\n",
" File \"/var/task/clients/pyppeteer_client.py\", line 32, in __create_browser_instance\n '--user-data-dir=/tmp'\n",
" File \"/tmp/sls-py-req/pyppeteer/launcher.py\", line 311, in launch\n return await Launcher(options, **kwargs).launch()\n",
" File \"/tmp/sls-py-req/pyppeteer/launcher.py\", line 125, in __init__\n download_chromium()\n",
" File \"/tmp/sls-py-req/pyppeteer/chromium_downloader.py\", line 136, in download_chromium\n extract_zip(download_zip(get_url()), DOWNLOADS_FOLDER / REVISION)\n",
" File \"/tmp/sls-py-req/pyppeteer/chromium_downloader.py\", line 125, in extract_zip\n zf.extractall(str(path))\n",
" File \"/var/lang/lib/python3.7/zipfile.py\", line 1616, in extractall\n self._extract_member(zipinfo, path, pwd)\n",
" File \"/var/lang/lib/python3.7/zipfile.py\", line 1662, in _extract_member\n os.makedirs(upperdirs)\n",
" File \"/var/lang/lib/python3.7/os.py\", line 211, in makedirs\n makedirs(head, exist_ok=exist_ok)\n",
" File \"/var/lang/lib/python3.7/os.py\", line 211, in makedirs\n makedirs(head, exist_ok=exist_ok)\n",
" File \"/var/lang/lib/python3.7/os.py\", line 211, in makedirs\n makedirs(head, exist_ok=exist_ok)\n",
" [Previous line repeated 2 more times]\n",
" File \"/var/lang/lib/python3.7/os.py\", line 221, in makedirs\n mkdir(name, mode)\n",
"OSError: [Errno 30] Read-only file system: '/home/sbx_user1051'\n"
]
}
Upvotes: 1
Views: 4649
Reputation: 18578
I suggest you to change ENV PYPPETEER_HOME='tmp/'
to
ENV PYPPETEER_HOME='/tmp/'
it seems PYPPETEER
try to mkdir
in /home/sbx_user1051/tmp
which has no write
permissions in
Upvotes: 2