Open synic opened 3 years ago
Figured it out, it's because I'm installing libstdc++
as a build library and then uninstalling it after the build completes. It needs to stay installed, so changing the first apk-add
bit to this works:
RUN apk add --no-cache \
libstdc++ \
libpq \
&& apk add --no-cache --virtual .build-deps \
autoconf \
automake \
build-base \
cmake \
libcurl \
libexecinfo-dev \
libtool \
make \
musl-dev \
postgresql-dev \
python3-dev \
&& pip install --no-cache-dir -e . \
&& apk del --no-cache .build-deps
By the way, I was able to find out why it wasn't working by looking at the code, specifically this line: https://github.com/aws/aws-lambda-python-runtime-interface-client/blob/main/awslambdaric/lambda_runtime_client.py#L31
try:
import runtime_client
runtime_client.initialize_client(_user_agent())
except ImportError:
runtime_client = None # THIS LINE HERE
Then, I just opened a python shell and typed import runtime_client
I don't know that it's good that it just silently fails on the import there. Is there a reason to believe the library can work when runtime_client
is None
?
I've had the same issue, but with python:3.8-alpine
. It seems like there are a LOT of assumptions (see also the documentation issue I opened, #24 ) about the container being perfectly set up... when there's little documentation on how to actually do that.
I had the same issue and had to do the same step as @synic to figure out the cause. In my case, the missing dependency was resolved by installing curl. I would remove except ImportError clause or at least document which dependencies are required by awslambdaric to be installed.
I had the same issue and had to do the same step as @synic to figure out the cause. In my case, the missing dependency was resolved by installing curl. I would remove except ImportError clause or at least document which dependencies are required by awslambdaric to be installed.
This worked for me.
For me it was libzstd.so
missing (FROM python:3.12-alpine3.19
). I just added to my the following to the final stage of my docker multi-stage build.
RUN apk add --no-cache zstd-dev
This was a really annoying issue, and there was no way to identify the cause without additional logging. I have opened a PR and am waiting for guidance about the proper way to log this.
Here's the full Dockerfile if interested:
FROM python:3.12-alpine3.19 as base
ARG FUNCTION_DIR="/app"
WORKDIR ${FUNCTION_DIR}
FROM base as builder
RUN apk update && \
apk add --no-cache \
cmake \
autoconf \
automake \
libtool \
binutils \
gcc \
libc-dev \
make \
elfutils-dev \
g++
COPY requirements.txt .
RUN pip install \
--target ${FUNCTION_DIR} --no-cache-dir -r requirements.txt
COPY app.py .
COPY --chmod=755 entrypoint.sh .
RUN rm requirements.txt
FROM base as final
RUN apk add --no-cache zstd-dev
COPY --from=builder ${FUNCTION_DIR} ${FUNCTION_DIR}
EXPOSE 3000
ENTRYPOINT ["/app/entrypoint.sh"]
This is happening to me with the
python:3.9-alpine3.12
base image. Here is the Dockerfile:Here's the
entry.sh
:and here's the error:
Just to make sure, I ran
docker exec -it mycontainer /bin/bash
and typed/usr/local/bin/python --version
, the response wasPython 3.9.1