Make local dev stack react to file changes reliably

- Poll for file changes (Vite, watchfiles) since host bind mounts don't deliver events
- Limit uvicorn reload to the app directory
- Dev nginx config re-resolves container names per request to avoid 502 after restarts

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
Simon GruberandClaude Sonnet 5.5 committed 2026-11-05 16:26:40 +01:00
1 parent 0481b71192
commit 5c1f4a77ef
3 files changed
+48 -2

No files matched your search

+12 -2
View File
@@ -15,8 +15,10 @@ services:
- ADMIN_EMAILS=${ADMIN_EMAILS:-}
- SMTP_HOST=mailpit
- SMTP_PORT=1025
# Bind mounts from Windows/macOS hosts don't deliver file events; poll instead
- WATCHFILES_FORCE_POLLING=true
restart: unless-stopped
command: uvicorn app.main:app --host 0.0.0.0 --port 5000 --reload
command: uvicorn app.main:app --host 0.0.0.0 --port 5000 --reload --reload-dir app
frontend:
build:
@@ -31,6 +33,8 @@ services:
- ./frontend/tsconfig.json:/app/tsconfig.json
- ./frontend/tsconfig.node.json:/app/tsconfig.node.json
- /app/node_modules # Reset node_modules by running with '--renew-anon-volumes'
environment:
- CHOKIDAR_USEPOLLING=true
command: npm run dev -- --host 0.0.0.0 --port 8000
mailpit:
@@ -47,7 +51,13 @@ services:
ports:
- "8020:8080"
volumes:
- ../nginx.conf:/etc/nginx/conf.d/default.conf:ro
- ./nginx.dev.conf:/etc/nginx/conf.d/default.conf:ro
command:
- sh
- -c
- |
echo "resolver $$(awk '/^nameserver/{print $$2; exit}' /etc/resolv.conf) valid=5s ipv6=off;" > /etc/nginx/resolver.conf
exec nginx -g 'daemon off;'
depends_on:
- backend
- frontend
+2
View File
@@ -3,4 +3,6 @@ import react from "@vitejs/plugin-react";
export default defineConfig({
plugins: [react()],
// Bind mounts from Windows/macOS hosts don't deliver file events; poll instead
server: { watch: { usePolling: true, interval: 300 } },
});
+34
View File
@@ -0,0 +1,34 @@
# Dev variant of ../nginx.conf: container names are re-resolved on every request.
# Static upstreams are resolved once at startup, so a restarted container (new IP) causes 502s.
# resolver.conf is generated by the nginx command in compose.yml (resolver IP differs between Docker and Podman).
include /etc/nginx/resolver.conf;
server {
listen 8080;
server_name _;
set $backend_upstream backend:5000;
set $frontend_upstream frontend:8000;
location /api/ {
# Image uploads are limited to 10 MB by the frontend; nginx defaults to 1 MB.
client_max_body_size 11m;
proxy_pass http://$backend_upstream;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
location / {
proxy_pass http://$frontend_upstream;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
}