I'm having trouble setting up chrome debugger within a dockerized node application.
I've tried following https://github.com/nodejs/node/issues/11591 to no success.
My application does run on PORT, but my chrome debugger always displays WebSockets request was expected
when on localhost:9229. I have a suspicion that it has something to do with my index.js listening on PORT, but I'm unsure.
Can someone please help? Thanks!
(I have a .env file with DOCKER_WORKING_DIR and PORT defined.)
Dockerfile
FROM node:8
ENV DOCKER_WORKING_DIR="/usr/local/app"
WORKDIR ${DOCKER_WORKING_DIR}
COPY package.json .
COPY package-lock.json .
RUN npm install --quiet
COPY . .
CMD ["npm", "run", "start"]
docker-compose.yml
version: '2.2'
services:
api:
build:
context: ../../.
dockerfile: docker/images/app/Dockerfile
command: npm run start-dev
environment:
PORT: ${PORT}
DOCKER_WORKING_DIR: ${DOCKER_WORKING_DIR}
volumes:
- ../../.:${DOCKER_WORKING_DIR}/
- ${DOCKER_WORKING_DIR}/node_modules
ports:
- "${PORT}:${PORT}"
- 9229:9229
package.json
"scripts": {
"start": "node index.js",
"start-dev": "nodemon --watch ./src -x \"npm run start-debug\"",
"start-debug": "node --inspect=0.0.0.0:9229 index.js",
},
index.js
const server = require('./src/server');
server.listen(process.env.PORT);