File size: 2,818 Bytes
243f395 c76cb5f 243f395 c76cb5f b2b1ed7 14effdf c76cb5f 7d6e00c 243f395 c76cb5f f2a79fa fa76f5f 7c179a2 c76cb5f 7d6e00c c76cb5f 14effdf 243f395 c76cb5f 243f395 14effdf 243f395 14effdf 243f395 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 |
# Include global arg in this stage of the build
ARG ARCH="x86_64"
ARG LAMBDA_TASK_ROOT="/var/task"
ARG PYTHONPATH="${LAMBDA_TASK_ROOT}:${PYTHONPATH}:/usr/local/lib/python3/dist-packages"
ARG POETRY_NO_INTERACTION=1
ARG POETRY_VIRTUALENVS_IN_PROJECT=1
ARG POETRY_VIRTUALENVS_CREATE=1
ARG POETRY_CACHE_DIR=/tmp/poetry_cache
ARG RIE="https://github.com/aws/aws-lambda-runtime-interface-emulator/releases/latest/download/aws-lambda-rie"
FROM python:3.11-bookworm as builder
ARG ARCH
ARG LAMBDA_TASK_ROOT
ARG PYTHONPATH
ARG POETRY_NO_INTERACTION
ARG POETRY_VIRTUALENVS_IN_PROJECT
ARG POETRY_VIRTUALENVS_CREATE
ARG POETRY_CACHE_DIR
ARG RIE
RUN echo "ARCH: $ARCH ..."
RUN echo "ARG RIE: $RIE ..."
RUN echo "ARG POETRY_CACHE_DIR: ${POETRY_CACHE_DIR} ..."
RUN echo "ARG PYTHONPATH: $PYTHONPATH ..."
# Set working directory to function root directory
WORKDIR ${LAMBDA_TASK_ROOT}
COPY requirements_poetry.txt pyproject.toml poetry.lock README.md ${LAMBDA_TASK_ROOT}/
# avoid segment-geospatial exception caused by missing libGL.so.1 library
RUN apt update && apt install -y libgl1 curl python3-pip && apt clean
RUN echo "check for libGL.so ..."
RUN ls -ld /usr/lib/*-linux-gnu/libGL.so* || echo "libGL.so* not found/1..."
RUN ls -ld /usr/lib/${ARCH}-linux-gnu/libGL.so* || echo "libGL.so* not found/2..."
RUN which python
RUN python --version
# poetry installation path is NOT within ${LAMBDA_TASK_ROOT}: not needed for runtime docker image
RUN python -m pip install -r ${LAMBDA_TASK_ROOT}/requirements_poetry.txt
RUN which poetry && poetry --version && poetry config --list
RUN poetry config virtualenvs.path ${LAMBDA_TASK_ROOT}
RUN echo "# poetry config --list #" && poetry config --list
RUN poetry install --with aws_lambda --no-root
RUN curl -Lo /usr/local/bin/aws-lambda-rie ${RIE}
RUN echo "check for libGL.so"
RUN ls -ld /usr/lib/*-linux-gnu/libGL.so* || echo "libGL.so* not found..."
RUN ls -ld ${LAMBDA_TASK_ROOT}/.venv
RUN ls -l ${LAMBDA_TASK_ROOT}/.venv
FROM python:3.11-slim-bookworm as runtime
ARG ARCH
ARG LAMBDA_TASK_ROOT
ENV VIRTUAL_ENV=${LAMBDA_TASK_ROOT}/.venv \
PATH="${LAMBDA_TASK_ROOT}/.venv/bin:$PATH"
COPY --from=builder /usr/local/bin/aws-lambda-rie /usr/local/bin/aws-lambda-rie
RUN echo "COPY --from=builder /usr/lib/${ARCH}-linux-gnu/libGL.so* /usr/lib/${ARCH}-linux-gnu/"
COPY --from=builder /usr/lib/${ARCH}-linux-gnu/libGL.so* /usr/lib/${ARCH}-linux-gnu/
COPY --from=builder ${LAMBDA_TASK_ROOT}/.venv ${LAMBDA_TASK_ROOT}/.venv
RUN echo "new LAMBDA_TASK_ROOT after hidden venv copy => ${LAMBDA_TASK_ROOT}"
RUN ls -ld ${LAMBDA_TASK_ROOT}/
RUN ls -lA ${LAMBDA_TASK_ROOT}/
RUN chmod +x /usr/local/bin/aws-lambda-rie
COPY ./scripts/lambda-entrypoint.sh /lambda-entrypoint.sh
RUN chmod +x /lambda-entrypoint.sh
RUN ls -l /lambda-entrypoint.sh
ENTRYPOINT ["/lambda-entrypoint.sh"]
|