gevent uwsgi 插件未在 Alpine 中加载 docker

gevent uwsgi plugin not loading in Alpine docker

我正在尝试在 Alpine docker 映像 (3.9) 上启动一个简单的 uWSGI 服务器。这是 Python 脚本

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

我正在尝试使用以下命令启动它:

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

但是,每次尝试此操作时都会出现此错误:

!!! 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

我已经尝试安装 python3-dev 包,但命令仍然失败。有谁知道为什么会这样?这是我的 Dockerfile:

FROM alpine:3.9.3

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

CMD ["sh"]

uwsgi-gevent 是 Python 2 uWSGI 插件:
https://pkgs.alpinelinux.org/package/v3.9/main/x86_64/uwsgi-gevent

对于 Python 3,您需要 uwsgi-gevent3

此外,您缺少 gevent Python 模块的 py3-gevent 包。

总而言之,更新的软件包列表:

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

此外,不要忘记使用 gevent3 插件而不是 gevent:

uwsgi --plugins http,python3,gevent3