From dee00a514a2bd18286155f421479f7405d1e7209 Mon Sep 17 00:00:00 2001 From: w Date: Wed, 13 Nov 2024 00:02:07 +0100 Subject: [PATCH] serve static files in production --- Dockerfile | 2 +- app/moneropro/settings.py | 6 +++--- app/moneropro/urls.py | 4 ++++ 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/Dockerfile b/Dockerfile index fd58222..34dc96b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -18,4 +18,4 @@ COPY app/ app/ WORKDIR /src/app -CMD ["python", "manage.py", "runserver", "0.0.0.0:8000"] +CMD ["gunicorn", "moneropro.wsgi:application", "--bind", "0.0.0.0:8000"] diff --git a/app/moneropro/settings.py b/app/moneropro/settings.py index 7059ffc..24a1cdf 100644 --- a/app/moneropro/settings.py +++ b/app/moneropro/settings.py @@ -21,11 +21,11 @@ BASE_DIR = Path(__file__).resolve().parent.parent #Comment for Local: DEBUG = False -#STATIC_ROOT = os.path.join(BASE_DIR, 'static') +STATIC_ROOT = os.path.join(BASE_DIR, 'static') #Comment for deploy: -DEBUG = True -STATICFILES_DIRS = [os.path.join(BASE_DIR, "static"),] +#DEBUG = True +#STATICFILES_DIRS = [os.path.join(BASE_DIR, "static"),] STATIC_URL = '/static/' LOCALE_PATHS = ( diff --git a/app/moneropro/urls.py b/app/moneropro/urls.py index 074d7b8..bdc03bf 100644 --- a/app/moneropro/urls.py +++ b/app/moneropro/urls.py @@ -18,7 +18,11 @@ from django.contrib import admin from django.urls import path from charts import views +from django.conf import settings +from django.views.static import serve + urlpatterns = [ path('admin/', admin.site.urls), url(r'', include(('charts.urls', 'charts'), namespace='charts')), + url(r'^static/(?P.*)$', serve,{'document_root': settings.STATIC_ROOT}) ]