Reputation: 424
I have been working on creating a custom image to use with my Lambda. I have a working Docker image that runs as expected on Fargate. To make the same image run on Lambda I install "awslambdaric"
FROM python:3.8-slim
ARG FUNCTION_DIR
USER root
RUN apt-get -y update && apt-get install -y --no-install-recommends \
libgl1-mesa-glx \
libglib2.0-0 \
wget \
git \
python3 \
python3-pip \
python3-setuptools \
ca-certificates \
gcc \
libc6-dev \
g++ \
make \
cmake \
unzip \
libcurl4-openssl-dev \
&& rm -rf /var/lib/apt/lists/*
RUN mkdir -p ${FUNCTION_DIR}
COPY . ${FUNCTION_DIR}/a/b
COPY requirements.txt ${FUNCTION_DIR}/a/
COPY VERSION.txt ${FUNCTION_DIR}/a/
COPY setup.py ${FUNCTION_DIR}/a/
RUN python -m pip install awslambdaric --target ${FUNCTION_DIR}/a/
WORKDIR "${FUNCTION_DIR}/a/"
ENTRYPOINT ["/usr/local/bin/python", "-m", "awslambdaric"]
CMD ["a/driver/v1/lambda_function.lambda_handler"]
My handler sits a/driver/v1/lambda_function.py I have some functions in a file caller runner.py which is at the same level as lambda_function.py
When I run the lambda, I get following error:
[ERROR] Runtime.ImportModuleError: Unable to import module 'a/driver/v1/lambda_function': No module named 'runner'
I have tried checking sys.path for my python and it indeed has "a" directory in it.
This is frustrating because the same image, minus the handler code and awslambdaric, works as expected on Fargate where all modules are found and image has the exact same directory structure.
Upvotes: 1
Views: 140