fix(deploy): serve django media and static from shared volumes

This commit is contained in:
2026-04-29 18:04:53 +03:30
parent 34af725f41
commit 50eaf00cf2
2 changed files with 15 additions and 15 deletions

View File

@@ -22,16 +22,16 @@ services:
ports:
- "127.0.0.1:6379:6379"
backend:
backend:
build:
context: ./backend/qlockify-backend-deployment
dockerfile: ../Dockerfile
restart: always
env_file:
- ./backend/qlockify-backend-deployment/.env
volumes:
- static_data:/app/staticfiles
- media_data:/app/mediafiles
env_file:
- ./backend/qlockify-backend-deployment/.env
volumes:
- static_data:/app/static
- media_data:/app/media
command: >
sh -c "python manage.py migrate &&
python manage.py collectstatic --noinput &&
@@ -44,15 +44,15 @@ services:
redis:
condition: service_started
celery:
celery:
build:
context: ./backend/qlockify-backend-deployment
dockerfile: ../Dockerfile
restart: always
env_file:
- ./backend/qlockify-backend-deployment/.env
volumes:
- media_data:/app/mediafiles
env_file:
- ./backend/qlockify-backend-deployment/.env
volumes:
- media_data:/app/media
command: celery -A config worker -l INFO
depends_on:
db:
@@ -82,8 +82,8 @@ services:
- ./nginx/nginx.conf:/etc/nginx/conf.d/default.conf:ro
- ./nginx/certs:/etc/nginx/certs:ro
- ./nginx/.htpasswd:/etc/nginx/.htpasswd:ro
- static_data:/usr/share/nginx/html/staticfiles:ro
- media_data:/usr/share/nginx/html/mediafiles:ro
- static_data:/usr/share/nginx/html/static:ro
- media_data:/usr/share/nginx/html/media:ro
depends_on:
- backend
- frontend

View File

@@ -37,13 +37,13 @@ server {
# Static and Media files
location /static/ {
alias /usr/share/nginx/html/staticfiles/;
alias /usr/share/nginx/html/static/;
expires 30d;
access_log off;
}
location /media/ {
alias /usr/share/nginx/html/mediafiles/;
alias /usr/share/nginx/html/media/;
expires 30d;
access_log off;
}