# PaddleOCR 3.7 on AWS Lambda, arm64 (Graviton), CPU only (brasspage.com/paddleocr-lambda/, Nov 26, 2026)
FROM public.ecr.aws/lambda/python:3.13
ENV PIP_NO_CACHE_DIR=1 PADDLE_PDX_DISABLE_MODEL_SOURCE_CHECK=True PADDLE_PDX_CACHE_HOME=/opt/paddlex
# PyPI has no Linux arm64 wheel of paddlepaddle 3.3.1. Paddle's own index has one.
RUN pip install paddlepaddle==3.3.1 -i https://www.paddlepaddle.org.cn/packages/stable/cpu/ \
 && pip install paddleocr==3.7.0
# PaddleX needs the full OpenCV wheel, and that needs libGL.so.1. The Lambda image has none.
RUN dnf install -y mesa-libGL && dnf clean all
COPY app.py ${LAMBDA_TASK_ROOT}/
# The models go into the image now, so a cold start downloads nothing.
RUN python -c "import app"
CMD ["app.handler"]
