Python Cryptography/CFFI not supported
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.
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?
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.
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?
I believe these questions have been answered.
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.