From 15e8e42dd8ecd66702a63031975ccd8031568422 Mon Sep 17 00:00:00 2001 From: tobuh Date: Fri, 6 Sep 2019 17:22:30 +0200 Subject: [PATCH 1/2] added automatic start of debugging container in vscode --- remote-debugging-docker/.vscode/launch.json | 4 +++- remote-debugging-docker/.vscode/tasks.json | 15 +++++++++++++++ remote-debugging-docker/debug.sh | 9 +++++++++ 3 files changed, 27 insertions(+), 1 deletion(-) create mode 100644 remote-debugging-docker/.vscode/tasks.json create mode 100755 remote-debugging-docker/debug.sh diff --git a/remote-debugging-docker/.vscode/launch.json b/remote-debugging-docker/.vscode/launch.json index 78cd708..84e2c03 100644 --- a/remote-debugging-docker/.vscode/launch.json +++ b/remote-debugging-docker/.vscode/launch.json @@ -13,7 +13,9 @@ "pathMappings": [ {"localRoot": "${workspaceFolder}", "remoteRoot": "/src/"} ], - "redirectOutput": false + "redirectOutput": false, + "preLaunchTask": "Start Debug", + "postDebugTask": "End Debug" } ] } 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/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 From d7d3d8340f7e89bddfb44b561bfd194726393613 Mon Sep 17 00:00:00 2001 From: tobuh Date: Fri, 6 Sep 2019 17:28:35 +0200 Subject: [PATCH 2/2] specified a seperate debug launch for building docker and attaching to it --- remote-debugging-docker/.vscode/launch.json | 13 ++++++++++++- remote-debugging-docker/README.md | 6 ++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/remote-debugging-docker/.vscode/launch.json b/remote-debugging-docker/.vscode/launch.json index 84e2c03..f0a0957 100644 --- a/remote-debugging-docker/.vscode/launch.json +++ b/remote-debugging-docker/.vscode/launch.json @@ -5,7 +5,7 @@ "version": "0.2.0", "configurations": [ { - "name": "Attach (Remote Debug)", + "name": "Build and Attach (Remote Debug)", "type": "python", "request": "attach", "port": 3000, @@ -16,6 +16,17 @@ "redirectOutput": false, "preLaunchTask": "Start Debug", "postDebugTask": "End Debug" + }, + { + "name": "Attach (Remote Debug)", + "type": "python", + "request": "attach", + "port": 3000, + "host": "localhost", + "pathMappings": [ + {"localRoot": "${workspaceFolder}", "remoteRoot": "/src/"} + ], + "redirectOutput": false } ] } 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