由于某些原因,当我在主机上更新“ 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
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
答案 0 :(得分:1)
固定:解决方案是添加到 uwsgi.ini
"py-autoreload = 1"