Error running python:3.8-alpine3.14 in docker AWS lambda

0

For My below code I am trying to run alipne version due to higher execution time mynormal python version. I got error: "START RequestId: 191b606b-ee6b-4dfe-8b02-7fccf7689718 Version: $LATEST RequestId: 191b606b-ee6b-4dfe-8b02-7fccf7689718 Error: exec: "generate_worldcloud.generate_wordcloud_handler": executable file not found in $PATH Runtime.InvalidEntrypoint END RequestId: 191b606b-ee6b-4dfe-8b02-7fccf7689718 REPORT RequestId: 191b606b-ee6b-4dfe-8b02-7fccf7689718 Duration: 0.86 ms Billed Duration: 1 ms Memory Size: 512 MB Max Memory Used: 2 MB " My docker file contains :

python3.8 lambda base image

FROM python:3.8-alpine3.14

# python3.8 lambda base image

FROM public.ecr.aws/lambda/python:3.9-x86_64

installing dependencies

COPY py3-nltk-3.8.1-r0.apk /tmp/ COPY py3-wordcloud-1.8.2.2-r1.apk /tmp/ COPY py3-pypdf2-2.10.9-r0.apk /tmp/

RUN apk add --no-cache /tmp/py3-pypdf2-2.10.9-r0.apk RUN apk add --no-cache /tmp/py3-nltk-3.8.1-r0.apk RUN apk add --no-cache /tmp/py3-wordcloud-1.8.2.2-r1.apk

create a directory for the NLTK data

RUN mkdir /tmp/nltk_data

copy the NLTK data to the container

COPY nltk_data /tmp/nltk_data

set the NLTK_DATA environment variable

ENV NLTK_DATA=/tmp/nltk_data

Copy all .py files to container

COPY *.py ./ COPY generate_worldcloud.py ./

setting the CMD to your handler file_name.function_name

CMD ["generate_worldcloud.generate_wordcloud_handler" ]

i tried installing using requirements file but it doesn't work so i downloaded APK copied and installed still my lambda function doesn't work. I don't understand why!

1 Answer
0

The problem comes from the fact that the image you are using does not contain the necessary code that Lambda runtime expects in the image.

Please follow these instruction to build a container Lambda from alternative images than the one provided by AWS.

https://docs.aws.amazon.com/lambda/latest/dg/images-create.html#images-create-from-alt

AWS
EXPERT
answered a year ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions