# Pull base image FROM python:3.10.12-slim-buster as build-image # Set environment variables ENV PYTHONDONTWRITEBYTECODE 1 ENV PYTHONUNBUFFERED 1 # Set work directory to the root of your project WORKDIR var/task/Model # Install system dependencies #RUN apt-get update && apt-get install -y netcat-openbsd # Install python dependencies COPY ./backend/requirements/base.txt ./backend/requirements/base.txt # Install and clean up temp caches RUN pip install --upgrade pip \ && pip install -r backend/requirements/base.txt && rm -rf /root/.cache # Since we are not using a base AWS image, there is some additional setup required. We need to set up the runtime # interface client # https://docs.aws.amazon.com/lambda/latest/dg/python-image.html#python-image-clients # Additionally install the AWS Lambda RIC RUN pip install awslambdaric # Second stage: "runtime-image" FROM python:3.10.12-slim-buster # Set work directory to the root of your project WORKDIR /var/task/Model # Copy the python dependencies from the build-image COPY --from=build-image /usr/local/lib/python3.10/site-packages/ /usr/local/lib/python3.10/site-packages/ # Copy project files COPY ./backend/ ./backend COPY ./recommendations/ ./recommendations COPY ./model_data/BaseUtility.py ./model_data/BaseUtility.py COPY ./model_data/config.py ./model_data/config.py COPY ./model_data/optimiser/ ./model_data/optimiser/ COPY ./model_data/__init__.py ./model_data/__init__.py COPY ./model_data/EpcClean.py ./model_data/EpcClean.py COPY ./model_data/utils.py ./model_data/utils.py COPY ./model_data/epc_attributes/ ./model_data/epc_attributes/ COPY ./model_data/simulation_system/core/DataProcessor.py ./model_data/simulation_system/core/DataProcessor.py COPY ./model_data/simulation_system/core/Settings.py ./model_data/simulation_system/core/Settings.py COPY ./datatypes/ ./datatypes/ COPY ./utils/ ./utils/ # Set the ENTRYPOINT to the AWS Lambda RIC and CMD to your function handler ENTRYPOINT [ "/usr/local/bin/python", "-m", "awslambdaric" ] # Define the handler location CMD ["backend.app.main.handler"]