簡體   English   中英

Docker-Compose NGINX/uWSGI/Flask 綁定掛載問題

[英]Docker-Compose NGINX/uWSGI/Flask bind mount issue

出於某種原因,當我更新主機上的“app.py”文件時,它不會在瀏覽器(本地主機)中更新。 它將更新的唯一方法是關閉容器,重建並重新啟動。 無法弄清楚我在這里缺少什么?

以下是一些相關的部分。 你可以在我的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

配置文件

    sendfile off;

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

    server {

        location / { try_files $uri @web; }

        location @web {
                include uwsgi_params;
                uwsgi_pass app;
        }

/應用程序/Dockerfile

FROM python:latest

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

WORKDIR /src/

應用程序

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" 

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM