Skip to content

Commit

Permalink
build: configure media file for django & nginx
Browse files Browse the repository at this point in the history
  • Loading branch information
Asiberus committed Oct 23, 2022
1 parent 4e06f6b commit f68cfd4
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 20 deletions.
7 changes: 4 additions & 3 deletions .conf/development/back/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,14 @@ ENV PATH="/scripts:$PATH"

COPY ./back/requirements.txt .

RUN apk add --update --no-cache postgresql-client && \
RUN apk add --update --no-cache postgresql-client zlib-dev jpeg-dev libwebp-dev && \
apk add --update --no-cache --virtual .tmp-deps \
build-base postgresql-dev musl-dev linux-headers && \
build-base postgresql-dev musl-dev linux-headers && \
pip install -r requirements.txt && \
apk del .tmp-deps && \
adduser --disabled-password --no-create-home back && \
mkdir /static && \
mkdir -p /vol/static && \
mkdir -p /vol/media && \
chmod -R +x /scripts

COPY ./back .
Expand Down
4 changes: 4 additions & 0 deletions .conf/development/nginx/default.conf.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ server {
alias /vol/static;
}

location /media {
alias /vol/media;
}

location / {
proxy_pass http://${BACKEND_NAME}:${BACKEND_PORT};
proxy_redirect off;
Expand Down
5 changes: 4 additions & 1 deletion back/back/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,4 +168,7 @@
# https://docs.djangoproject.com/en/4.1/howto/static-files/

STATIC_URL = '/static/'
STATIC_ROOT = '/static'
STATIC_ROOT = '/vol/static'

MEDIA_URL = '/media/'
MEDIA_ROOT = '/vol/media'
11 changes: 6 additions & 5 deletions back/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
Django==4.1
Django==4.1.2
django-cors-headers==3.13.0
djangorestframework==3.12.4
pytz==2022.2.1
django-filter==2.4.0
django_extensions==3.1.3
djangorestframework==3.14.0
pytz==2022.5
django-filter==22.1
django_extensions==3.2.1
django-mailjet
Pillow==9.2.0
psycopg2>=2.8.6,<2.8.7
uWSGI>=2.0.19.1,<2.1
28 changes: 17 additions & 11 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ services:
BACKEND_PORT: ${BACKEND_PORT}
volumes:
- ./static:/vol/static
- beer_crackerz_media:/vol/media
depends_on:
- backend
backend:
container_name: ${BACKEND_NAME}
build:
Expand All @@ -35,6 +38,7 @@ services:
MAILJET_API_SECRET: ${MAILJET_API_SECRET}
volumes:
- ./back:/back
- beer_crackerz_media:/vol/media
depends_on:
- db
db:
Expand All @@ -48,17 +52,17 @@ services:
- ${DB_PORT}:${DB_CONTAINER_PORT}
volumes:
- beer_crakerz_db:/var/lib/postgresql/data
# email:
# image: juanluisbaptiste/postfix:alpine
# container_name: ${EMAIL_HOST}
# expose:
# - ${EMAIL_PORT}
# environment:
# SMTP_SERVER: ${EMAIL_HOST}
# SMTP_PORT: ${EMAIL_PORT}
## SMTP_USERNAME: ${EMAIL_USERNAME}
## SMTP_PASSWORD: ${EMAIL_PASSWORD}
# SERVER_HOSTNAME: ${EMAIL_HOST}
# email:
# image: juanluisbaptiste/postfix:alpine
# container_name: ${EMAIL_HOST}
# expose:
# - ${EMAIL_PORT}
# environment:
# SMTP_SERVER: ${EMAIL_HOST}
# SMTP_PORT: ${EMAIL_PORT}
## SMTP_USERNAME: ${EMAIL_USERNAME}
## SMTP_PASSWORD: ${EMAIL_PASSWORD}
# SERVER_HOSTNAME: ${EMAIL_HOST}
adminer:
container_name: ${DB_ADMINER_NAME}
image: adminer
Expand All @@ -67,3 +71,5 @@ services:
volumes:
beer_crakerz_db:
name: beer_crakerz_db
beer_crackerz_media:
name: beer_crackerz_media

0 comments on commit f68cfd4

Please sign in to comment.