rikukissa / typehole

TypeScript development tool for Visual Studio Code that helps you automate creating the initial static typing for runtime values

Home Page:https://marketplace.visualstudio.com/items?itemName=rikurouvila.typehole

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Running NodeJS server in Docker Container

ahmad2smile opened this issue · comments

commented

typings not working when code is running inside a container. Is there any port I can expose to make it work or some config?

Try exposing the port 17341 to the docker container from the host where your VSCode is running

commented

Any idea how to do it? afaik, this can't be done unless typehole runtime calls host.docker.internal instead of localhost and docker container is created with network_mode: host, even which in my case can't be done as my container connects to a docker swarm networks so I can't replace those out.

I just pushed a new release (1.6.0) of typehole both to npm and to VSCode. Now you are able to configure both the host address the runtime uses to connect to the extension server and the extension HTTP listener port. This is still undocumented, but you can configure the client like this

import typehole, { configure } from "typehole";

configure({
  extensionHost: 'http://host.docker.internal:17341'
});

What comes to your problem: do your docker containers have access to the public internet? One thing you could do is to expose the Typehole port to the outside internet for instance with ngrok.

$ ngrok http 17341

and then use the address you get in your runtime configuration

import typehole, { configure } from "typehole";

configure({
  extensionHost: 'https://b8722b82f530.eu.ngrok.io'
});

Could something like this work?

Closing the issue for now. Please feel free to reopen if you have issues connecting from your code to the extension after upgrading the extension and the runtime.

commented

I really appreciate your quick response and update. This is very useful, I'm still trying to make it work with my "work" project as there is where I need this the most.

The issues I'm facing are very particular to my own specific usecase. I can not use 3rd party servers at all for work, for that reason I'm looking to get typehole traffic out of container using some native solutions, for now ended up here:

docker/compose#3532

Same issue, to use overlay network and host network at the same time. If I were to find a solution, I'll update here for posterity.