From 906082577c3dbc2901c7bbede9315b53a33bcd92 Mon Sep 17 00:00:00 2001 From: r0mchik Date: Mon, 26 May 2025 19:27:32 +0700 Subject: [PATCH] v0.0.3 --- .gitignore | 5 ++++- docker-compose-dev.yaml | 2 +- docker-compose.yaml | 11 +++------- web/Dockerfile | 2 ++ web/app/settings.py | 45 ++++++++++++++++++++++++----------------- 5 files changed, 36 insertions(+), 29 deletions(-) diff --git a/.gitignore b/.gitignore index 755fb4e..088a105 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,6 @@ .env __pycache__ -venv \ No newline at end of file +venv +--cached +media +web/logs \ No newline at end of file diff --git a/docker-compose-dev.yaml b/docker-compose-dev.yaml index 269c0f6..0f031b8 100644 --- a/docker-compose-dev.yaml +++ b/docker-compose-dev.yaml @@ -8,7 +8,7 @@ services: volumes: - .:/app - ./media:/app/media - - ./static:/app/staticfiles + - ./web/staticfiles:/app/web/staticfiles # - ./media:/app/media ports: - "8000:8000" diff --git a/docker-compose.yaml b/docker-compose.yaml index e4721bf..985183f 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -7,14 +7,11 @@ services: volumes: - .:/app - ./media:/app/media - - ./static:/app/staticfiles + - ./web/staticfiles:/app/staticfiles # - ./media:/app/media ports: - "8106:8106" - expose: - - 8000 - depends_on: - redis # - vpn @@ -43,14 +40,12 @@ services: # ports: # - "80:80" # volumes: - - # - ./static:/home/app/static # # - ./nginx/nginx.conf:/etc/nginx/nginx.conf - # # - ./nginx/nginx.conf:/etc/nginx/conf.d/nginx.conf + # - ./nginx/nginx/conf.d/nginx.conf:/etc/nginx/conf.d/nginx.conf # depends_on: # - web - # restart: always + # restart: always redis: diff --git a/web/Dockerfile b/web/Dockerfile index 350579d..bb294b3 100644 --- a/web/Dockerfile +++ b/web/Dockerfile @@ -17,6 +17,8 @@ ENV PYTHONDONTWRITEBYTECODE=1 \ WORKDIR /app/web +RUN cd /app/web && mkdir logs + COPY requirements.txt . RUN pip install --no-cache-dir -r requirements.txt COPY . . diff --git a/web/app/settings.py b/web/app/settings.py index f76fad6..bc2c595 100644 --- a/web/app/settings.py +++ b/web/app/settings.py @@ -129,7 +129,7 @@ USE_TZ = True # Static files (CSS, JavaScript, Images) # https://docs.djangoproject.com/en/5.2/howto/static-files/ -STATIC_URL = '/staticfiles/' +STATIC_URL = 'staticfiles' STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles') # Default primary key field type @@ -148,21 +148,28 @@ CHANNEL_LAYERS = { }, } -# LOGGING = { -# 'version': 1, -# 'disable_existing_loggers': False, -# 'handlers': { -# 'file': { -# 'level': 'WARNING', -# 'class': 'logging.FileHandler', -# 'filename': '/app/logs/django.log', -# }, -# }, -# 'loggers': { -# 'django': { -# 'handlers': ['file'], -# 'level': 'WARNING', -# 'propagate': True, -# }, -# }, -# } \ No newline at end of file +LOGGING = { + 'version': 1, + 'disable_existing_loggers': False, # чтобы не отключать встроенные логи Django + 'formatters': { + 'simple': { + 'format': '[{levelname}] {asctime} {name}: {message}', + 'style': '{', + }, + }, + 'handlers': { + 'console': { + 'class': 'logging.StreamHandler', + 'formatter': 'simple', + }, + 'file': { + 'class': 'logging.FileHandler', + 'filename': os.path.join(BASE_DIR,'logs', 'django.log'), + 'formatter': 'simple', + }, + }, + 'root': { + 'handlers': ['console', 'file'], + 'level': 'INFO', + }, +} \ No newline at end of file