Setup nginx for django static

This commit is contained in:
IRBorisov 2023-08-08 18:14:30 +03:00
parent 8e2b91402f
commit 2c6038116a
4 changed files with 7 additions and 20 deletions

View File

@ -26,7 +26,6 @@ services:
restart: always
depends_on:
- postgresql-db
- nginx
build:
context: ./rsconcept/backend
env_file: ./rsconcept/backend/.env.dev
@ -46,15 +45,3 @@ services:
volumes:
- postgres_volume:/var/lib/postgresql/data
nginx:
restart: always
build:
context: ./nginx
ports:
- 1337:80
command: "/bin/sh -c 'while :; do sleep 6h & wait $${!}; nginx -s reload; done & nginx -g \"daemon off;\"'"
volumes:
- django_static_volume:/var/www/static
- django_media_volume:/var/www/media

View File

@ -32,7 +32,6 @@ services:
restart: always
depends_on:
- postgresql-db
- nginx
secrets:
- db_password
- django_key
@ -42,8 +41,8 @@ services:
environment:
SECRET_KEY: /run/secrets/django_key
DB_PASSWORD: /run/secrets/db_password
ports:
- 8000:8000
expose:
- 8000
volumes:
- django_static_volume:/home/app/web/static
- django_media_volume:/home/app/web/media
@ -68,7 +67,9 @@ services:
build:
context: ./nginx
ports:
- 1337:80
- 8000:80
depends_on:
- backend
command: "/bin/sh -c 'while :; do sleep 6h & wait $${!}; nginx -s reload; done & nginx -g \"daemon off;\"'"
volumes:
- django_static_volume:/var/www/static

View File

@ -1,12 +1,12 @@
upstream innerdjango {
server back:8000;
server backend:8000;
# `backend` is the service's name in docker-compose.yml,
# The `innerdjango` is the name of upstream, used by nginx below.
}
server {
listen 80;
server_name localhost dev.concept.ru www.dev.concept.ru portal.acconcept.ru www.portal.acconcept.ru;
server_name dev.concept.ru www.dev.concept.ru portal.acconcept.ru www.portal.acconcept.ru;
location / {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $host;

View File

@ -13,7 +13,6 @@ fi
cd $APP_HOME
python $APP_HOME/manage.py collectstatic --noinput --clear
python $APP_HOME/manage.py makemigrations
python $APP_HOME/manage.py migrate
# Execute given input command