Skip to content

Optimize container startup#3563

Open
sainak wants to merge 1 commit intodevelopfrom
sainak/optimize-container-startup
Open

Optimize container startup#3563
sainak wants to merge 1 commit intodevelopfrom
sainak/optimize-container-startup

Conversation

@sainak
Copy link
Member

@sainak sainak commented Mar 7, 2026

Proposed Changes

  • Run collectstatic and compilemessages management commands during build
  • Added config var to specify number of gunicorn workers

Merge Checklist

  • Tests added/fixed
  • Update docs in /docs
  • Linting Complete
  • Any other necessary step

Only PR's with test cases included and passing lint and test pipelines will be reviewed

@ohcnetwork/care-backend-maintainers @ohcnetwork/care-backend-admins

Summary by CodeRabbit

  • New Features

    • Added GUNICORN_WORKERS environment variable, allowing configuration of application server worker count to optimize resource usage (default: 2).
  • Chores

    • Updated Docker health check configuration with adjusted timeout and retry parameters.
    • Optimized deployment startup process for improved initialization efficiency.

@sainak sainak requested a review from a team as a code owner March 7, 2026 19:53
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 7, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 43a7723a-406d-4eb2-b15c-0846fd9cb6b3

📥 Commits

Reviewing files that changed from the base of the PR and between d2a2c2f and cafd311.

📒 Files selected for processing (4)
  • docker/prod.Dockerfile
  • scripts/celery_beat.sh
  • scripts/celery_worker.sh
  • scripts/start.sh
💤 Files with no reviewable changes (2)
  • scripts/celery_worker.sh
  • scripts/celery_beat.sh

📝 Walkthrough

Walkthrough

Consolidates Django asset collection and message compilation into the Docker build phase by adding these operations to prod.Dockerfile and removing them from startup scripts. Introduces configurable Gunicorn worker count and adjusts container health check parameters.

Changes

Cohort / File(s) Summary
Docker Build Configuration
docker/prod.Dockerfile
Added RUN step to execute collectstatic --noinput and compilemessages during image build. Updated HEALTHCHECK timeout (5s → 3s), start-period (10s → 5s), and retries (12 → 20).
Runtime Startup Scripts
scripts/celery_beat.sh, scripts/celery_worker.sh, scripts/start.sh
Removed collectstatic and compilemessages commands from runtime execution paths. Introduced GUNICORN_WORKERS environment variable with default value of 2 in start.sh.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title directly reflects the main objective of the PR: optimizing container startup by moving asset compilation to build time and adding configurable worker counts.
Description check ✅ Passed The description covers the proposed changes and includes the merge checklist, though it lacks the 'Associated Issue' section and any architectural rationale for the optimizations.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch sainak/optimize-container-startup

Tip

Try Coding Plans. Let us write the prompt for your AI agent so you can ship faster (with fewer bugs).
Share your feedback on Discord.


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

@codecov
Copy link

codecov bot commented Mar 7, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 76.22%. Comparing base (d2a2c2f) to head (cafd311).

Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #3563      +/-   ##
===========================================
- Coverage    76.22%   76.22%   -0.01%     
===========================================
  Files          474      474              
  Lines        22262    22262              
  Branches      2324     2324              
===========================================
- Hits         16970    16969       -1     
  Misses        4764     4764              
- Partials       528      529       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

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.

1 participant