-
-
Notifications
You must be signed in to change notification settings - Fork 0
WebStorm Docker Integration
This document was written before NestJS integration, and no longer applies to newer versions of the API. You may continue to read it for now, however this article will be removed in the future.
It is possible to use WebStorm to develop Glimpse without any additional work beyond that in the
README.md
, however you can take steps to better integrate the project into your IDE, allowing you to use tools such as the built-in IDE debugger.You should read the articles linked below for basic instructions on how to set up Docker in WebStorm. You can use Docker / Docker Compose run configurations to boot your Docker containers, however they will be booted completely detached from the IDE's debugger. To attach them, you have two options.
WebStorm offers the ability to attach to a remote debugger, provided a host, port, and protocol. By default, the development Docker Compose config will run
npm run dev.debug
, which exposes the debugger socket in the Docker container at0.0.0.0:5858
. In your run configurations, add a new "Attach to Node.js/Chrome" configuration. Specify the host aslocalhost
, port as5858
and selectChrome or Node.js > 6.8 started with --inspect
for the "Attach to" protocol. Make sure to check the box "Reconnect automatically", or else the debugger will not restart with Nodemon.When you're ready to debug, you can select this new run configuration from the dropdown and click the bug icon to run it in debug mode. It will automatically attach to the Node debug socket.
The previous method is preferred, but it might not work all the time. In this case, there is an alternative, but it is more work. You can set up a separate Node.js run configuration with a remote interpreter in the Docker container. This method could result in inconsistencies with what you see in the Docker Compose config due to how the file system works.
The program will execute within the Docker container, however it will essentially use the file system of the host machine. As a result, you will need to make sure your
node_modules
folder is populated. If your host machine is a different OS/arch than the Docker container (e.g. Windows), you may need to boot up the container using the CLI and copy thenode_modules
folder to the host first. Otherwise, you can probably just runnpm install
. Once you've populated thenode_modules
folder, if you want nodemon to auto-restart the program on file changes, you will need to add this line to the Node parameters of the run configuration:./node_modules/.bin/nodemon -L --inspect=0.0.0.0:5858
.