mirror of
https://github.com/Hestia-Homes/Model.git
synced 2026-07-12 13:29:04 +00:00
main.py imports repositories.historic_epc.* after the re-plug; without the COPY the lambda fails at init with Runtime.ImportModuleError (caught by test_lambda_image_copies_full_import_closure). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
53 lines
1.6 KiB
Docker
53 lines
1.6 KiB
Docker
# 3.11 required: domain.modelling.measure_type uses enum.StrEnum (added in 3.11).
|
|
FROM public.ecr.aws/lambda/python:3.11
|
|
# FROM python:3.11.10-bullseye
|
|
|
|
|
|
ARG DEV_DB_HOST
|
|
ARG DEV_DB_PORT
|
|
ARG DEV_DB_NAME
|
|
ARG EPC_AUTH_TOKEN
|
|
ARG OPEN_EPC_API_TOKEN
|
|
|
|
ENV DB_HOST=${DEV_DB_HOST}
|
|
ENV DB_PORT=${DEV_DB_PORT}
|
|
ENV DB_NAME=${DEV_DB_NAME}
|
|
ENV EPC_AUTH_TOKEN=${EPC_AUTH_TOKEN}
|
|
ENV OPEN_EPC_API_TOKEN=${OPEN_EPC_API_TOKEN}
|
|
|
|
|
|
# Set working directory (Lambda task root)
|
|
WORKDIR /var/task
|
|
|
|
# -----------------------------
|
|
# Copy requirements FIRST (for Docker layer caching)
|
|
# -----------------------------
|
|
COPY backend/address2UPRN/handler/requirements.txt .
|
|
|
|
|
|
# Install dependencies into Lambda runtime
|
|
RUN pip install --no-cache-dir -r requirements.txt
|
|
|
|
|
|
# Copy necessary files for database and utility imports
|
|
COPY utils/ utils/
|
|
COPY backend/ backend/
|
|
COPY datatypes/ datatypes/
|
|
# main.py imports infrastructure.epc_client.epc_client_service (EpcClientService);
|
|
# without this the lambda fails at init with "No module named 'infrastructure'".
|
|
COPY infrastructure/ infrastructure/
|
|
# EpcClientService -> datatypes.epc.domain.mapper -> domain.sap10_calculator;
|
|
# without this the lambda fails at init with "No module named 'domain'".
|
|
COPY domain/ domain/
|
|
# main.py resolves historic-EPC UPRNs via repositories.historic_epc.* (the
|
|
# HistoricEpcResolver + S3 repository); without this the lambda fails at init
|
|
# with "No module named 'repositories'".
|
|
COPY repositories/ repositories/
|
|
|
|
# Copy the handler
|
|
COPY backend/address2UPRN/main.py .
|
|
|
|
# -----------------------------
|
|
# Lambda handler
|
|
# -----------------------------
|
|
CMD ["main.handler"]
|