I have two dockerfiles that I use to build a docker image that's deployed as a AWS Lambda. and I would like to retain the files from docker image amazon/aws-lambda-python:3.9 in my final built docker image. I build the public docker image and publish it on docker hub.
When I build this docker image locally everything is as expected.
However, when I use Bitbucket pipelines to build my private dockerfile pulling from my public docker image, many of the essential files are missing in the final build step.
I need the entire /var folder from amazon/aws-lambda-python:3.9 as aws to be in my final docker image. How can I achieve this?
Public docker image:
FROM amazon/aws-lambda-python:3.9 as aws
ENV PATH=/var/lang/bin:/usr/local/bin:/usr/bin/:/bin:/opt/bin
ENV LAMBDA_RUNTIME_DIR=/var/runtime
ENV LANG=en_US.UTF-8
ENV TZ=:/etc/localtime
ENV LD_LIBRARY_PATH=/var/lang/lib:/lib64:/usr/lib64:/var/runtime:/var/runtime/lib:/var/task:/var/task/lib:/opt/lib
ENV LAMBDA_TASK_ROOT=/var/task
ENV LAMBDA_RUNTIME_DIR=/var/runtime
RUN yum update -y
RUN yum -y install tesseract poppler-utils
RUN python3 -m pip install --upgrade pip
RUN pip3 install pillow pytesseract requests boto3 python-dotenv pytz gql[all] PyMuPDF google-cloud-storage pdf2image --target "${LAMBDA_TASK_ROOT}"
WORKDIR ${LAMBDA_TASK_ROOT}
ENTRYPOINT [ "/lambda-entrypoint.sh" ]
Private docker image:
FROM private-docker-image:latest
ENV PATH=/var/lang/bin:/usr/local/bin:/usr/bin/:/bin:/opt/bin
ENV LAMBDA_RUNTIME_DIR=/var/runtime
ENV LANG=en_US.UTF-8
ENV TZ=:/etc/localtime
ENV LD_LIBRARY_PATH=/var/lang/lib:/lib64:/usr/lib64:/var/runtime:/var/runtime/lib:/var/task:/var/task/lib:/opt/lib
ENV LAMBDA_TASK_ROOT=/var/task
ENV LAMBDA_RUNTIME_DIR=/var/runtime
COPY --from=amazon/aws-lambda-python:3.9 / /
COPY . ${LAMBDA_TASK_ROOT}
WORKDIR ${LAMBDA_TASK_ROOT}
RUN chmod -R +rwx ${LAMBDA_TASK_ROOT}
RUN chmod +x /lambda-entrypoint.sh
CMD [ "app.handler" ]