Search code examples
pythondockeruwsgigeventalpine-linux

gevent uwsgi plugin not loading in Alpine docker


I'm trying to boot a simple uWSGI server on Alpine docker image (3.9). Here is the Python script

def application(env, start_response):
    start_response('200 OK', [('Content-Type','text/html')])
    return [b"Hello World"]

And I'm trying to start it using the following command:

uwsgi --plugins http,python3,gevent --http :8081 --uid nobody --gid nobody --wsgi-file hello.py --module hello --master --processes 4 --gevent 2 --gevent-monkey-patch --socket /tmp/uswgi.sock

However, every time I try this I get this error:

!!! UNABLE to load uWSGI plugin: Error relocating /usr/lib/uwsgi/gevent_plugin.so: PyInt_FromLong: symbol not found !!!
uwsgi: unrecognized option: gevent
getopt_long() error

I've tried installing python3-dev package, but the command still fails. Does anyone has idea why this happens? Here is my Dockerfile:

FROM alpine:3.9.3

RUN apk add --no-cache --update \
  python3 \
  python3-dev \
  uwsgi \
  uwsgi-python3 \
  uwsgi-http \
  uwsgi-gevent

CMD ["sh"]

Solution

  • uwsgi-gevent is the Python 2 uWSGI plugin:
    https://pkgs.alpinelinux.org/package/v3.9/main/x86_64/uwsgi-gevent

    For Python 3, you'd need uwsgi-gevent3.

    Also, you're missing the py3-gevent package for the gevent Python module.

    In summary, updated package list:

    RUN apk add --no-cache --update \
      python3 \
      python3-dev \
      py3-gevent \
      uwsgi \
      uwsgi-python3 \
      uwsgi-http \
      uwsgi-gevent3
    

    Plus, don't forget to use the gevent3 plugin instead of gevent:

    uwsgi --plugins http,python3,gevent3