diff --git a/api/Dockerfile b/api/Dockerfile index 68006914112..a073e03571a 100644 --- a/api/Dockerfile +++ b/api/Dockerfile @@ -101,7 +101,6 @@ COPY --chown=opener . /api/ # Collect static assets, these are used by the next stage, `nginx` RUN env \ SETUP_ES="False" \ - STATIC_ROOT="/static" \ DJANGO_SECRET_KEY="any string" \ python manage.py collectstatic diff --git a/api/conf/settings/static.py b/api/conf/settings/static.py index 3c275632292..a04fe955064 100644 --- a/api/conf/settings/static.py +++ b/api/conf/settings/static.py @@ -5,6 +5,6 @@ # https://docs.djangoproject.com/en/4.2/howto/static-files/ # Where to collect static files in production/development deployments -STATIC_ROOT = config("STATIC_ROOT", default="/var/api_static_content/static") +STATIC_ROOT = config("STATIC_ROOT", default="/static") STATIC_URL = "static/" diff --git a/api/conf/urls/__init__.py b/api/conf/urls/__init__.py index 76e5d5d2bb6..432bc5aa8f9 100644 --- a/api/conf/urls/__init__.py +++ b/api/conf/urls/__init__.py @@ -4,7 +4,8 @@ For more information on this file, see https://docs.djangoproject.com/en/4.2/topics/http/urls/ """ - +from django.conf import settings +from django.conf.urls.static import static from django.contrib import admin from django.urls import include, path from django.views.generic import RedirectView @@ -35,3 +36,6 @@ path("healthcheck/", HealthCheck.as_view(), name="health"), path("v1/", include(versioned_paths)), ] + +if settings.ENVIRONMENT == "local": + urlpatterns += static(settings.STATIC_URL, document_root=settings.STATIC_ROOT) diff --git a/api/env.docker b/api/env.docker index fce8ad7f460..c13c36a0401 100644 --- a/api/env.docker +++ b/api/env.docker @@ -5,7 +5,7 @@ DJANGO_SECRET_KEY="ny#b__$$f6ry4wy8oxre97&-68u_0lk3gw(z=d40_dxey3zw0v1" DJANGO_DEBUG_ENABLED=True BASE_URL=http://localhost:50280/ -ENVIRONMENT=development +ENVIRONMENT=local ALLOWED_HOSTS=api.openverse.engineering,api-dev.openverse.engineering,host.docker.internal REDIS_HOST=cache diff --git a/docker-compose.yml b/docker-compose.yml index 709d78a42dc..1c226b6cf40 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -234,12 +234,9 @@ services: env_file: - api/env.docker - api/.env - environment: - STATIC_ROOT: ${STATIC_ROOT:-} - MEDIA_ROOT: ${MEDIA_ROOT:-} stdin_open: true tty: true - command: python manage.py runserver 0.0.0.0:8000 + command: gunicorn --reload -w 1 ingestion_server: profiles: