generated from bisco/codex-bootstrap
fix(docker): serve django static files via nginx
This commit is contained in:
@@ -112,7 +112,8 @@ DEFAULT_FROM_EMAIL = os.environ.get("DEFAULT_FROM_EMAIL", "no-reply@azionelab.lo
|
||||
if "test" in sys.argv:
|
||||
EMAIL_BACKEND = "django.core.mail.backends.locmem.EmailBackend"
|
||||
|
||||
STATIC_URL = "static/"
|
||||
STATIC_URL = "/static/"
|
||||
STATIC_ROOT = BASE_DIR / "staticfiles"
|
||||
DEFAULT_AUTO_FIELD = "django.db.models.BigAutoField"
|
||||
|
||||
REST_FRAMEWORK = {
|
||||
|
||||
@@ -19,11 +19,14 @@ services:
|
||||
POSTGRES_PORT: ${POSTGRES_PORT:-5432}
|
||||
expose:
|
||||
- "${BACKEND_PORT:-8000}"
|
||||
volumes:
|
||||
- django_static:/app/staticfiles
|
||||
depends_on:
|
||||
postgres:
|
||||
condition: service_healthy
|
||||
networks:
|
||||
- internal
|
||||
user: "0:0"
|
||||
restart: unless-stopped
|
||||
|
||||
frontend:
|
||||
@@ -66,6 +69,7 @@ services:
|
||||
NGINX_ENVSUBST_FILTER: "^(BACKEND_HOST|BACKEND_PORT|FRONTEND_HOST|FRONTEND_PORT)$"
|
||||
volumes:
|
||||
- ./nginx/templates:/etc/nginx/templates:ro
|
||||
- django_static:/var/www/static:ro
|
||||
depends_on:
|
||||
- backend
|
||||
- frontend
|
||||
@@ -75,6 +79,7 @@ services:
|
||||
|
||||
volumes:
|
||||
postgres_data:
|
||||
django_static:
|
||||
|
||||
networks:
|
||||
internal:
|
||||
|
||||
@@ -29,9 +29,9 @@ server {
|
||||
}
|
||||
|
||||
location /static/ {
|
||||
proxy_pass http://azionelab_backend;
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Forwarded-Proto $scheme;
|
||||
alias /var/www/static/;
|
||||
access_log off;
|
||||
expires 1d;
|
||||
}
|
||||
|
||||
location /media/ {
|
||||
|
||||
Reference in New Issue
Block a user