I am writing an AWS Lambda function using Node.js which is deployed via a container image.
I have used the base Node.js Dockerfile image for Lambda provided at the link below to configure my image. This works well. My image is deployed and my Lambda function is running.
https://docs.aws.amazon.com/lambda/latest/dg/images-create.html#images-create-from-base
Here is the Dockerfile:
FROM public.ecr.aws/lambda/nodejs:14
COPY index.js package.json cad/ ${LAMBDA_TASK_ROOT}
# Here I would like to install libgl1-mesa-dev, libx11-dev and libglu1-mesa-de
RUN npm install
CMD ["index.handler"]
However, I now need to install additional dependencies on the image. Specifically I need OpenGL to use PDFTron to convert CAD files to PDF, according to the PDFTron documentation here. So I require libgl1-mesa-dev
, libx11-dev
and libglu1-mesa-de
.
The information on the AWS documentation above states:
Install any dependencies under the ${LAMBDA_TASK_ROOT} directory alongside the function handler to ensure that the Lambda runtime can locate them when the function is invoked.
If this was an ubuntu or alpine image I could install using apt-get
or apk add
. But neither is available on this base AWS Lambda Node image since this isn't an ubuntu or alpine image.
So my question is, how do I install libgl1-mesa-dev
, libx11-dev
and libglu1-mesa-de
on this image so that the Lambda runtime can locate them when the function is invoked?
CodePudding user response:
I think the equivalent for ubuntu, on Amazon Linux 2 (lambda is using it) would be:
FROM public.ecr.aws/lambda/nodejs:14
COPY index.js package.json cad/ ${LAMBDA_TASK_ROOT}
RUN yum install -y libgl1-mesa-devel libx11-devel mesa-libGL-devel
RUN npm install
CMD ["index.handler"]