'Error while building python docker container with uWSGI

Here is my Dockerfile:

FROM python:3.7-alpine


RUN mkdir -p /usr/src/app 
WORKDIR /usr/src/app

COPY . /usr/src/app

RUN apk --update add gcc build-base freetype-dev libpng-dev openblas-dev musl-dev
RUN apk update

RUN pip install --no-cache-dir -r requirements.txt

EXPOSE 5000

CMD ["uwsgi", "app.ini"]

When building uwsgi wheel got and error:

In file included from core/utils.c:1:
  ./uwsgi.h:238:10: fatal error: linux/limits.h: No such file or directory
    238 | #include <linux/limits.h>
        |          ^~~~~~~~~~~~~~~~

What package am i need to add to Dockerfile?+



Solution 1:[1]

I also ran in the situation that the container was not building the uwsgi. After changing "FROM python:3.8-alpine" to "FROM python:3.8" everything worked fine. Then i think you also don't need to install the linux-packages.

Solution 2:[2]

Try adding apk add linux-headers, looks like uwsgi is missing some headers during the build, might be due to alpine being very bare-bones

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Jussi Visapää
Solution 2 Ron Serruya