more minimal

This commit is contained in:
Jun-te Kim 2025-07-18 16:16:52 +00:00
parent 4581b3ad82
commit 4a06e52f41

View file

@ -1,29 +1,44 @@
# Start from lightweight base image
# ----------- 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
# 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/*
# 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 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
# Copy app code
# Copy application code
COPY etl/ etl/
COPY deployment/lambda/extractor_and_loader/docker/app.py .
# Lambda entrypoint
ENTRYPOINT ["/usr/local/bin/python3", "-m", "awslambdaric"]
ENTRYPOINT ["python3", "-m", "awslambdaric"]
CMD ["app.handler"]