I am trying to understand how to pip install packages into the lambda using lambci/lambda
While doing so, I created the below Dockerfile
FROM lambci/lambda:python3.7
ENV AWS_DEFAULT_REGION us-east-1
COPY . .
RUN pip3 install -r requirements.txt --user
# Assumes you have a .lambdaignore file with a list of files you don't want in your zip
RUN cat .lambdaignore | xargs zip -9qyr lambda.zip . -x
CMD aws lambda update-function-code --function-name mylambda --zip-file fileb://lambda.zip
But RUN pip3 install -r requirements.txt --user terminated with permission issues.
➜ amazonlinux-gdal git:(master) ✗ docker build -t mylambda .
Sending build context to Docker daemon 4.212MB
Step 1/6 : FROM lambci/lambda:python3.7
---> 2720aa44045e
Step 2/6 : ENV AWS_DEFAULT_REGION us-east-1
---> Using cache
---> 4c7d5b602e26
Step 3/6 : COPY . .
---> 2bb85fd2cc7f
Step 4/6 : RUN pip3 install -r requirements.txt --user
---> Running in b7d71772ad9f
The directory '/home/sbx_user1051/.cache/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
The directory '/home/sbx_user1051/.cache/pip' or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
Collecting flask (from -r requirements.txt (line 1))
Downloading https://files.pythonhosted.org/packages/9b/93/628509b8d5dc749656a9641f4caf13540e2cdec85276964ff8f43bbb1d3b/Flask-1.1.1-py2.py3-none-any.whl (94kB)
Collecting Jinja2>=2.10.1 (from flask->-r requirements.txt (line 1))
Downloading https://files.pythonhosted.org/packages/1d/e7/fd8b501e7a6dfe492a433deb7b9d833d39ca74916fa8bc63dd1a4947a671/Jinja2-2.10.1-py2.py3-none-any.whl (124kB)
Collecting itsdangerous>=0.24 (from flask->-r requirements.txt (line 1))
Downloading https://files.pythonhosted.org/packages/76/ae/44b03b253d6fade317f32c24d100b3b35c2239807046a4c953c7b89fa49e/itsdangerous-1.1.0-py2.py3-none-any.whl
Collecting Werkzeug>=0.15 (from flask->-r requirements.txt (line 1))
Downloading https://files.pythonhosted.org/packages/d1/ab/d3bed6b92042622d24decc7aadc8877badf18aeca1571045840ad4956d3f/Werkzeug-0.15.5-py2.py3-none-any.whl (328kB)
Collecting click>=5.1 (from flask->-r requirements.txt (line 1))
Downloading https://files.pythonhosted.org/packages/fa/37/45185cb5abbc30d7257104c434fe0b07e5a195a6847506c074527aa599ec/Click-7.0-py2.py3-none-any.whl (81kB)
Collecting MarkupSafe>=0.23 (from Jinja2>=2.10.1->flask->-r requirements.txt (line 1))
Downloading https://files.pythonhosted.org/packages/98/7b/ff284bd8c80654e471b769062a9b43cc5d03e7a615048d96f4619df8d420/MarkupSafe-1.1.1-cp37-cp37m-manylinux1_x86_64.whl
Installing collected packages: MarkupSafe, Jinja2, itsdangerous, Werkzeug, click, flask
Could not install packages due to an EnvironmentError: [Errno 13] Permission denied: '/home/sbx_user1051'
Check the permissions.
Any idea what am I missing. My goal is to be able to use some custom packages on lambda.
I am trying to understand how to pip install packages into the lambda using lambci/lambda While doing so, I created the below Dockerfile
But
RUN pip3 install -r requirements.txt --user
terminated with permission issues.Any idea what am I missing. My goal is to be able to use some custom packages on lambda.