fix(deploy): serve django media and static from shared volumes
This commit is contained in:
@@ -22,16 +22,16 @@ services:
|
|||||||
ports:
|
ports:
|
||||||
- "127.0.0.1:6379:6379"
|
- "127.0.0.1:6379:6379"
|
||||||
|
|
||||||
backend:
|
backend:
|
||||||
build:
|
build:
|
||||||
context: ./backend/qlockify-backend-deployment
|
context: ./backend/qlockify-backend-deployment
|
||||||
dockerfile: ../Dockerfile
|
dockerfile: ../Dockerfile
|
||||||
restart: always
|
restart: always
|
||||||
env_file:
|
env_file:
|
||||||
- ./backend/qlockify-backend-deployment/.env
|
- ./backend/qlockify-backend-deployment/.env
|
||||||
volumes:
|
volumes:
|
||||||
- static_data:/app/staticfiles
|
- static_data:/app/static
|
||||||
- media_data:/app/mediafiles
|
- media_data:/app/media
|
||||||
command: >
|
command: >
|
||||||
sh -c "python manage.py migrate &&
|
sh -c "python manage.py migrate &&
|
||||||
python manage.py collectstatic --noinput &&
|
python manage.py collectstatic --noinput &&
|
||||||
@@ -44,15 +44,15 @@ services:
|
|||||||
redis:
|
redis:
|
||||||
condition: service_started
|
condition: service_started
|
||||||
|
|
||||||
celery:
|
celery:
|
||||||
build:
|
build:
|
||||||
context: ./backend/qlockify-backend-deployment
|
context: ./backend/qlockify-backend-deployment
|
||||||
dockerfile: ../Dockerfile
|
dockerfile: ../Dockerfile
|
||||||
restart: always
|
restart: always
|
||||||
env_file:
|
env_file:
|
||||||
- ./backend/qlockify-backend-deployment/.env
|
- ./backend/qlockify-backend-deployment/.env
|
||||||
volumes:
|
volumes:
|
||||||
- media_data:/app/mediafiles
|
- media_data:/app/media
|
||||||
command: celery -A config worker -l INFO
|
command: celery -A config worker -l INFO
|
||||||
depends_on:
|
depends_on:
|
||||||
db:
|
db:
|
||||||
@@ -82,8 +82,8 @@ services:
|
|||||||
- ./nginx/nginx.conf:/etc/nginx/conf.d/default.conf:ro
|
- ./nginx/nginx.conf:/etc/nginx/conf.d/default.conf:ro
|
||||||
- ./nginx/certs:/etc/nginx/certs:ro
|
- ./nginx/certs:/etc/nginx/certs:ro
|
||||||
- ./nginx/.htpasswd:/etc/nginx/.htpasswd:ro
|
- ./nginx/.htpasswd:/etc/nginx/.htpasswd:ro
|
||||||
- static_data:/usr/share/nginx/html/staticfiles:ro
|
- static_data:/usr/share/nginx/html/static:ro
|
||||||
- media_data:/usr/share/nginx/html/mediafiles:ro
|
- media_data:/usr/share/nginx/html/media:ro
|
||||||
depends_on:
|
depends_on:
|
||||||
- backend
|
- backend
|
||||||
- frontend
|
- frontend
|
||||||
|
|||||||
@@ -37,13 +37,13 @@ server {
|
|||||||
|
|
||||||
# Static and Media files
|
# Static and Media files
|
||||||
location /static/ {
|
location /static/ {
|
||||||
alias /usr/share/nginx/html/staticfiles/;
|
alias /usr/share/nginx/html/static/;
|
||||||
expires 30d;
|
expires 30d;
|
||||||
access_log off;
|
access_log off;
|
||||||
}
|
}
|
||||||
|
|
||||||
location /media/ {
|
location /media/ {
|
||||||
alias /usr/share/nginx/html/mediafiles/;
|
alias /usr/share/nginx/html/media/;
|
||||||
expires 30d;
|
expires 30d;
|
||||||
access_log off;
|
access_log off;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user