don't use aws lambda

This commit is contained in:
Jun-te Kim 2025-07-18 16:11:58 +00:00
parent dcf589f175
commit f84a50a9e2

View file

@ -1,30 +1,30 @@
# ---------- Builder Stage (uses Poetry) ----------
FROM python:3.12-slim as builder
# Start from lightweight base image
FROM python:3.12-slim
# Install Poetry
RUN pip install --no-cache-dir poetry
# Set environment vars to reduce image size and avoid bytecode
ENV PYTHONDONTWRITEBYTECODE=1 \
PYTHONUNBUFFERED=1 \
PIP_NO_CACHE_DIR=1
# Install required system packages and Lambda RIC
RUN apt-get update && apt-get install -y curl \
&& pip install awslambdaric \
&& apt-get clean && rm -rf /var/lib/apt/lists/*
# Set working directory
WORKDIR /app
WORKDIR /var/task
# Copy only what's needed for dependency resolution
# Copy Poetry files and export dependencies
COPY pyproject.toml poetry.lock ./
RUN pip install poetry \
&& poetry export -f requirements.txt --without-hashes --only main -o requirements.txt \
&& pip install -r requirements.txt --target . \
&& rm -rf ~/.cache .venv
# Export dependencies (no dev) to requirements.txt
RUN poetry export -f requirements.txt --without-hashes --only main -o requirements.txt
# Copy app code
COPY etl/ etl/
COPY deployment/lambda/extractor_and_loader/docker/app.py .
# Install into a clean target folder
RUN pip install --no-cache-dir -r requirements.txt --target /python
# ---------- Final Lambda Image ----------
FROM public.ecr.aws/lambda/python:3.12
# 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)
# Lambda entrypoint
ENTRYPOINT ["/usr/local/bin/python3", "-m", "awslambdaric"]
CMD ["app.handler"]