Handle media files.

This commit is contained in:
jmsgrogan 2024-02-18 14:25:20 +00:00
parent 9576202fa1
commit 2b9dbcbb2d
4 changed files with 15 additions and 1 deletions

View file

@ -7,6 +7,7 @@ services:
volumes: volumes:
- ./wedding_site/:/usr/src/app/ - ./wedding_site/:/usr/src/app/
- static_volume:/staticfiles - static_volume:/staticfiles
- media_volume:/mediafiles
expose: expose:
- 8000 - 8000
env_file: env_file:
@ -18,8 +19,10 @@ services:
- 8080:80 - 8080:80
volumes: volumes:
- static_volume:/staticfiles - static_volume:/staticfiles
- media_volume:/mediafiles
depends_on: depends_on:
- web - web
volumes: volumes:
static_volume: static_volume:
media_volume:

View file

@ -11,10 +11,15 @@ server {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $host; proxy_set_header Host $host;
proxy_redirect off; proxy_redirect off;
client_max_body_size 100M;
} }
location /static/ { location /static/ {
alias /staticfiles/; alias /staticfiles/;
} }
location /media/ {
alias /mediafiles/;
}
} }

View file

@ -11,6 +11,9 @@ COPY ./requirements.txt .
RUN pip install -r requirements.txt RUN pip install -r requirements.txt
RUN mkdir staticfiles RUN mkdir staticfiles
RUN mkdir mediafiles
ADD ./uploads /mediafiles
# copy project # copy project
COPY . . COPY . .

View file

@ -118,6 +118,9 @@ USE_TZ = True
STATIC_URL = 'static/' STATIC_URL = 'static/'
STATIC_ROOT = BASE_DIR / "staticfiles" STATIC_ROOT = BASE_DIR / "staticfiles"
MEDIA_URL = 'media/'
MEDIA_ROOT = BASE_DIR / "mediafiles"
# Default primary key field type # Default primary key field type
# https://docs.djangoproject.com/en/5.0/ref/settings/#default-auto-field # https://docs.djangoproject.com/en/5.0/ref/settings/#default-auto-field