Install poppler in AWS base python image for Lambda

3.6k views Asked by At

I am trying to deploy my docker container on AWS Lambda. However, I use pdf2image package in my code which depends on poppler. To install poppler, I need to insert the following line in the Dockerfile.

RUN apt-get install -y poppler-utils

This is the full view of the dockerfile.

FROM ubuntu:18.04

RUN apt-get update
RUN apt-get install -y poppler-utils

RUN apt-get install python3 -y
RUN apt-get install python3-pip -y
RUN pip3 install --upgrade pip

WORKDIR /

COPY app.py .
COPY requirements.txt  .

RUN  pip3 install -r requirements.txt

ENTRYPOINT [ "python3", "app.py" ]

However, to deploy on Lambda, I need to use AWS base python image for Lambda. This is my attempt to rewrite the above dockerfile to use the Lambda base image.

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

# Cannot run the follow lines: apt-get: command not found

# RUN apt-get update
# RUN apt-get install -y poppler-utils

COPY app.py .
COPY requirements.txt  .

RUN pip install -r requirements.txt

CMD ["app.handler"]

Based on the dockerfile above, you can see that the apt-get command cannot be run. Understandable because it is not from ubuntu image like I did earlier. My question is, how can I install the poppler in the Lambda base image?

1

There are 1 answers

0
chehsunliu On BEST ANSWER

It uses the yum package manager, so you can do the following instead:

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

RUN yum install -y poppler-utils