diff --git a/remote-debugging-docker/.vscode/launch.json b/remote-debugging-docker/.vscode/launch.json index 78cd708..f0a0957 100644 --- a/remote-debugging-docker/.vscode/launch.json +++ b/remote-debugging-docker/.vscode/launch.json @@ -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", diff --git a/remote-debugging-docker/.vscode/tasks.json b/remote-debugging-docker/.vscode/tasks.json new file mode 100644 index 0000000..46c0687 --- /dev/null +++ b/remote-debugging-docker/.vscode/tasks.json @@ -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" + } + ] +} \ No newline at end of file diff --git a/remote-debugging-docker/README.md b/remote-debugging-docker/README.md index 2ec0d35..3cb7b21 100644 --- a/remote-debugging-docker/README.md +++ b/remote-debugging-docker/README.md @@ -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 \ No newline at end of file diff --git a/remote-debugging-docker/debug.sh b/remote-debugging-docker/debug.sh new file mode 100755 index 0000000..08b7e19 --- /dev/null +++ b/remote-debugging-docker/debug.sh @@ -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 \ No newline at end of file