Successfully debug nodejs code within container

This commit is contained in:
jason.zhu 2021-02-08 21:15:43 +11:00
parent 817b6bffd2
commit 338c95a834
5 changed files with 85 additions and 5 deletions

23
.dockerignore Normal file
View File

@ -0,0 +1,23 @@
**/.classpath
**/.dockerignore
**/.env
**/.git
**/.gitignore
**/.project
**/.settings
**/.toolstarget
**/.vs
**/.vscode
**/*.*proj.user
**/*.dbmdl
**/*.jfm
**/azds.yaml
**/charts
**/docker-compose*
**/Dockerfile*
**/node_modules
**/npm-debug.log
**/obj
**/secrets.dev.yaml
**/values.dev.yaml
README.md

49
.vscode/launch.json vendored Normal file
View File

@ -0,0 +1,49 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"console": "integratedTerminal",
"internalConsoleOptions": "neverOpen",
"name": "nodemon",
"program": "${workspaceFolder}/app.js",
"request": "launch",
"restart": true,
"runtimeExecutable": "nodemon",
"skipFiles": [
"<node_internals>/**"
],
"type": "pwa-node"
},
{
"address": "TCP/IP address of process to be debugged",
"localRoot": "${workspaceFolder}",
"name": "Attach to Remote",
"port": 9229,
"remoteRoot": "Absolute path to the remote directory containing the program",
"request": "attach",
"skipFiles": [
"<node_internals>/**"
],
"type": "pwa-node"
},
{
"name": "Docker: Attach to Node.js",
"type": "node",
"request": "attach",
"remoteRoot": "/work/src/",
"port": 9229,
"address": "localhost",
"localRoot": "${workspaceFolder}/nodejs/src",
"protocol": "inspector",
"restart": true,
},
]
}

View File

@ -39,9 +39,10 @@ services:
stdin_open: true
tty: true
volumes:
- ./nodejs/src/:/work
- ./nodejs/src/:/work/src/
ports:
- 5502:5000
- 9229:9229 # debug port
python: #docker run -it -v ${PWD}:/work -w /work -p 5003:5000 aimvector/python:1.0.0 /bin/sh
container_name: python
image: cruxlight/python_dev:1.0.0

View File

@ -27,7 +27,7 @@ services:
context: ./nodejs
target: prod
volumes:
- ./nodejs/src/:/work
- ./nodejs/src/:/work/src
ports:
- 5502:5000
python: #docker run -it -v ${PWD}:/work -w /work -p 5003:5000 aimvector/python:1.0.0 /bin/sh

View File

@ -5,12 +5,19 @@ WORKDIR /work/
COPY ./src/package.json /work/package.json
RUN npm install
RUN npm install -g nodemon
COPY ./src/ /work/
COPY ./src/ /work/src/
# CMD [ "nodemon", "--inspect=0.0.0.0:9229", "./src/server.js" ]
###########START NEW IMAGE###################
FROM dev as prod
FROM node:12.4.0-alpine as prod
CMD node .
WORKDIR /work/
COPY ./src/package.json /work/package.json
RUN npm install
COPY ./src/ /work/
CMD node .