Openverse is a search engine for openly-licensed media. This monorepo includes all application code.
Switch local API dev server to use gunicorn instead of django runserver (#2936)
Ashir Amin6408b4234241
diff --git a/api/Dockerfile b/api/Dockerfileindex 680069141..a073e0357 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 collectstaticdiff --git a/api/conf/settings/static.py b/api/conf/settings/static.pyindex 3c2756322..a04fe9550 100644--- a/api/conf/settings/static.py+++ b/api/conf/settings/static.py@@ -5,6 +5,6 @@ from decouple import config# 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__.pyindex 76e5d5d2b..432bc5aa8 100644--- a/api/conf/urls/__init__.py+++ b/api/conf/urls/__init__.py@@ -4,7 +4,8 @@ URL configuration for the Openverse API.For more information on this file, seehttps://docs.djangoproject.com/en/4.2/topics/http/urls/"""-+from django.conf import settings+from django.conf.urls.static import staticfrom django.contrib import adminfrom django.urls import include, pathfrom django.views.generic import RedirectView@@ -35,3 +36,6 @@ urlpatterns = [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.dockerindex fce8ad7f4..c13c36a04 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=TrueBASE_URL=http://localhost:50280/-ENVIRONMENT=development+ENVIRONMENT=localALLOWED_HOSTS=api.openverse.engineering,api-dev.openverse.engineering,host.docker.internalREDIS_HOST=cachediff --git a/docker-compose.yml b/docker-compose.ymlindex 709d78a42..1c226b6cf 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: truetty: true- command: python manage.py runserver 0.0.0.0:8000+ command: gunicorn --reload -w 1ingestion_server:profiles: