I had slight problems with this, and in short, I would advise you to ask if this is really worth the hassle. Numpy is huge when you start adding things like pandas, gpus and scipy to the stack, so the benefits of building it on alpine are limited, and the savings compared to using Debian, Arch, or even Ubuntu are relatively small when 500 MB of your space is turned on. this library anyway.
Having said that, I put together an image that does this. I needed build time dependencies: musl-dev, linux-headers and g ++. I also had to add openblas from edge for something later on the stack, so it is entirely possible that some dependencies would also be required. But I believe that simply adding the three former libraries with
apk --no-cache add musl-dev linux-headers g++
should be enough to prevent a gcc error from occurring. You can view the image at https://hub.docker.com/r/o76923/alpine-numpy-stack/
source share