diff --git a/Dockerfile b/Dockerfile index 86fe039..9e5c7f9 100644 --- a/Dockerfile +++ b/Dockerfile @@ -34,6 +34,7 @@ WORKDIR /app COPY --chown=appuser:appuser . . ENV PYTHONDONTWRITEBYTECODE=1 ENV PYTHONUNBUFFERED=1 +ENV IMAGE_TAG=build USER appuser EXPOSE 8000 RUN rm -rvf /app/Dockerfile* \ diff --git a/argocd/configmap.yaml b/argocd/configmap.yaml index 2a6c28a..85b0152 100644 --- a/argocd/configmap.yaml +++ b/argocd/configmap.yaml @@ -5,7 +5,7 @@ metadata: namespace: labhelper data: DEBUG: "False" - ALLOWED_HOSTS: "labhelper.adebaumann.com" + ALLOWED_HOSTS: "labhelper.adebaumann.com,*" ALLOWED_CIDR_NETS: "10.0.0.0/16" LANGUAGE_CODE: "en-us" TIME_ZONE: "UTC" @@ -18,4 +18,4 @@ data: LOGIN_REDIRECT_URL: "index" LOGOUT_REDIRECT_URL: "login" GUNICORN_OPTS: "--access-logfile -" - IMAGE_TAG: "0.061" \ No newline at end of file + IMAGE_TAG: "0.062" diff --git a/argocd/deployment.yaml b/argocd/deployment.yaml index 2263224..5187d19 100644 --- a/argocd/deployment.yaml +++ b/argocd/deployment.yaml @@ -27,7 +27,7 @@ spec: mountPath: /data containers: - name: web - image: git.baumann.gr/adebaumann/labhelper:0.061 + image: git.baumann.gr/adebaumann/labhelper:0.062 imagePullPolicy: Always ports: - containerPort: 8000 diff --git a/labhelper/settings.py b/labhelper/settings.py index 7297dc8..8ba9855 100644 --- a/labhelper/settings.py +++ b/labhelper/settings.py @@ -47,6 +47,7 @@ INSTALLED_APPS = [ MIDDLEWARE = [ 'django.middleware.security.SecurityMiddleware', + 'whitenoise.middleware.WhiteNoiseMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.common.CommonMiddleware', 'django.middleware.csrf.CsrfViewMiddleware', @@ -124,6 +125,9 @@ USE_TZ = os.environ.get('USE_TZ', 'True').lower() == 'true' STATIC_URL = os.environ.get('STATIC_URL', '/static/') STATIC_ROOT = BASE_DIR / 'staticfiles' +# WhiteNoise static file serving configuration +STATICFILES_STORAGE = 'whitenoise.storage.CompressedManifestStaticFilesStorage' + # Media files (user uploads) MEDIA_URL = os.environ.get('MEDIA_URL', '/media/') MEDIA_ROOT = BASE_DIR / 'data' / 'media' diff --git a/labhelper/urls.py b/labhelper/urls.py index a31e34d..df607b1 100644 --- a/labhelper/urls.py +++ b/labhelper/urls.py @@ -62,5 +62,6 @@ urlpatterns = [ path('admin/', admin.site.urls), ] -urlpatterns += static(settings.STATIC_URL, document_root=settings.STATIC_ROOT) +# Static files are served by WhiteNoise middleware in production +# Media files still need Django serving in all environments urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT) diff --git a/requirements.txt b/requirements.txt index 6572697..16deb09 100644 --- a/requirements.txt +++ b/requirements.txt @@ -36,3 +36,4 @@ Pillow==11.1.0 sorl-thumbnail==12.11.0 bleach==6.1.0 coverage==7.6.1 +whitenoise==6.8.2