I am trying to run aws lambda function with Pillow package but getting an import error. This error is like a standard error (talked here and here). What I understood from those threads is: to resolve the problem I should run the package installation in a docker container and then use that as a zip package from lambda function.
Following is my docker file:
FROM lambci/lambda:python3.6
USER root
ENV APP_DIR /var/task
WORKDIR $APP_DIR
COPY requirements.txt .
COPY bin ./bin
COPY lib ./lib
RUN mkdir -p $APP_DIR/lib
RUN pip3 install -r requirements.txt -t /var/task/lib
(i am using lambci/lambda:python3.6 to emulate python lambda environment locally and locally the lambda function runs fine).
My question is: once I run the docker-build
command, I can see the image being build but I can't seem to figure out a way to zip the packages and dependencies (in lib and bin) installed and use that zip file to upload on s3.
Following is my docker-compose
file:
version: '3'
services:
lambda:
build: .
environment:
- PYTHONPATH=/var/task/src:/var/task/lib
- PATH=/var/task/bin
volumes:
- ./src/:/var/task/src/