Docker-编写 NGINX/uWSGI/Flask 绑定挂载问题

Docker-Compose NGINX/uWSGI/Flask bind mount issue

出于某种原因,当我在主机上更新 "app.py" 文件时,它不会在浏览器 (localhost) 中更新。它更新的唯一方法是关闭容器,重建并重新启动。无法弄清楚我在这里缺少什么?

以下是一些相关部分。你可以在我的 github

上看到完整的代码

https://github.com/longfellowone/Docker-Flask-NGINX-uWSGI

.
├── app
│   ├── app.py
│   ├── Dockerfile
│   ├── requirements.txt
│   ├── sock.sock
│   └── uwsgi.ini
├── docker-compose.yml
├── nginx
│   ├── Dockerfile
│   ├── nginx.conf
│   └── uwsgi_params
└── README.md

docker-compose.yml

    web: 
      build: ./app
      volumes:
        - type: bind
          source: ./app
          target: /src
      command: uwsgi --ini ./uwsgi.ini

    nginx:
      container_name: nginx
      image: nginx:latest
      volumes:
        - ./nginx/:/etc/nginx/
        - type: bind
          source: ./app/
          target: /tmp

nginx.conf

    sendfile off;

    upstream app { server unix:/tmp/sock.sock; }

    server {

        location / { try_files $uri @web; }

        location @web {
                include uwsgi_params;
                uwsgi_pass app;
        }

/app/Dockerfile

FROM python:latest

COPY requirements.txt /tmp/
RUN pip install --requirement /tmp/requirements.txt

WORKDIR /src/

app.py

from flask import Flask
app = Flask(__name__)

@app.route('/')
def hello_world():
    return 'Hello, World!'

uwsgi.ini

[uwsgi]

module = app:app

socket = sock.sock
chmod-socket = 666

已修复:解决方案是添加到 uwsgi.ini

"py-autoreload = 1"