Учитывая, что мой Dockerfile выглядит так:
Код: Выделить всё
# Stage 1: Build stage
FROM python:3.10-slim-bullseye as builder
ENV DEBIAN_FRONTEND=noninteractive
# Set up environment variables
ENV LC_ALL=C.UTF-8
ENV LANG=en_US.UTF-8
ENV TZ=:/etc/localtime
ENV PATH=/var/lang/bin:/usr/local/bin:/usr/bin/:/bin:/opt/bin
ENV LD_LIBRARY_PATH=/var/lang/lib:/lib64:/usr/lib64:/var/runtime:/var/runtime/lib:/var/task:/var/task/lib:/opt/lib
# Install build dependencies and R in build stage
RUN apt-get update && \
apt-get install -y \
g++ \
make \
cmake \
unzip \
libcurl4-openssl-dev \
r-base-core \
&& apt-get clean
# Set up working directory
ARG FUNCTION_DIR="/var/task"
WORKDIR ${FUNCTION_DIR}
# Copy requirements for Python and R scripts
COPY requirements.txt .
COPY script_calcproper.R .
COPY main.py .
COPY data/. data/.
# Install Python dependencies
RUN pip install --no-cache-dir -r requirements.txt
# Stage 2: Final stage
FROM python:3.10-slim-bullseye
ENV DEBIAN_FRONTEND=noninteractive
# Set up environment variables
ENV LC_ALL=C.UTF-8
ENV LANG=en_US.UTF-8
ENV TZ=:/etc/localtime
ENV PATH=/var/lang/bin:/usr/local/bin:/usr/bin/:/bin:/opt/bin
ENV LD_LIBRARY_PATH=/var/lang/lib:/lib64:/usr/lib64:/var/runtime:/var/runtime/lib:/var/task:/var/task/lib:/opt/lib
# Install R runtime dependencies in final stage
RUN apt-get update && \
apt-get install -y --no-install-recommends \
r-base-core \
libcurl4-openssl-dev \
&& apt-get clean && rm -rf /var/lib/apt/lists/*
# Define custom function directory
ARG FUNCTION_DIR="/var/task"
WORKDIR ${FUNCTION_DIR}
# Copy only the necessary files from the build stage
COPY --from=builder /usr/local/lib/python3.10/site-packages /usr/local/lib/python3.10/site-packages
COPY --from=builder /usr/local/bin /usr/local/bin
COPY --from=builder ${FUNCTION_DIR} ${FUNCTION_DIR}
# Set the CMD to your handler
ENTRYPOINT [ "/usr/local/bin/python", "-m", "awslambdaric" ]
CMD [ "main.handler"]
Подробнее здесь: https://stackoverflow.com/questions/790 ... start-time