From 39a1eb29d5cd836bc44b0b18c46bdc640cbda016 Mon Sep 17 00:00:00 2001 From: Jun-te Kim Date: Fri, 18 Jul 2025 16:18:17 +0000 Subject: [PATCH] more cleaner --- .../extractor_and_loader/docker/Dockerfile | 21 ++++++++++++------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/deployment/lambda/extractor_and_loader/docker/Dockerfile b/deployment/lambda/extractor_and_loader/docker/Dockerfile index dcbe910..7ed1d7c 100644 --- a/deployment/lambda/extractor_and_loader/docker/Dockerfile +++ b/deployment/lambda/extractor_and_loader/docker/Dockerfile @@ -9,15 +9,20 @@ RUN pip install poetry # Set working directory WORKDIR /app -# Copy only what's needed to resolve dependencies +# Copy Poetry files and your source code COPY pyproject.toml poetry.lock ./ +COPY etl/ etl/ -# Export main dependencies only +# Export main dependencies RUN poetry export -f requirements.txt --without-hashes --only main -o requirements.txt -# Install dependencies to /python (Lambda expects this path) +# 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 @@ -26,19 +31,19 @@ ENV PYTHONDONTWRITEBYTECODE=1 \ PYTHONUNBUFFERED=1 \ PIP_NO_CACHE_DIR=1 -# Install Lambda Runtime Interface Client (RIC) +# Install Lambda RIC RUN pip install awslambdaric -# Copy app dependencies from builder +# 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 application code -COPY etl/ etl/ +# Copy Lambda handler COPY deployment/lambda/extractor_and_loader/docker/app.py . -# Lambda entrypoint +# Set Lambda entrypoint and handler ENTRYPOINT ["python3", "-m", "awslambdaric"] CMD ["app.handler"]