Skip to content

fix(start): allow skipping collectstatic via DISABLE_COLLECTSTATIC env var#1237

Open
mihow wants to merge 1 commit intomainfrom
fix/skip-collectstatic-via-env
Open

fix(start): allow skipping collectstatic via DISABLE_COLLECTSTATIC env var#1237
mihow wants to merge 1 commit intomainfrom
fix/skip-collectstatic-via-env

Conversation

@mihow
Copy link
Copy Markdown
Collaborator

@mihow mihow commented Apr 15, 2026

Summary

Adds an opt-in env var (DISABLE_COLLECTSTATIC=1) to skip collectstatic in compose/production/django/start. Default behaviour is unchanged.

Why

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. Because /start runs collectstatic before exec gunicorn, this blocks gunicorn from ever starting and the container appears "up" but nothing listens on port 5000 — producing 502 Bad Gateway responses upstream until the container is killed and recreated.

This was observed in a production deployment after a routine container restart. The container had been running fine for weeks because the previous image had a local modification commenting out the collectstatic line; that modification was lost on the next image rebuild and collectstatic ran against an unreachable backend, hanging at boot.

Behaviour

  • DISABLE_COLLECTSTATIC unset or set to anything other than "1" → unchanged, collectstatic runs as before.
  • DISABLE_COLLECTSTATIC=1 → prints Skipping collectstatic (DISABLE_COLLECTSTATIC=1) and proceeds straight to gunicorn.

Test plan

  • Build the production django image, run with DISABLE_COLLECTSTATIC unset → confirm collectstatic still runs (existing behaviour).
  • Build the production django image, run with DISABLE_COLLECTSTATIC=1 → confirm the skip message logs and gunicorn starts.
  • No change to local/dev start scripts; local development behaviour unchanged.

🤖 Generated with Claude Code

…v 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) <[email protected]>
Copilot AI review requested due to automatic review settings April 15, 2026 20:43
@netlify
Copy link
Copy Markdown

netlify bot commented Apr 15, 2026

Deploy Preview for antenna-preview canceled.

Name Link
🔨 Latest commit 2ea6791
🔍 Latest deploy log https://app.netlify.com/projects/antenna-preview/deploys/69dff8811d8a3c000806a63f

@netlify
Copy link
Copy Markdown

netlify bot commented Apr 15, 2026

Deploy Preview for antenna-ssec canceled.

Name Link
🔨 Latest commit 2ea6791
🔍 Latest deploy log https://app.netlify.com/projects/antenna-ssec/deploys/69dff88180746c000794cd0b

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Apr 15, 2026

Warning

Rate limit exceeded

@mihow has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 46 minutes and 39 seconds before requesting another review.

Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 46 minutes and 39 seconds.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 56121a59-1668-4827-9f57-36382ba4b7b1

📥 Commits

Reviewing files that changed from the base of the PR and between af2f688 and 2ea6791.

📒 Files selected for processing (1)
  • compose/production/django/start
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/skip-collectstatic-via-env

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds an opt-in toggle to the production Django container start script so deployments that don’t need Django static collection (or have an unreachable staticfiles backend) can avoid blocking container boot.

Changes:

  • Gate python /app/manage.py collectstatic --noinput behind DISABLE_COLLECTSTATIC=1.
  • Log an explicit “Skipping collectstatic …” message when the skip is enabled.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants