-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
numpy unable to import packages with python distroless #1296
Comments
I gave it a try on the chainguard image and it seems to work: $ docker run -it -u root --entrypoint=sh cgr.dev/chainguard/python:latest-dev
$ pip install numpy pytest hypothesis typing_extensions
$ python
# import numpy
# numpy.test()
25189 passed, 411 skipped, 1307 deselected, 31 xfailed, 5 xpassed, 25 warnings in 66.86s (0:01:06) |
but chainguard uses python3.11 which is incompatible with my app, and probably many others. @dlorenc |
Which version are you looking for? We have 3.10 as well, and others are on the way. |
@dlorenc |
it worked using this Dockerfile: FROM python:3.8-slim-buster AS protobuf
ENV PB_REL="https://github.com/protocolbuffers/protobuf/releases"
ENV VERSION="21.12"
ENV PYTHONUNBUFFERED=true
WORKDIR /protobuf
COPY server/proto .
RUN apt-get update && \
apt-get install -y --no-install-recommends \
unzip curl zip && \
rm -rf /var/lib/apt/lists/*
RUN curl -LO $PB_REL/download/v${VERSION}/protoc-${VERSION}-linux-x86_64.zip && \
unzip -o protoc-${VERSION}-linux-x86_64.zip -d /usr/local bin/protoc && \
unzip -o protoc-${VERSION}-linux-x86_64.zip -d /usr/local include/* && \
rm -rf protoc-${VERSION}-linux-x86_64.zip
RUN mkdir output/ && \
for p in $(find . -type f -name "*.proto"); do \
protoc --python_out=output/ --pyi_out=output/ ${p} ; \
done
COPY Pipfile* ./
RUN pip install pipenv && \
pipenv requirements > requirements.txt
FROM cgr.dev/chainguard/python:3.10-dev AS build
WORKDIR /app
COPY --from=protobuf /protobuf/requirements.txt .
RUN pip install -r requirements.txt --user
FROM cgr.dev/chainguard/python:3.10
COPY --from=build /home/nonroot/.local/lib/python3.10/site-packages /home/nonroot/.local/lib/python3.10/site-packages
COPY server /app/server
COPY --from=protobuf /protobuf/output /app/server/.
WORKDIR /app
USER root
ENV PYTHONPATH=/home/nonroot/.local/lib/python3.10/site-packages
CMD ["server/app.py"] |
I would like pipenv to be added to chainguard, but obviously that's just my egoistic liking, this works fine :) @dlorenc |
BTW this has reduced my vulnerabilities from |
Yay! Can you file an issue for us here? https://github.com/wolfi-dev/os |
Describe the bug
My python app uses numpy version 1.23.4, it fails on importing C-extensions.
Numpy is also very popular package, the python packages should come with prerequisites in order for it to work properly.
To Reproduce
Python app with numpy usage.
Expected behavior
Numpy imports it's packages and works
Console Output
If applicable, add information from your container run
Additional context
Dockerfile:
The text was updated successfully, but these errors were encountered: