survey-extraction/deployment/lambda/extractor_and_loader/docker/Dockerfile
2025-07-18 16:16:52 +00:00

44 lines
1 KiB
Docker

# ----------- Build Stage (with Poetry) -----------
FROM python:3.12-slim as builder
ENV PIP_NO_CACHE_DIR=1
# Install Poetry
RUN pip install poetry
# Set working directory
WORKDIR /app
# Copy only what's needed to resolve dependencies
COPY pyproject.toml poetry.lock ./
# Export main dependencies only
RUN poetry export -f requirements.txt --without-hashes --only main -o requirements.txt
# Install dependencies to /python (Lambda expects this path)
RUN pip install --no-deps -r requirements.txt --target /python
# ----------- Runtime Stage (Slim and Clean) -----------
FROM python:3.12-slim
ENV PYTHONDONTWRITEBYTECODE=1 \
PYTHONUNBUFFERED=1 \
PIP_NO_CACHE_DIR=1
# Install Lambda Runtime Interface Client (RIC)
RUN pip install awslambdaric
# Copy app dependencies from builder
COPY --from=builder /python /var/task
# Set working directory
WORKDIR /var/task
# Copy application code
COPY etl/ etl/
COPY deployment/lambda/extractor_and_loader/docker/app.py .
# Lambda entrypoint
ENTRYPOINT ["python3", "-m", "awslambdaric"]
CMD ["app.handler"]