From 0c2ad449ef4084ae51fbfe50f2b5453d5bd1c248 Mon Sep 17 00:00:00 2001 From: igor_nadein Date: Tue, 17 Feb 2026 18:33:20 +0300 Subject: [PATCH] =?UTF-8?q?feat(docker):=20=D0=B4=D0=BE=D0=B1=D0=B0=D0=B2?= =?UTF-8?q?=D0=BB=D0=B5=D0=BD=D0=B8=D0=B5=20=D0=B2=D1=81=D0=BF=D0=BE=D0=BC?= =?UTF-8?q?=D0=BE=D0=B3=D0=B0=D1=82=D0=B5=D0=BB=D1=8C=D0=BD=D1=8B=D1=85=20?= =?UTF-8?q?=D1=84=D0=B0=D0=B9=D0=BB=D0=BE=D0=B2=20=D0=B4=D0=BB=D1=8F=20Doc?= =?UTF-8?q?ker?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - .dockerignore - исключение ненужных файлов при сборке образа - .env.example - пример переменных окружения - backend/eusrr_backend/urls.py - добавлена раздача статических файлов в DEBUG режиме --- .dockerignore | 56 +++++++++++++++++++++++++++++++++++ .env.example | 39 ++++++++++++++++++++++++ backend/eusrr_backend/urls.py | 21 ++++++++++--- 3 files changed, 112 insertions(+), 4 deletions(-) create mode 100644 .dockerignore create mode 100644 .env.example diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 00000000..c5d7fe0b --- /dev/null +++ b/.dockerignore @@ -0,0 +1,56 @@ +# Git +.git +.gitignore +.github + +# Python +__pycache__ +*.py[cod] +*$py.class +*.so +.Python +*.egg-info +dist/ +build/ +.venv +venv/ +env/ +ENV/ + +# Django +*.log +logs/ +db.sqlite3 +db.sqlite3-journal +/media +/staticfiles +/static + +# IDE +.vscode +.idea +*.swp +*.swo +*~ + +# OS +.DS_Store +Thumbs.db + +# Documentation +docs/ +*.md +!README.md + +# Test +.pytest_cache +.coverage +htmlcov/ +.tox/ + +# Environment +.env +.env.local + +# Docker +docker-compose.override.yml diff --git a/.env.example b/.env.example new file mode 100644 index 00000000..71b5802b --- /dev/null +++ b/.env.example @@ -0,0 +1,39 @@ +# Django Settings +DEBUG=False +SECRET_KEY=change-me-django-secret-key +ALLOWED_HOSTS=localhost,127.0.0.1,web + +# Database Settings +USE_SQLITE=False +POSTGRES_DB=eusrr +POSTGRES_USER=eusrr_user +POSTGRES_PASSWORD=change-me-postgres-password +DB_HOST=db +DB_PORT=5432 + +# Redis Settings +REDIS_HOST=redis +REDIS_PORT=6379 + +# Celery Settings +CELERY_BROKER_URL=redis://redis:6379/0 +CELERY_RESULT_BACKEND=redis://redis:6379/1 + +# Ports (for development) +WEB_PORT=8000 + +# LDAP Settings (if used) +# LDAP_SERVER_URI=ldap://your-ldap-server +# LDAP_BIND_DN=cn=admin,dc=example,dc=com +# LDAP_BIND_PASSWORD=your-ldap-password +# LDAP_USER_SEARCH_BASE=ou=users,dc=example,dc=com + +# Email Settings (if used) +# EMAIL_HOST=smtp.gmail.com +# EMAIL_PORT=587 +# EMAIL_USE_TLS=True +# EMAIL_HOST_USER=your-email@example.com +# EMAIL_HOST_PASSWORD=your-email-password + +# Other Settings +# SITE_URL=http://localhost:8000 diff --git a/backend/eusrr_backend/urls.py b/backend/eusrr_backend/urls.py index c848d3b4..cf881407 100644 --- a/backend/eusrr_backend/urls.py +++ b/backend/eusrr_backend/urls.py @@ -1,9 +1,11 @@ +import os + from django.conf import settings from django.conf.urls.static import static from django.contrib import admin -from django.urls import include, path from django.http import FileResponse -import os +from django.urls import include, path + def serve_service_worker(request): """Обслуживает Service Worker с правильным content-type и заголовками""" @@ -25,10 +27,10 @@ def serve_service_worker(request): from django.http import HttpResponse return HttpResponse(f"Service Worker not found: {e}", status=500) + urlpatterns = [ path("admin/", admin.site.urls), path("auth/", include("employees.urls_front_auth", namespace="auth_front")), - path("documents/", include("documents.urls", namespace="documents")), path("requests/", include("requests_app.urls", namespace="requests")), path("employees/", include("employees.urls_front", namespace="employees")), path("communications/", include("communications.urls", namespace="communications")), @@ -39,4 +41,15 @@ urlpatterns = [ # Service Worker должен быть в корне для правильного scope path("sw.js", serve_service_worker, name="sw"), path("", include("feed.urls_front", namespace="feed")), -] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT) +] + +# Serve static and media files in development +if settings.DEBUG: + urlpatterns += static(settings.STATIC_URL, + document_root=settings.STATIC_ROOT) + urlpatterns += static(settings.MEDIA_URL, + document_root=settings.MEDIA_ROOT) +else: + # In production, media files should still be served by Django/Daphne + urlpatterns += static(settings.MEDIA_URL, + document_root=settings.MEDIA_ROOT)