mirror of
https://github.com/Hestia-Homes/survey-extraction.git
synced 2026-06-08 11:17:29 +00:00
smaller image
This commit is contained in:
parent
b6e201c7d1
commit
dcf589f175
1 changed files with 22 additions and 17 deletions
|
|
@ -1,25 +1,30 @@
|
|||
FROM public.ecr.aws/lambda/python:3.12
|
||||
# ---------- Builder Stage (uses Poetry) ----------
|
||||
FROM python:3.12-slim as builder
|
||||
|
||||
# Install Poetry (you could pin a version if you like)
|
||||
RUN curl -sSL https://install.python-poetry.org | python3 -
|
||||
|
||||
# Add Poetry to PATH
|
||||
ENV PATH="/root/.local/bin:$PATH"
|
||||
# Install Poetry
|
||||
RUN pip install --no-cache-dir poetry
|
||||
|
||||
# Set working directory
|
||||
WORKDIR /var/task
|
||||
WORKDIR /app
|
||||
|
||||
# Copy Poetry files first to leverage Docker layer caching
|
||||
COPY pyproject.toml poetry.lock README.md ./
|
||||
COPY etl/ etl/
|
||||
# Copy only what's needed for dependency resolution
|
||||
COPY pyproject.toml poetry.lock ./
|
||||
|
||||
# Export dependencies (no dev) to requirements.txt
|
||||
RUN poetry export -f requirements.txt --without-hashes --only main -o requirements.txt
|
||||
|
||||
# Install dependencies into /var/task
|
||||
RUN poetry config virtualenvs.create false \
|
||||
&& poetry install --only main --no-interaction --no-ansi
|
||||
# Install into a clean target folder
|
||||
RUN pip install --no-cache-dir -r requirements.txt --target /python
|
||||
|
||||
# Copy app code
|
||||
COPY deployment/lambda/extractor_and_loader/docker/app.py ./
|
||||
# ---------- Final Lambda Image ----------
|
||||
FROM public.ecr.aws/lambda/python:3.12
|
||||
|
||||
# Set Lambda handler
|
||||
CMD ["app.handler"]
|
||||
# Copy installed dependencies from builder
|
||||
COPY --from=builder /python /var/task
|
||||
|
||||
# Copy your app code
|
||||
COPY etl/ /var/task/etl/
|
||||
COPY deployment/lambda/extractor_and_loader/docker/app.py /var/task/
|
||||
|
||||
# Set the Lambda handler (file.function_name)
|
||||
CMD ["app.handler"]
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue