Fix os import and add media settings

This commit is contained in:
ack
2026-01-21 04:05:16 +03:00
parent 74ef625c88
commit bc93f9576b
3 changed files with 39 additions and 6 deletions

View File

@@ -9,7 +9,7 @@ https://docs.djangoproject.com/en/5.2/topics/settings/
For the full list of settings and their values, see
https://docs.djangoproject.com/en/5.2/ref/settings/
"""
import os
from pathlib import Path
# Build paths inside the project like this: BASE_DIR / 'subdir'.
@@ -116,6 +116,11 @@ USE_TZ = True
# https://docs.djangoproject.com/en/5.2/howto/static-files/
STATIC_URL = 'static/'
STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles')
MEDIA_URL = 'media/'
MEDIA_ROOT = os.path.join(BASE_DIR, 'media')
# Default primary key field type
# https://docs.djangoproject.com/en/5.2/ref/settings/#default-auto-field

18
default.conf Normal file
View File

@@ -0,0 +1,18 @@
server {
listen 80;
server_name localhost;
location / {
proxy_pass http://web:8000;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
}
location /static/ {
alias /app/staticfiles/;
}
location /media/ {
alias /app/media/;
}
}

View File

@@ -1,11 +1,21 @@
version: '3.8'
services:
web:
build: .
volumes:
- .:/app
# Больше не открываем порт 8080 наружу для Django,
# теперь его будет "прикрывать" Nginx
expose:
- "8000"
command: gunicorn core.wsgi:application --bind 0.0.0.0:8000 --workers 3
nginx:
image: nginx:latest
volumes:
- ./nginx/default.conf:/etc/nginx/conf.d/default.conf
- ./staticfiles:/app/staticfiles
- ./media:/app/media
ports:
- "8080:8000"
environment:
- DEBUG=1
- "8080:80"
depends_on:
- web