简体   繁体   English

在 Lambda 的 AWS 基础 python 映像中安装 poppler

[英]Install poppler in AWS base python image for Lambda

I am trying to deploy my docker container on AWS Lambda.我正在尝试在 AWS Lambda 上部署我的 docker 容器。 However, I use pdf2image package in my code which depends on poppler .但是,我在依赖poppler的代码中使用pdf2image package 。 To install poppler , I need to insert the following line in the Dockerfile.要安装poppler ,我需要在 Dockerfile 中插入以下行。

RUN apt-get install -y poppler-utils

This is the full view of the dockerfile.这是 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.但是,要在 Lambda 上部署,我需要为 Lambda 使用 AWS 基础 python 映像。 This is my attempt to rewrite the above dockerfile to use the Lambda base image.这是我尝试重写上面的 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"]

Based on the dockerfile above, you can see that the apt-get command cannot be run.根据上面的dockerfile可以看到apt-get命令无法运行。 Understandable because it is not from ubuntu image like I did earlier.可以理解,因为它不像我之前所做的那样来自 ubuntu 图像。 My question is, how can I install the poppler in the Lambda base image?我的问题是,如何在 Lambda 基础映像中安装poppler

It uses the yum package manager, so you can do the following instead:它使用 yum package 管理器,因此您可以执行以下操作:

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

RUN yum install -y poppler-utils

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM