From 2ea679159d223e636e987a594810a84da39ea86a Mon Sep 17 00:00:00 2001 From: Michael Bunsen Date: Wed, 15 Apr 2026 13:43:20 -0700 Subject: [PATCH] fix(start): allow skipping collectstatic via DISABLE_COLLECTSTATIC env var Deployments that serve static files from an external CDN (e.g. Netlify) do not need Django's `collectstatic` to run on container boot. When the configured `STATICFILES_STORAGE` backend is unreachable, `collectstatic` can hang indefinitely on a network call, blocking gunicorn from starting and causing 502 Bad Gateway responses upstream until the container is killed and recreated. This adds an opt-in env var (`DISABLE_COLLECTSTATIC=1`) that skips the step entirely in `compose/production/django/start`. Default behaviour (running `collectstatic`) is unchanged. Co-Authored-By: Claude Opus 4.6 (1M context) --- compose/production/django/start | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/compose/production/django/start b/compose/production/django/start index 5a772895a..636f6bf19 100644 --- a/compose/production/django/start +++ b/compose/production/django/start @@ -4,7 +4,11 @@ set -o errexit set -o pipefail set -o nounset -python /app/manage.py collectstatic --noinput +if [ "${DISABLE_COLLECTSTATIC:-0}" = "1" ]; then + echo "Skipping collectstatic (DISABLE_COLLECTSTATIC=1)" +else + python /app/manage.py collectstatic --noinput +fi # Gunicorn natively reads WEB_CONCURRENCY as its --workers default. # If not set, default to CPU core count.