Integrate VSCode debugger into app #678
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
**** Please include a summary of the change and which issue is fixed. Please also include relevant motivation and context. List any dependencies that are required for this change. ****
This PR enables VSCode's native debugger to optionally be used with the web application. It installs debugpy, which implements the Debug Adapter Protocol, used by VSCode and other IDEs (but not PyCharm, apparently). The Docker container now exposes port 5678, which the IDE uses to talk to it.
Currently, only the
webcontainer has been augmented. The same can be done for the other containers if this approach is viable. EDIT: This has not been tested, but the other containers would need to have their debuggers listen on other ports (e.g., 5679, 5680), and then two new entries would have to be added to theconfigurationskey inlaunch.json.Also, a number of images were identical to the
app-baseimage, with the only difference being that they specifiedCMDin theirDockerfiles. They have been removed in favor of specifyingcommandindocker-compose.yml. Thewebservice's command is a script that conditionally listens for a debugger only ifDEBUGPY=1is set.Type of change
**** Please delete options that are not relevant. ****
How Has This Been Tested?
**** Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration. ****
launch.jsonto the.vscodefolder:Rebuild
app-baseand child images so thatdebugpyis installed.Set
export DEBUGPY=1in the environment before bringing up Docker Compose.Open the debugger in the left panel of VSCode. Select "Attach to Docker Django" if necessary. Click on the play button to start the web server and debugging process.
Set a breakpoint (e.g., in
coldfront.core.user.views.UserProfile.get_context_data). Navigate to that page on the host (using the existing port 8080 or 8081), observe that execution stops, and observe that variable contents are displayed in VSCode.See the updated Docker
README.mdfor the same instructions.PR Self Evaluation
Strikethrough things that don’t make sense for your PR.