Skip to content

Commit 3cbd9b1

Browse files
mihowclaude
andcommitted
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) <noreply@anthropic.com>
1 parent 0a87a3a commit 3cbd9b1

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

  • compose/production/django

compose/production/django/start

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,11 @@ set -o errexit
44
set -o pipefail
55
set -o nounset
66

7-
python /app/manage.py collectstatic --noinput
7+
if [ "${DISABLE_COLLECTSTATIC:-0}" = "1" ]; then
8+
echo "Skipping collectstatic (DISABLE_COLLECTSTATIC=1)"
9+
else
10+
python /app/manage.py collectstatic --noinput
11+
fi
812

913
# Gunicorn natively reads WEB_CONCURRENCY as its --workers default.
1014
# If not set, default to CPU core count.

0 commit comments

Comments
 (0)