mirror of
https://github.com/Hestia-Homes/Model.git
synced 2026-06-08 11:17:27 +00:00
testing changing the docker file to perform a multi-stage build to optimise image size
This commit is contained in:
parent
57a67cd9c4
commit
04beb0d510
1 changed files with 16 additions and 7 deletions
|
|
@ -1,5 +1,5 @@
|
|||
# Pull base image
|
||||
FROM python:3.10.12-slim-buster
|
||||
FROM python:3.10.12-slim-buster as build-image
|
||||
|
||||
# Set environment variables
|
||||
ENV PYTHONDONTWRITEBYTECODE 1
|
||||
|
|
@ -17,6 +17,21 @@ RUN pip install --upgrade pip
|
|||
# Install and clean up temp caches
|
||||
RUN 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
|
||||
|
|
@ -30,12 +45,6 @@ COPY ./model_data/epc_attributes/ ./model_data/epc_attributes/
|
|||
COPY ./datatypes/ ./datatypes/
|
||||
COPY ./utils/ ./utils/
|
||||
|
||||
# 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
|
||||
|
||||
# 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
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue