ndb
ndb copied to clipboard
docker containers support?
Want to use this wonderful toolkit... but I have my project inside the docker container (maybe like many other developers nowadays).
But, as I can see - ndb works with puppeteer and starts some chrome instance with ui - which is unacceptable inside docker.
Q: do we have any ways to debug js files inside docker? (I even agree to install ndb both on host and docker envs)
For now I use chrome debugger and forward 9229 port from container.
We do not have any ways to debug node inside docker container right now.
To make it possible we need some kind of ndd_service.js
implementation which will help ndb to discover targets inside docker and help ndb to send and receive message from node inside docker. It is definitely doable.
Do you have any article in mind which describes required steps to run Node.js inside docker or at least describes best practices in this area? Something like this will help us a lot to understand use case better.
Unfortunately, I'm not so good in node internal engine to give some advices (
what I do..... just use any ubuntu docker image and install there latest node.js; thats all ); guess, it's the simplest way to run any project in container.
As far as I know we can communicate with docker using ports or files (also found some solution with x11 forwarding but it's not an option because requires XServer)
almost sure that we'll find some ways to run it....
I'd also love to see something like this implemented. Here's a brief overview of our setup:
- Run some command / NPM script to start a
docker-compose
instance. One of these containers is the 'principal' container with our Node process running in it with port9229
exposed to the host machine. - The Node process in the container is run with
--inspect=0.0.0.0:9229
, which tells Node to bind to all available IP addresses (not just127.0.0.1
) on our exposed port. - Now, a developer can launch Chrome DevTools and connect to Debugger instance running in the container. 🎉
This process works to give us the "standard" debugging experience, but ndb
seems like a fantastic product and we would love to start using it. 😸
Happy to provide more context if needed.
Even if by default ndb looked for debuggers on 9229, that'd be a big help. I use something very similar to the above. Here's a fairly bog-standard docker-compose.yml, if it helps:
version: '3'
services:
db:
image: postgres
environment:
POSTGRES_PASSWORD: myproject
POSTGRES_USER: myproject
POSTGRES_DB: myproject
ports:
- "5432:5432"
express:
image: node:10.7-alpine
command: nodemon --delay 80ms --exec 'fuser -k 9229/tcp; node --inspect=0.0.0.0:9229 index.js'
volumes:
- ".:/express"
working_dir: "/express"
depends_on:
- "db"
ports:
- "3001:3001"
- "9229:9229"
links:
- "db"
environment:
DB_PASSWORD: myproject
DB_USER: myproject
DB_NAME: myproject
DB_HOST: db
@ak239 This might help too - https://kevinridgway.com/debugging-nodejs-in-docker-with-visualstudiocode/
@ak239 Would love to be able to connect to any remote instance by running
ndb http://some-host:9229
Where on some-host
, node was started with --inspect
. It can then discover the available targets by calling http://some-host:9229/json
.
Likewise, I'd just like to be able to just give it a raw websocket url that is
ndb ws://some-host:9229/99cbba16-f8fc-4c8c-b56e-161af9bb6706
One or the other is all that's needed to support debugging in docker containers. Added bonus is that you can now debug any remote target. For instance I could send a SIGUSR1
to the node process in my production server (this would activate the debugger) and point ndb
from my laptop to it.
Any updates?
Unfortunately, I do not have free time to work on this issue shortly.
ndb
frontend uses chrome devtools protocol to speak with its backend. For proper docker support, it should be possible to run ndb
in backend-only mode and teach ndb
frontend to talk with it through port exposed from docker.
If someone would like to help with this one - I will explain more details.
Hi Aleksey, Id like to dig deeper into updating the code to support the ndb front-end connecting to the backend inside a docker container via the exposed ports. Happy to chat off line if u have a few minutes.
Cheers,
Andy