Step 2: Build Images and Run Containers using Docker Compose and specified nodemon to execute the babel-node CLI using the - exec option.We added the nodemon utility to run our node.js application. "start:server": "nodemon -debug server/server.js -exec babel-node", Going back to the same NPM script we edited in Step 1c, lets make the small change of adding nodemon:.The same would be if we weren’t using Docker, you would be required to shutdown and restart your express.js application on any change. route add or update) would normally require you stopping your running application contain and restarting it. NOTE: If you’re not familiar with nodemon, it’s simply a utility that will monitor your application server files and restart your node.js server when there are changes. I thought it might be easier in the overall approach to wire up the port mapping first. Exposing the port on the container and mapping the port from the container to the local host. When setting up port access to a container there are two parts. If the node.js debugger for our application is listening on port 5858, we’ll be able to connect to it from our host machine.We have mapped the port 5858 on the container to our local host port 5858.add an additional port mapping 5858 to local host port 5858:.Inside the docker-compose.yml file, locate the “ports” property, under the “node” service.In order to make it available through our container do the following: However, to keep it as simple as possible, we’re going to stick with the default port that node.js debugger will listen on which 5858. We could specify any port to use by specifying a port along with the –debug flag, when we start our express.js application. To do this, we need to open up the port that our Express.js application debugger will be listening on. We want to be able to attach WebStorm to a running node.js debugger in our application’s Docker container. We are using this port to connect to the running application in our container (e.g. and set the services to use the “hackershall-network” networkĬurrently, we only have the port 7000 of the container mapped to our local host post 7000.That created a single network named “hackershall-network”.Create a file in the root of the project and name it “ docker-compose.yml”ĭockerfile.No different than how we started using Docker Compose in the Docker tutorial, we’re also going to leverage Docker Compose for creating our network, creating our services and their containers in this debug docker container tutorial. Connect WebStorm Node.js Remote Interpreter to our application’s debugger.Configure WebStorm Node.js Remote Debugger plugin.
0 Comments
Leave a Reply. |