Skip to content

Conversation

@mihow
Copy link
Collaborator

@mihow mihow commented Nov 14, 2025

Summary

Clean up the docker-compose start command & how we enable the VS Code debugger for both Celery workers & the main Django app.

List of Changes

  • Update docker-compose.yml to use /start-celeryworker script instead of a duplicated inline command
  • Add a docker-compose.override.yml.example showing how to enable debuggers
  • Add debugger config for main Django app in addition to Celery workers
  • Update docs & Claude Agent instructions

Related Issues

The debugger has been partially added in multiple PRs. This one full replaces #953 and will replace part of what's in #1034 & #1041

Detailed Description

Use docker-compose override file pattern for enabling remote debugging with debugpy in VS Code. Supports debugging the main Django app and Celery workers independently or simultaneously.

How to Test the Changes

cp docker-compose.override.yml.example docker-compose.override.yml
docker compose up -f

Open on the debugger panel in VS Code
Choose the "Attach: Django + Celery" launch config & press Play
Set a breakpoint in a celery task or django function

Screenshots

image image image

Deployment Notes

Relevant to local dev only

Checklist

  • I have tested these changes appropriately.
  • I have added and/or modified relevant tests.
  • I updated relevant documentation or comments.
  • I have verified that this PR follows the project's coding standards.
  • Any dependent changes have already been merged to main.

Summary by CodeRabbit

  • New Features

    • Added Visual Studio Code remote debugging support for Django and Celery with combined attach sessions.
  • Documentation

    • Added "Debugging with VS Code" guidance in project docs and README covering setup, attach options, usage, troubleshooting, and disable steps.
  • Chores

    • Added example local override for enabling debugging and updated ignore rules to exclude local override files.

Use docker-compose override file pattern for enabling remote debugging
with debugpy in VS Code. Supports debugging the main Django app and
Celery workers independently or simultaneously.

Changes:
- Update docker-compose.yml to use /start-celeryworker script
- Add docker-compose.override.yml.example to enable debuggers
- Update start scripts to look for DEBUGGER environment variable
- Add debugger config for main Django app in addition to Celery workers
Copilot AI review requested due to automatic review settings November 14, 2025 01:06
@netlify
Copy link

netlify bot commented Nov 14, 2025

Deploy Preview for antenna-preview canceled.

Name Link
🔨 Latest commit 5c37f03
🔍 Latest deploy log https://app.netlify.com/projects/antenna-preview/deploys/6916990cdb37fd000872ae7d

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Nov 14, 2025

Caution

Review failed

The pull request is closed.

Note

Other AI code review bot(s) detected

CodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review.

Walkthrough

Adds local VS Code remote-debugging for Django and Celery using debugpy: documentation and README updates, new VS Code launch configurations, an example docker-compose.override enabling DEBUGGER=1 with port mappings and mounted start scripts, and debug-aware conditional start scripts.

Changes

Cohort / File(s) Summary
Documentation & Guides
.agents/AGENTS.md, README.md
Added "Debugging with VS Code" guidance: one-time override copy, start procedure (docker compose up), attach options (Django, Celeryworker, or both), DEBUGGER behavior, disable steps, and quick refs.
VS Code Launch Config
.vscode/launch.json
Added Attach: Django (port 5678) and Attach: Celeryworker (port 5679) configurations and a compound Attach: Django + Celery grouping them; adjusted pathMapping/remoteRoot and justMyCode settings.
Docker Compose & Override
docker-compose.yml, docker-compose.override-example.yml
Removed embedded debugpy command from main compose; added override example that sets DEBUGGER=1, exposes ports 5678/5679, and mounts start scripts to enable debugging without rebuilding images.
Start Scripts (runtime behavior)
compose/local/django/start, compose/local/django/celery/worker/start
Added set -o pipefail; introduced conditional branching on DEBUGGER to run services under debugpy (Django -> 5678, Celery -> 5679) when enabled; preserved non-debug behavior (uvicorn with reload, watchfiles-based Celery) otherwise.
Dev ignores
.gitignore
Added docker-compose.override.yml to ignore list with a comment advising local-use override files be ignored.

Sequence Diagram(s)

sequenceDiagram
    participant Dev as Developer
    participant Docker as Docker Compose
    participant Django as Django Container
    participant Celery as Celery Container
    participant VSCode as VS Code (debugger)

    Dev->>Docker: docker compose up (with override)
    Docker->>Docker: set DEBUGGER=1 (from override)
    alt DEBUGGER=1
        Docker->>Django: run /start -> debugpy listen 5678
        Docker->>Celery: run /start-celeryworker -> debugpy listen 5679
    else DEBUGGER!=1
        Docker->>Django: run normal uvicorn (reload)
        Docker->>Celery: run normal Celery worker
    end

    Dev->>VSCode: Launch "Attach: Django + Celery" (or individual attaches)
    VSCode->>Django: attach to localhost:5678
    VSCode->>Celery: attach to localhost:5679
    note right of VSCode: breakpoints and inspection via debugpy
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

  • Inspect conditional debug branches in compose/local/django/start and compose/local/django/celery/worker/start for correct debugpy invocation, quoting, and signal forwarding.
  • Verify docker-compose.override-example.yml volume mounts and port mappings align with container paths and the start scripts (/start, /start-celeryworker).
  • Check .vscode/launch.json pathMapping/remoteRoot and justMyCode settings match repository/workspace layout.

Possibly related PRs

Poem

🐰 I hopped into code at night,
Ports aligned, debug lights bright,
5678 and 5679 hum,
VS Code listens — breakpoints come,
A rabbit cheers: happy debugging!

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely summarizes the main change: improving debugging support for Django and Celery with updated configurations.
Description check ✅ Passed The description is well-structured, includes summary, list of changes, related issues, detailed explanation, testing instructions with examples, screenshots, deployment notes, and a completed checklist aligned with the template.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 7bf6582 and 5c37f03.

📒 Files selected for processing (1)
  • docker-compose.override-example.yml (1 hunks)

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
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

This PR improves the debugging experience for local development by introducing a clean docker-compose override pattern to enable debugpy for Django and Celery services. The change removes hardcoded debugging configuration from docker-compose.yml and makes it opt-in through a git-ignored override file.

Key changes:

  • Introduced docker-compose.override.yml.example with debugger configuration
  • Updated start scripts to conditionally enable debugpy based on DEBUGGER environment variable
  • Added comprehensive VS Code launch configurations for debugging Django and Celery independently or together

Reviewed Changes

Copilot reviewed 7 out of 8 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
docker-compose.yml Removed hardcoded debugpy configuration from celeryworker service, replaced with standard /start-celeryworker script
docker-compose.override.yml.example New file providing opt-in debugger configuration with DEBUGGER=1 environment variable and port mappings
compose/local/django/start Added conditional debugpy support based on DEBUGGER environment variable
compose/local/django/celery/worker/start Added conditional debugpy support based on DEBUGGER environment variable
.vscode/launch.json Added individual and compound debug configurations for Django and Celery
README.md Added comprehensive debugging setup, usage, and troubleshooting documentation
.agents/AGENTS.md Added debugging section for Claude Agent with implementation details
.gitignore Added docker-compose.override.yml to git-ignore list

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

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

♻️ Duplicate comments (2)
compose/local/django/celery/worker/start (2)

3-5: Past review feedback addressed.

The set -o pipefail has been added as suggested in the previous review, improving error handling for piped commands.


8-8: Past review feedback addressed.

The comment about auto-reload being disabled during debugging addresses the concern raised in the previous review about documenting this behavioral difference.

🧹 Nitpick comments (4)
compose/local/django/start (1)

12-12: Consider making uvicorn port explicit in debug mode.

The debug command doesn't specify an explicit port for uvicorn (will default to 8000). While this matches the default behavior, making it explicit would improve clarity and consistency with the non-debug path.

Apply this diff to make the port explicit:

-    exec python -Xfrozen_modules=off -m debugpy --listen 0.0.0.0:5678 -m uvicorn config.asgi:application --host 0.0.0.0
+    exec python -Xfrozen_modules=off -m debugpy --listen 0.0.0.0:5678 -m uvicorn config.asgi:application --host 0.0.0.0 --port 8000
README.md (1)

270-273: Note: Symlink approach has trade-offs.

The documentation offers ln -s as an alternative to cp. While valid, a symlink means local changes to docker-compose.override.yml would affect the tracked example file if the link is reversed, and updates to the example file automatically apply to the override. The cp approach is safer for most users as it creates an independent file.

Consider adding a note about the difference:

 1. Copy or link the override example file:
    ```bash
    cp docker-compose.override-example.yml docker-compose.override.yml
-   # OR
+   # OR use symlink (changes to example file will auto-apply)
    ln -s docker-compose.override-example.yml docker-compose.override.yml
    ```
compose/local/django/celery/worker/start (1)

9-10: Consider adding -Xfrozen_modules=off flag for consistency.

The Django start script uses -Xfrozen_modules=off when launching with debugpy (Line 12 in compose/local/django/start), but the Celery worker script doesn't include this flag. For consistency and to ensure the same debugging experience, consider adding it here as well.

Apply this diff:

-    exec watchfiles --filter python 'python -m debugpy --listen 0.0.0.0:5679 -m celery -A config.celery_app worker -l INFO'
+    exec watchfiles --filter python 'python -Xfrozen_modules=off -m debugpy --listen 0.0.0.0:5679 -m celery -A config.celery_app worker -l INFO'
.vscode/launch.json (1)

43-57: Consider removing redundant debug configuration.

The existing "Python Debugger: Remote Attach" configuration (Lines 43-57) appears redundant with the new "Attach: Django" configuration (Lines 11-26), as both attach to port 5678. The key difference is the remoteRoot path ("." vs "/app"). If the new configuration with "/app" is correct, consider removing the old one to avoid confusion.

If the remoteRoot verification confirms /app is correct, remove the redundant configuration:

         },
-        {
-            "name": "Python Debugger: Remote Attach",
-            "type": "debugpy",
-            "request": "attach",
-            "connect": {
-                "host": "localhost",
-                "port": 5678
-            },
-            "pathMappings": [
-                {
-                    "localRoot": "${workspaceFolder}",
-                    "remoteRoot": "."
-                }
-            ]
-        }
     ]
 }

Alternatively, if both path mappings are needed for different scenarios, consider renaming the old configuration to clarify when each should be used.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 1d80beb and 160a24d.

📒 Files selected for processing (7)
  • .agents/AGENTS.md (1 hunks)
  • .vscode/launch.json (1 hunks)
  • README.md (1 hunks)
  • compose/local/django/celery/worker/start (1 hunks)
  • compose/local/django/start (1 hunks)
  • docker-compose.override-example.yml (1 hunks)
  • docker-compose.yml (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • docker-compose.yml
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: test
🔇 Additional comments (7)
compose/local/django/start (2)

7-8: Inconsistent summary - but code is correct.

The AI summary states that the migrate step was removed, but Line 7 shows python manage.py migrate is still present. Keeping the migration step is the correct approach, as it ensures the database schema is up-to-date before starting the server.


11-12: ****

The raised concerns are not valid. Verification confirms:

  • debugpy is already listed in requirements/local.txt with an explicit comment for remote debugging
  • Python 3.11.11 is configured in the Dockerfile, which supports the -Xfrozen_modules=off flag

The implementation is correct and requires no changes.

Likely an incorrect or invalid review comment.

README.md (1)

262-307: Comprehensive debugging documentation.

The debugging section is well-structured with clear setup instructions, usage guidance, troubleshooting tips, and disable procedures. Port numbers, commands, and configuration names are all consistent with the implementation.

docker-compose.override-example.yml (1)

1-30: Well-structured override example.

The override file is clean and well-documented, with clear setup instructions and consistent port mappings (5678 for Django, 5679 for Celery) that align with the start scripts and VS Code configuration.

.agents/AGENTS.md (1)

69-96: Consistent debugging documentation for agents.

The debugging section provides clear guidance for Claude agents working with the codebase. The content is consistent with README.md, port numbers align with the implementation, and the technical explanation is accurate.

.vscode/launch.json (1)

3-9: Well-structured compound configuration.

The compound configuration correctly references both debug configurations by name and uses stopAll: true to ensure all debuggers stop together, which provides a better debugging experience.

compose/local/django/celery/worker/start (1)

9-10: No action required—debugpy is already available in the Celery worker image.

The Dockerfile installs dependencies from requirements/local.txt, which already includes debugpy as an explicit dependency. Since both the django and celeryworker services inherit from the same docker anchor and use the same Dockerfile, debugpy is installed in both images during the build process. The code at lines 9-10 will not fail due to missing debugpy.

@mihow mihow merged commit ba88814 into main Nov 14, 2025
6 of 7 checks passed
@mihow mihow deleted the feat/debugger-setup branch November 14, 2025 02:52
@coderabbitai coderabbitai bot mentioned this pull request Nov 14, 2025
5 tasks
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