Пробую проверить flask + uwsgi на docker. Вот мой Dockerfile:
FROM --platform=linux/amd64 python:3.8.3-buster as build
WORKDIR /opt/test_apis
COPY requirements.txt /opt/test_apis
RUN pip3 wheel --no-cache-dir --wheel-dir=/root/wheels -r requirements.txt
FROM --platform=linux/amd64 python:3.8.3-slim-buster as test_apis_runner
WORKDIR /opt/test_apis
ARG DEBIAN_FRONTEND=noninteractive
RUN apt-get update && apt-get install -y --no-install-recommends apt-utils
RUN apt-get update \
&& apt-get install -y libpq5 libxml2 \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
COPY --from=build /root/wheels /root/wheels
COPY requirements.txt /opt/test_apis
RUN pip3 install --no-index --find-links=/root/wheels -r requirements.txt
COPY deploy/uwsgi.ini /opt/test_apis
COPY deploy/permission.sh /
COPY flaskr /opt/test_apis/flaskr
ARG uwsgi_uid
ARG uwsgi_gid
RUN bash /permission.sh "${uwsgi_uid}" "${uwsgi_gid}"
ENV PYTHONPATH /opt/test_apis/flaskr
ENTRYPOINT ["uwsgi"]
CMD ["--ini", "uwsgi.ini", "--manage-script-name"]
вот мой uwsgi.ini
[uwsgi]
socket = /var/run/uwsgi/test_apis.sock
pid = /var/run/uwsgi/test_apis.pid
logto = /var/log/test_apis@(exec://date +%%Y-%%m-%%d).log
chdir=/opt/test_apis/flaskr
mount=/=wsgi:app
callable=application
chmod-socket = 664
http-timeout = 120
vacuum = true
uid = uwsgi
gid = uwsgi
мой исходный код:
/opt/test_apis/flaskr
|-__init__.py
|-apis.py
|-wsgi.py
команда: "docker -compose up "в порядке, однако у меня есть ошибки в файле журнала:
...
*** Operational MODE: preforking+threaded ***
*** uWSGI is running in multiple interpreter mode ***
spawned uWSGI master process (pid: 1)
spawned uWSGI worker 1 (pid: 8, cores: 15)
spawned uWSGI worker 2 (pid: 9, cores: 15)
subprocess 6 exited with code 0
mounting wsgi:app on /
ModuleNotFoundError: No module named 'wsgi'
unable to load app 0 (mountpoint='/') (callable not found or import error)
*** no app loaded. going in full dynamic mode ***
mounting wsgi:app on /
ModuleNotFoundError: No module named 'wsgi'
unable to load app 0 (mountpoint='/') (callable not found or import error)
Но uwsgi работал, когда я пытался получить доступ к docker и запустить:
$ uwsgi --init uwsgi.ini
Как решить эту проблему проблема?