I set up a dash app to visualize the development of COVID-19 Infections in Germany over time on a Google virtual machine running Ubuntu 18.04.
The app is based on three docker container:
Now my problem is, no matter what I do, the app I get served is a fairly outdated version of the app (data exactly as when I first deployed it. Up until March 28). I tried changing the source data to include newer, but also to include fewer data and did not see any change whatsoever. I also tried changing the Nginx-settings around proxy_buffers, proxy_buffer_size, proxy_buffering, but to no avail.
This leads me to believe that I am getting served a cached app. I tried different browser/machines/devices which leads me to believe that the caching happens server-side.
I am not very familiar with Nginx nor Gunicorn nor Dash for that matter. But what I find very strange is that the results seemed to be cashed, even after docker-compose up and down multiple times.
What am I missing here?
Find the repo here:
based on the following docker-compose file:
version: '3.7'
services:
web:
build: ./services/web
command: gunicorn --bind 0.0.0.0:5000 wsgi:app
expose:
- 5000
nginx:
image: nginx:1.17-alpine
restart: unless-stopped
volumes:
- ./data/nginx:/etc/nginx/conf.d
- ./data/certbot/conf:/etc/letsencrypt
- ./data/certbot/www:/var/www/certbot
ports:
- "80:80"
- "443:443"
depends_on:
- web
command: "/bin/sh -c 'while :; do sleep 6h & wait $${!}; nginx -s reload; done & nginx -g \"daemon off;\"'"
certbot:
image: certbot/certbot
restart: unless-stopped
volumes:
- ./data/certbot/conf:/etc/letsencrypt
- ./data/certbot/www:/var/www/certbot
entrypoint: "/bin/sh -c 'trap exit TERM; while :; do certbot renew; sleep 12h & wait $${!}; done;'"
Could be because the web Dockerfile runs a COPY command to copy in that entire directory, including data.csv.
Therefor if you place a new data.csv in that directory on the host, it would only be copied into the image if you do docker-compose build.
You could probably fix this by adding a volume mount to the web service, and place data.csv in there, allowing you to update that file on the host, then issue a docker-compose restart web.
To avoid having to issue that restart command, you'd probably have to change the way this part is coded:
def load_data():
global data
_ = pd.read_csv(os.path.join(os.path.dirname(__file__), '../data.csv'))
return _
data = load_data()
Let me know if you need further advice on this.