Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Missing find command in lambda/python:3.12 image #196

Open
tlinhart opened this issue Sep 20, 2024 · 2 comments
Open

Missing find command in lambda/python:3.12 image #196

tlinhart opened this issue Sep 20, 2024 · 2 comments

Comments

@tlinhart
Copy link

I'm trying to decrease my Docker image size by cleaning the cache files after installing the requirements but the build fails due to a missing find command. This is my Dockerfile:

FROM public.ecr.aws/lambda/python:3.12

COPY requirements.txt /tmp
RUN pip install -t ${LAMBDA_TASK_ROOT} -r /tmp/requirements.txt \
 && find ${LAMBDA_TASK_ROOT} -regex '^.*\(__pycache__\|\.py[co]\)$' -delete

COPY lambda_function.py ${LAMBDA_TASK_ROOT}

CMD ["lambda_function.lambda_handler"]

Looking inside the running container, it seems that other usual files are present in /usr/bin.

@leandrodamascena
Copy link

Hi @tlinhart! Good to see you here dude! I ran into this same issue like 1 hour ago and was trying to understand what's going on. Up until Python 3.11 Runtime, Lambda images are using Amazon Linux 2 which comes with the findutils package by default, but starting from Python 3.12 it is using Amazon Linux 2023 and it seems that the findutils package is not installed by default.

Python 3.11

➜ docker run --rm -it --entrypoint bash public.ecr.aws/lambda/python:3.11
WARNING: The requested image's platform (linux/amd64) does not match the detected host platform (linux/arm64/v8) and no specific platform was requested
bash-4.2# rpm -qa | grep find
findutils-4.5.11-6.amzn2.x86_64
bash-4.2# 

Python 3.12

➜ docker run --rm -it --entrypoint bash public.ecr.aws/lambda/python:3.12
bash-5.2# rpm -qa |grep find
bash-5.2# 

To solve this problem you can install findutils package in your image, add this line RUN dnf install -y findutils before the pip install line and you'll be able to use the find command.

@tlinhart
Copy link
Author

Hey @leandrodamascena! I was a bit surprised that find was not present to be honest :-) Anyway, thanks for your suggestion, will give it a try.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants