[英]Install poppler in AWS base python image for Lambda
我正在嘗試在 AWS Lambda 上部署我的 docker 容器。 但是,我在依賴poppler
的代碼中使用pdf2image
package 。 要安裝poppler
,我需要在 Dockerfile 中插入以下行。
RUN apt-get install -y poppler-utils
這是 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" ]
但是,要在 Lambda 上部署,我需要為 Lambda 使用 AWS 基礎 python 映像。 這是我嘗試重寫上面的 dockerfile 以使用 Lambda 基礎映像。
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"]
根據上面的dockerfile可以看到apt-get命令無法運行。 可以理解,因為它不像我之前所做的那樣來自 ubuntu 圖像。 我的問題是,如何在 Lambda 基礎映像中安裝poppler
?
它使用 yum package 管理器,因此您可以執行以下操作:
FROM public.ecr.aws/lambda/python:3.6
RUN yum install -y poppler-utils
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.