Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding automatic docker container build in vscode launch config of remote docker debugging #10

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions remote-debugging-docker/.vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,19 @@
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Build and Attach (Remote Debug)",
"type": "python",
"request": "attach",
"port": 3000,
"host": "localhost",
"pathMappings": [
{"localRoot": "${workspaceFolder}", "remoteRoot": "/src/"}
],
"redirectOutput": false,
"preLaunchTask": "Start Debug",
"postDebugTask": "End Debug"
},
{
"name": "Attach (Remote Debug)",
"type": "python",
Expand Down
15 changes: 15 additions & 0 deletions remote-debugging-docker/.vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"version": "2.0.0",
"tasks": [
{
"label": "Start Debug",
"command": "./debug.sh start && sleep 3",
"type": "shell"
},
{
"label": "End Debug",
"type": "shell",
"command": "./debug.sh stop"
}
]
}
6 changes: 6 additions & 0 deletions remote-debugging-docker/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,9 @@
* Add a breakpoint to the line `print("attached")`
* Go into the debugger menu and select `Python: Attach` and press the green arrow icon
* Wait for around 2 seconds and the debugger should hit at the breakpoint

## Using automatic build of docker container
It's the above steps combined in one.
* Add a breakpoint to the line `print("attached")`
* Go into the debugger menu and select `Python: Build and Attach` and press the green arrow icon
* Wait for a little time and the debugger should hit at the breakpoint
9 changes: 9 additions & 0 deletions remote-debugging-docker/debug.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/bash

if [ "$1" == "start" ]; then
docker build -t remote-debugging-docker .
docker run -d -t -p 3000:3000 --name remote-dbg-docker remote-debugging-docker
elif [ "$1" == "stop" ]; then
docker stop remote-dbg-docker
docker rm remote-dbg-docker
fi