Posts

Debug nodejs Application In Docker Container Using WebStorm - Part 3

Image
In the part 1  of this series we implemented a simple RESTful service that simply responds with "Hello, world!". We also demonstrated hitting a breakpoint. In part 2  we containerized our app and demonstrated that we could run it in a Docker container without a single change. In this third part we'll build on that by adding the configurations required so we can hit breakpoints while our app is running inside of a Docker container. As a reminder you can find the source code for this tutorial on github . Debugging nodejs Remotely A container is separate from our local environment. It's not a virtual machine but better described as a minimal runtime environment. We don't really need to understand a container other than knowing that it provides just the elements our RESTful web service needs and nothing else. To debug a nodejs application that runs inside a container we need to be able to connect to it remotely. For that we'll tell nodejs that it i...

Debug nodejs Application In Docker Container Using WebStorm - Part 2

Image
In part 1 of this post we created a very simple "Hello, world!" example for a RESTful web service. We also demonstrated hitting a breakpoint when debugging our service. In this second part we will take it to the next level by deploying web service into a Docker container. Note that you will find it easier to follow this post if you have some basic understanding of Docker. One option is to work through the first two parts of the official Docker tutorial which I found quite well made. Also, this second part continues where part 1 left off. We won't repeat the steps from part one. As a reminder the source code is available on github . Docker To docker-ize (or container-ize) our application we need two elements: A Dockerfile which describes how the image is created, i.e. the steps to create the container image. A docker-compose.yml file that contains parameters for creating the image Oversimplified you could say that the docker-compose.yml file contains the i...

Debug nodejs Application In Docker Container Using WebStorm - Part 1

Image
First some housekeeping: I'm using the following versions of tools and libraries: - Windows 10 Professional, latest updates as of 19 Aug 2018 - Node.js 8.11.3 - WebStorm 2018.2 - Docker for Windows, Community Edition, version 18.06.0-ce-win72 (19098), channel: stable Introduction WebStorm is a great IDE for developing applications based on nodejs. Docker is a great technology to develop microservices. While often you can run your code and tests without firing up a docker container, I was curious to find out if I could create a simple "Hello, world!" app, set a break point, run it in a container and then hit that break point. That turned out harder than I thought because of changes between versions of nodejs, changes of WebStorm dialog boxes, and similar more. Obviously, if all your app is doing is printing "Hello, world!" somewhere then using Docker would be a total overkill. Don't do it! For something that simple it would result in a Rube ...