Skip to content

Conversation

@mihow
Copy link
Collaborator

@mihow mihow commented Sep 17, 2025

TODO

  • Add video or instructions on how to use this

Summary by CodeRabbit

  • Chores
    • Added new remote debugging configuration for Django with separate debugger setup
    • Enabled conditional debug startup for Django service using remote debugging when activated
    • Added remote debugging port mapping to Docker Compose for local development support

@netlify
Copy link

netlify bot commented Sep 17, 2025

Deploy Preview for antenna-preview canceled.

Name Link
🔨 Latest commit 4f160a4
🔍 Latest deploy log https://app.netlify.com/projects/antenna-preview/deploys/69151f1310b7ce0008421ed9

@mihow mihow marked this pull request as ready for review October 8, 2025 22:28
Copilot AI review requested due to automatic review settings October 8, 2025 22:28
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 enables Python debugging capabilities for the main Django container by configuring debugpy to listen on port 5679. The change allows developers to attach a remote debugger to the Django application running in Docker for improved development experience.

  • Modified Django container startup command to run with debugpy for remote debugging
  • Added port mapping for debugger communication (5679:5679)
  • Created separate VS Code launch configuration for Django debugging

Reviewed Changes

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

File Description
docker-compose.yml Configured Django container to run with debugpy and exposed debugger port
.vscode/launch.json Added Django-specific debugger configuration and renamed existing Celery config

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@mihow mihow requested a review from carlosgjs October 8, 2025 22:49
@mihow
Copy link
Collaborator Author

mihow commented Oct 15, 2025

@mohamedelabbas1996 where did you add your django debugger updates? I know I saw them somewhere!

@mihow
Copy link
Collaborator Author

mihow commented Nov 12, 2025

@carlosgjs Will you review this and also update celeryworker to use the same method?

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Nov 12, 2025

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

This pull request introduces remote debugging support for Django development environments using debugpy. Debug configurations are added to VS Code's launch settings, and the Django startup process is modified to conditionally activate debugpy when DJANGO_DEBUG=1 environment variable is set, exposing port 5679 for remote attachment.

Changes

Cohort / File(s) Summary
Debug Configuration
\.vscode/launch\.json
Renames existing "Python Remote Attach" config to "Python Debugger: Remote Attach (Celery)" on port 5678, and adds new "Python Debugger: Remote Attach (Django)" config on port 5679 with identical path mappings.
Django Startup Scripts
compose/local/django/start, docker-compose\.yml
Replaces direct uvicorn execution with conditional startup: when DJANGO_DEBUG=1, launches Python with debugpy listening on 0.0.0.0:5679 before running uvicorn; otherwise runs uvicorn normally. Exposes debug port 5679 in docker-compose service.

Sequence Diagram(s)

sequenceDiagram
    autonumber
    actor Developer
    participant Docker as Docker Container
    participant Debugpy as debugpy
    participant Uvicorn as Uvicorn/ASGI
    participant VSCode as VS Code Debugger

    Developer->>Docker: Start container with DJANGO_DEBUG=1
    Docker->>Debugpy: Launch Python with debugpy (port 5679)
    activate Debugpy
    Debugpy->>Debugpy: Listen on 0.0.0.0:5679
    Debugpy->>Uvicorn: Start Uvicorn with reload
    activate Uvicorn
    Developer->>VSCode: Attach debugger to localhost:5679
    VSCode->>Debugpy: Connect to debugpy session
    activate VSCode
    Developer->>Uvicorn: Send request
    Uvicorn->>VSCode: Breakpoint hit, control to debugger
    rect rgb(200, 220, 255)
        Note over Developer,VSCode: Debug session active
    end
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~15 minutes

  • Review conditional logic in compose/local/django/start for correctness of environment variable check and debugpy invocation syntax
  • Verify port mappings and debugpy binding address (0.0.0.0) alignment across files
  • Confirm path mappings in VS Code launch configs match container-to-host directory structure

Poem

🐰 A carrot I trace through code so fine,
With debugpy now on port five-six-seven-nine!
Django dreams under moonlit DJANGO_DEBUG glow,
Remote breakpoints dance—watch the logic flow! 🌙✨

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Description check ⚠️ Warning The PR description is largely incomplete and lacks required sections. It only contains a TODO note without providing a summary, detailed explanation, testing instructions, or deployment notes as specified in the template. Complete the description by adding a Summary section explaining the changes, a List of Changes, Related Issues (if any), Detailed Description with testing instructions, and any deployment notes needed.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely summarizes the main change—enabling Python debugger functionality for the Django container, which is the primary objective reflected in all modified files.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat/django-container-debugger

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

@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

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 97a1fc3 and 4f160a4.

📒 Files selected for processing (3)
  • .vscode/launch.json (2 hunks)
  • compose/local/django/start (1 hunks)
  • docker-compose.yml (1 hunks)
⏰ 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 (1)
.vscode/launch.json (1)

1-35: LGTM! Clean separation of debug configurations.

The VS Code launch configurations correctly separate Django (port 5679) and Celery (port 5678) debugging, with consistent pathMappings for both. The naming clearly distinguishes the two services.

Comment on lines +9 to +15
if [ "$DJANGO_DEBUG" = "1" ]; then
echo "Starting Django under debugpy..."
python -m debugpy --listen 0.0.0.0:5679 \
-m uvicorn config.asgi:application \
--host 0.0.0.0 \
--reload \
--reload-include '*.html'
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

Fix variable handling and add exec for proper signal propagation.

Two issues with the debug path:

  1. Missing default value: With set -o nounset (line 5), the script will fail if DJANGO_DEBUG is undefined. Use parameter expansion to provide a default.

  2. Missing exec: The debug branch doesn't use exec (unlike line 18), leaving the shell process alive. This prevents proper signal handling (e.g., SIGTERM won't reach the Python process), causing graceful shutdown issues.

Apply this diff:

-if [ "$DJANGO_DEBUG" = "1" ]; then
+if [ "${DJANGO_DEBUG:-0}" = "1" ]; then
   echo "Starting Django under debugpy..."
-  python -m debugpy --listen 0.0.0.0:5679 \
+  exec python -m debugpy --listen 0.0.0.0:5679 \
     -m uvicorn config.asgi:application \
     --host 0.0.0.0 \
     --reload \
     --reload-include '*.html'
🤖 Prompt for AI Agents
In compose/local/django/start around lines 9 to 15, the debug branch fails under
set -o nounset when DJANGO_DEBUG is undefined and does not use exec so signals
don't propagate to the Python process; update the condition to use parameter
expansion (e.g. ${DJANGO_DEBUG:-0}) to provide a default value and prepend exec
to the python -m debugpy command so the shell is replaced by the Python process
for proper signal handling.

Comment on lines +37 to +38
command: >
python -m debugpy --listen 0.0.0.0:5679 -m uvicorn config.asgi:application --host 0.0.0.0 --reload --reload-include '*.html'
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🔴 Critical

Critical: Command overrides the conditional startup logic in the start script.

The hardcoded command completely bypasses the compose/local/django/start script, which contains conditional logic to enable debugpy only when DJANGO_DEBUG=1. This means:

  • The debugger will always be active, regardless of the DJANGO_DEBUG variable
  • The conditional startup logic in the start script becomes unreachable and useless
  • There's no way to disable debugging without modifying docker-compose.yml

Solution: Remove the command override to allow the start script's conditional logic to work:

-    command: >
-        python -m debugpy --listen 0.0.0.0:5679 -m uvicorn config.asgi:application --host 0.0.0.0 --reload --reload-include '*.html'

Then ensure DJANGO_DEBUG=1 is set in .envs/.local/.django to enable debugging during development, or add it to the environment section:

environment:
  - DJANGO_DEBUG=1
🤖 Prompt for AI Agents
In docker-compose.yml around lines 37-38, the hardcoded command that launches
debugpy/uvicorn overrides the service's start script and forces the debugger on;
remove this command override so the service uses compose/local/django/start
(which contains the DJANGO_DEBUG conditional), and ensure DJANGO_DEBUG is set to
enable debugging when desired (either by adding DJANGO_DEBUG=1 to
.envs/.local/.django or by adding it under the service's environment section).

@mihow
Copy link
Collaborator Author

mihow commented Nov 14, 2025

Closing for #1048 instead. Thanks for your help @mohamedelabbas1996! I kept the env variable flag.

@mihow mihow closed this Nov 14, 2025
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.

3 participants