diff --git a/deployment/lambda/extractor_and_loader/docker/Dockerfile b/deployment/lambda/extractor_and_loader/docker/Dockerfile index a314824..cdd1f8a 100644 --- a/deployment/lambda/extractor_and_loader/docker/Dockerfile +++ b/deployment/lambda/extractor_and_loader/docker/Dockerfile @@ -1,41 +1,25 @@ -# ---------- Stage 1: Build (Poetry) ---------- -FROM public.ecr.aws/lambda/python:3.12 as builder +FROM public.ecr.aws/lambda/python:3.12 -ENV PATH="/root/.local/bin:$PATH" \ - PIP_NO_CACHE_DIR=1 \ - PYTHONUNBUFFERED=1 \ - PYTHONDONTWRITEBYTECODE=1 - -# Install Poetry +# Install Poetry (you could pin a version if you like) RUN curl -sSL https://install.python-poetry.org | python3 - -WORKDIR /app - -# Copy poetry config and install deps -COPY pyproject.toml poetry.lock ./ -RUN poetry config virtualenvs.create false \ - && poetry install --only main --no-interaction --no-ansi \ - && rm -rf ~/.cache - -# Copy source code -COPY etl/ etl/ -COPY deployment/lambda/extractor_and_loader/docker/app.py . - -# ---------- Stage 2: Runtime (Slim + RIC) ---------- -FROM python:3.12-slim - -ENV PYTHONDONTWRITEBYTECODE=1 \ - PYTHONUNBUFFERED=1 \ - PIP_NO_CACHE_DIR=1 - -# Install AWS Lambda Runtime Interface Client -RUN pip install awslambdaric +# Add Poetry to PATH +ENV PATH="/root/.local/bin:$PATH" +# Set working directory WORKDIR /var/task -# Copy minimal runtime files from builder -COPY --from=builder /app /var/task +# Copy Poetry files first to leverage Docker layer caching +COPY pyproject.toml poetry.lock README.md ./ +COPY etl/ etl/ -# Lambda entrypoint -ENTRYPOINT ["python3", "-m", "awslambdaric"] -CMD ["app.handler"] + +# Install dependencies into /var/task +RUN poetry config virtualenvs.create false \ + && poetry install --only main --no-interaction --no-ansi + +# Copy app code +COPY deployment/lambda/extractor_and_loader/docker/app.py ./ + +# Set Lambda handler +CMD ["app.handler"] \ No newline at end of file