mirror of
https://github.com/Hestia-Homes/survey-extraction.git
synced 2026-06-08 11:17:29 +00:00
49 lines
1.2 KiB
Docker
49 lines
1.2 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 Poetry files and your source code
|
|
COPY pyproject.toml poetry.lock ./
|
|
COPY etl/ etl/
|
|
|
|
# Export main dependencies
|
|
RUN poetry export -f requirements.txt --without-hashes --only main -o requirements.txt
|
|
|
|
# Install into /python (Lambda expects this structure)
|
|
RUN pip install --no-deps -r requirements.txt --target /python
|
|
|
|
# Optionally: strip cache, pyc, and tests to reduce size
|
|
RUN find /python -type d -name "tests" -exec rm -rf {} + \
|
|
&& find /python -type f -name "*.pyc" -delete
|
|
|
|
|
|
# ----------- Runtime Stage (Slim and Clean) -----------
|
|
FROM python:3.12-slim
|
|
|
|
ENV PYTHONDONTWRITEBYTECODE=1 \
|
|
PYTHONUNBUFFERED=1 \
|
|
PIP_NO_CACHE_DIR=1
|
|
|
|
# Install Lambda RIC
|
|
RUN pip install awslambdaric
|
|
|
|
# Copy installed dependencies and app code from builder
|
|
COPY --from=builder /python /var/task
|
|
COPY --from=builder /app/etl /var/task/etl
|
|
|
|
# Set working directory
|
|
WORKDIR /var/task
|
|
|
|
# Copy Lambda handler
|
|
COPY deployment/lambda/extractor_and_loader/docker/app.py .
|
|
|
|
# Set Lambda entrypoint and handler
|
|
ENTRYPOINT ["python3", "-m", "awslambdaric"]
|
|
CMD ["app.handler"]
|