I've been setting up a Nodejs project using Docker for the first time and I'm having trouble attaching a debugger to the app.
here's my docker files:
FROM node:latest
LABEL Name=graphql Version=0.1.0
# Create app directory
RUN mkdir -p /graphql
WORKDIR /graphql
# Install app dependencies
COPY package.json /graphql
RUN npm install -g gulp
RUN npm install
# Bundle app source
COPY . /graphql
EXPOSE 3000
EXPOSE 5858
EXPOSE 8000
CMD gulp
and the compose one:
version: '2'
services:
graphql:
image: graphql:latest
container_name: apollo-graphql
build:
context: .
dockerfile: dockerfile
environment:
NODE_ENV: development
tty: true
ports:
- 3000:3000
- 5858:5858
- 8000:8000
volumes:
- .:/graphql
## set your startup file here
command: gulp
the gulp task is currently launching nodemon like this:
gulp.task('serve', ['bundle'], () => {
stream = nodemon({
execMap: {
js: 'node --debug=5858'
},
script: 'build/server.bundle.js',
verbose: true
})
This seems to run everything just fine, including an output stating: Debugger listening on 127.0.0.1:5858 However I can't seems to connect to it. I'm using VScode and my launch config file is the following:
"name": "Attach",
"type": "node",
"request": "attach",
"address": "127.0.0.1",
"port": 5858,
"localRoot": "${workspaceRoot}/graphql/",
"remoteRoot": "/graphql/",
Even if I change the --debug flag to --inspect to use the new protocol, I still can't open it in Chrome devtools.
I've seen some tutorials and those pretty much do what I'm doing here but am I missing something here? I have also seen some suggestions on StackOverflow about running a second container with node-inspect, but I'd rather not go that route as I'm trying to keep things simple. In fact, this sort of setup seems to work in those tutorials, so why doesn't it work for me?
Thanks in advance!
via Tiago Vila Verde
No comments:
Post a Comment