From 0816ceb40e6b337d1a2b53a52f3d050c786b0e5a Mon Sep 17 00:00:00 2001 From: "jason.zhu" Date: Tue, 11 May 2021 09:26:33 +1000 Subject: [PATCH] Working on nodejs-debugging-in-docker --- .vscode/tasks.json | 46 ++++++++++++++++++++++++++ nodejs/.devcontainer/devcontainer.json | 34 +++++++++++++++++++ nodejs/Dockerfile | 4 ++- 3 files changed, 83 insertions(+), 1 deletion(-) create mode 100644 .vscode/tasks.json create mode 100644 nodejs/.devcontainer/devcontainer.json diff --git a/.vscode/tasks.json b/.vscode/tasks.json new file mode 100644 index 0000000..226c062 --- /dev/null +++ b/.vscode/tasks.json @@ -0,0 +1,46 @@ +{ + "version": "2.0.0", + "tasks": [ + { + "type": "docker-build", + "label": "docker-build", + "platform": "node", + "dockerBuild": { + "dockerfile": "${workspaceFolder}/nodejs/src/Dockerfile", + "context": "${workspaceFolder}/nodejs/src", + "pull": true + }, + "node": { + "package": "${workspaceFolder}/nodejs/src/package.json" + } + }, + { + "type": "docker-run", + "label": "docker-run: release", + "dependsOn": [ + "docker-build" + ], + "platform": "node", + "node": { + "package": "${workspaceFolder}/nodejs/src/package.json" + } + }, + { + "type": "docker-run", + "label": "docker-run: debug", + "dependsOn": [ + "docker-build" + ], + "dockerRun": { + "env": { + "DEBUG": "*", + "NODE_ENV": "development" + } + }, + "node": { + "package": "${workspaceFolder}/nodejs/src/package.json", + "enableDebugging": true + } + } + ] +} \ No newline at end of file diff --git a/nodejs/.devcontainer/devcontainer.json b/nodejs/.devcontainer/devcontainer.json new file mode 100644 index 0000000..77039d0 --- /dev/null +++ b/nodejs/.devcontainer/devcontainer.json @@ -0,0 +1,34 @@ +// For format details, see https://aka.ms/devcontainer.json. For config options, see the README at: +// https://github.com/microsoft/vscode-dev-containers/tree/v0.158.0/containers/docker-existing-dockerfile +{ + "name": "Existing Dockerfile", + + // Sets the run context to one level up instead of the .devcontainer folder. + "context": "..", + + // Update the 'dockerFile' property if you aren't using the standard 'Dockerfile' filename. + "dockerFile": "../Dockerfile", + + // Set *default* container specific settings.json values on container create. + "settings": { + "terminal.integrated.shell.linux": null + }, + + // Add the IDs of extensions you want installed when the container is created. + "extensions": [], + + // Use 'forwardPorts' to make a list of ports inside the container available locally. + "forwardPorts": [], + + // Uncomment the next line to run commands after the container is created - for example installing curl. + // "postCreateCommand": "apt-get update && apt-get install -y curl", + + // Uncomment when using a ptrace-based debugger like C++, Go, and Rust + // "runArgs": [ "--cap-add=SYS_PTRACE", "--security-opt", "seccomp=unconfined" ], + + // Uncomment to use the Docker CLI from inside the container. See https://aka.ms/vscode-remote/samples/docker-from-docker. + // "mounts": [ "source=/var/run/docker.sock,target=/var/run/docker.sock,type=bind" ], + + // Uncomment to connect as a non-root user if you've added one. See https://aka.ms/vscode-remote/containers/non-root. + // "remoteUser": "vscode" +} diff --git a/nodejs/Dockerfile b/nodejs/Dockerfile index 24c2046..e44e782 100644 --- a/nodejs/Dockerfile +++ b/nodejs/Dockerfile @@ -9,7 +9,9 @@ RUN npm install -g nodemon COPY ./src/ /work/src/ -# CMD [ "nodemon", "--inspect=0.0.0.0:9229", "./src/server.js" ] +# ENTRYPOINT [ "nodemon", "--inspect=0.0.0.0:9229", "./src/server.js" ] +# ENTRYPOINT [ "/usr/bin/top" ] +CMD top ###########START NEW IMAGE###################