feat(static): improve static files handling and permissions in Docker

- Add script to set correct permissions on static files after collectstatic
- Introduce collectstatic command in entrypoint with permission fixing
- Add WhiteNoise middleware for efficient static file serving without DB access
- Configure WhiteNoise static files storage backend in settings
- Set STATIC_ROOT path properly for Docker container environment
- Add fallback static files serving in Django urls for production without nginx
- Enhance inventory_detail.html scripts to log errors if JS files or components fail to load
- Add whitenoise package to requirements for static file serving support
This commit is contained in:
2025-12-22 20:45:52 +03:00
parent 6eea53754a
commit 483f150e7a
6 changed files with 66 additions and 8 deletions

View File

@@ -45,3 +45,9 @@ else:
'document_root': settings.MEDIA_ROOT,
}),
]
# Fallback для статических файлов в production (если nginx не настроен или не может прочитать файлы)
urlpatterns += [
re_path(r'^static/(?P<path>.*)$', serve, {
'document_root': settings.STATIC_ROOT,
}),
]