|
| 1 | +FROM public.ecr.aws/lambda/provided:al2023 AS builder |
| 2 | + |
| 3 | +RUN dnf install -y unzip python3-pip findutils && \ |
| 4 | + dnf clean all |
| 5 | + |
| 6 | +# Download http-cli |
| 7 | +RUN --mount=type=secret,id=github_token \ |
| 8 | + curl -H "Authorization: token $(cat /run/secrets/github_token)" \ |
| 9 | + -L https://github.com/ql4b/http-cli/archive/refs/heads/develop.zip \ |
| 10 | + -o http-cli.zip && \ |
| 11 | + unzip http-cli.zip && \ |
| 12 | + mkdir -p /http-cli-bin && \ |
| 13 | + mv http-cli-develop/http-cli /http-cli-bin/ && \ |
| 14 | + chmod +x /http-cli-bin/http-cli && \ |
| 15 | + rm -rf http-cli.zip http-cli-develop |
| 16 | + |
| 17 | +RUN pip3 install --no-cache-dir --target /tmp/awscurl awscurl && \ |
| 18 | + find /tmp/awscurl -type d -name '__pycache__' -exec rm -rf {} + && \ |
| 19 | + find /tmp/awscurl -type f -name '*.pyc' -delete && \ |
| 20 | + find /tmp/awscurl -type d -name '*.dist-info' -exec rm -rf {} + |
| 21 | + |
| 22 | +# Stage 2: Runtime stage |
| 23 | +FROM public.ecr.aws/lambda/provided:al2023 |
| 24 | + |
| 25 | +# Install only runtime dependencies |
| 26 | +RUN dnf install -y jq python3 && \ |
| 27 | + dnf clean all && \ |
| 28 | + rm -rf /var/cache/dnf |
| 29 | + |
| 30 | +# Copy only what's needed |
| 31 | +COPY --from=builder /tmp/awscurl /var/task/aws |
| 32 | +# Clean up Python cache and metadata |
| 33 | +RUN rm -rf \ |
| 34 | + /var/task/aws/__pycache__ \ |
| 35 | + /var/task/aws/*.dist-info \ |
| 36 | + /var/task/aws/**/__pycache__ |
| 37 | + |
| 38 | +ENV PYTHONPATH="/var/task/aws" |
| 39 | + |
| 40 | +RUN mkdir -p /var/task/bin && \ |
| 41 | + printf '#!/bin/sh\nexport PYTHONPATH=/var/task/aws\nexec python3 -m awscurl.awscurl "$@"\n' > /var/task/bin/awscurl && \ |
| 42 | + chmod +x /var/task/bin/awscurl |
| 43 | + |
| 44 | +# Copy http-cli |
| 45 | +COPY --from=builder /http-cli-bin/http-cli /var/task/bin/http-cli |
| 46 | +ENV PATH="/var/task/bin:${PATH}" |
| 47 | + |
| 48 | +COPY runtime/bootstrap /var/runtime/bootstrap |
| 49 | +RUN chmod +x /var/runtime/bootstrap |
| 50 | + |
| 51 | +WORKDIR /var/task |
| 52 | + |
| 53 | +COPY functions/handler.sh handler.sh |
0 commit comments