mirror of
https://github.com/Hestia-Homes/survey-extraction.git
synced 2026-06-30 13:10:56 +00:00
does this build
This commit is contained in:
parent
39a1eb29d5
commit
72b5b60b20
1 changed files with 19 additions and 27 deletions
|
|
@ -1,49 +1,41 @@
|
|||
# ----------- Build Stage (with Poetry) -----------
|
||||
FROM python:3.12-slim as builder
|
||||
# ---------- Stage 1: Build (Poetry) ----------
|
||||
FROM public.ecr.aws/lambda/python:3.12 as builder
|
||||
|
||||
ENV PIP_NO_CACHE_DIR=1
|
||||
ENV PATH="/root/.local/bin:$PATH" \
|
||||
PIP_NO_CACHE_DIR=1 \
|
||||
PYTHONUNBUFFERED=1 \
|
||||
PYTHONDONTWRITEBYTECODE=1
|
||||
|
||||
# Install Poetry
|
||||
RUN pip install poetry
|
||||
RUN curl -sSL https://install.python-poetry.org | python3 -
|
||||
|
||||
# Set working directory
|
||||
WORKDIR /app
|
||||
|
||||
# Copy Poetry files and your source code
|
||||
# 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 .
|
||||
|
||||
# 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) -----------
|
||||
# ---------- Stage 2: Runtime (Slim + RIC) ----------
|
||||
FROM python:3.12-slim
|
||||
|
||||
ENV PYTHONDONTWRITEBYTECODE=1 \
|
||||
PYTHONUNBUFFERED=1 \
|
||||
PIP_NO_CACHE_DIR=1
|
||||
|
||||
# Install Lambda RIC
|
||||
# Install AWS Lambda Runtime Interface Client
|
||||
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 .
|
||||
# Copy minimal runtime files from builder
|
||||
COPY --from=builder /app /var/task
|
||||
|
||||
# Set Lambda entrypoint and handler
|
||||
# Lambda entrypoint
|
||||
ENTRYPOINT ["python3", "-m", "awslambdaric"]
|
||||
CMD ["app.handler"]
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue