distroless icon indicating copy to clipboard operation
distroless copied to clipboard

Python Cryptography/CFFI not supported

Open lstn opened this issue 8 years ago • 5 comments

Libraries that use cryptography or bcrypt will not work, as far as I can tell, due to the lack of _cffi_backend.so in the PYTHONPATH (tried with the Python 3.7 image). Installing the CFFI module will not help.

The package that would usually need to be present on the system for this to work would be libffi-devel.

lstn avatar Nov 22 '18 14:11 lstn

I also need libffi but this is only one of many.

Is it possible to mix a multi-stage build with Alpine?

FROM python:3.6-alpine AS build-image
RUN apk add --update-cache \
  build-base \
  binutils \
  gcc \
  linux-headers \
  musl-dev \
  mailcap \
  libffi-dev \
  libpq \
  ca-certificates \
  postgresql-dev \
  jpeg-dev openjpeg-dev \
  zlib-dev freetype-dev tiff-dev tk-dev tcl-dev

FROM gcr.io/distroless/python3

COPY --from=build-image /usr/include/* /usr/include/
...?

What about: /usr/lib? /lib? /usr/local/lib?

How do we get all those library dependencies into distroless? It seems a recursive COPY is too inclusive and copying each file individually would make a long and ridiculously unmaintainable Dockerfile.

If extra dependencies are needed, is this just not a use-case for distroless?

nitrag avatar Jan 04 '19 20:01 nitrag

There are various solutions for this.

Starting with a Debian Stretch base you can build your application and copy over your files one by one or with the help of a shell script to consolidate all the assets into /app for example.

You can add /app to your PYTHONPATH once all the assets are there.

Optionally you could include the desired assets in the code base (with a README explaining where they come from) and build everything off the distroless image.

lathama avatar Feb 27 '19 15:02 lathama

Is it possible to mix a multi-stage build with Alpine?

I am not really qualified to confirm this, but I believe Alpine uses musl, so taking binaries from Alpine to Distroless may not necessarily work?

chanseokoh avatar Feb 27 '19 16:02 chanseokoh

I believe these questions have been answered.

donmccasland avatar Nov 01 '19 17:11 donmccasland

I have the same queries... I don't know how to do that with Alpine. I have node-rdkafka that need some libs to build on the Alpine side.

But on the distroless side I have the error : Error: libc.musl-x86_64.so.1: cannot open shared object file: No such file or directory.

So I suppose I will have a problem as musl is not in the distroless image.

RemyLespagnol avatar Nov 28 '19 10:11 RemyLespagnol