Step by Step Deployment of Node-js application through docker.

Step by Step Deployment of Node-js application through docker.

Deployment of Node-Js Application

Β·

2 min read

πŸ‘‰ Create a new β€œnode-app” directory in the Projects folder.

  • πŸ‘‰ We have taken node-to-do code from my GitHub account.

  • πŸ‘‰ Clone the code to the local host machine from GitHub.

  • πŸ‘‰ We have cloned the code with the "git clone" command.

  • πŸ‘‰ We have got the whole project with the "git clone" command @my local machine.

  • πŸ‘‰ Post this we can check with the ls -l command & we have the Dockerfile as well. But for practice purposes, I have removed the Dockerfile with the following command β€œrm Dockerfile”. We are going to create a new docker file.

  • πŸ‘‰ We have created the docker file and the first line would be for the base image for "node js". The best practice is always to communicate with developers what version they need. Also to check with the latest image we can search in Google β€œ node js image for Docker”.

  • πŸ‘‰ Then we can go with the first link β€œDocker Hub”.

  • πŸ‘‰ Below is the content in the Dockerfile.

πŸ‘‰ We can run the command "docker build -t node-app " . (We have used. (Dot) cause. represents the present working directory and our Dockerfile is in the same directory.

& the image for node-js app successfully created.

πŸ‘‰ After this, we can check in the code that this app is the web app and it's working on the port. We can check here it a running on port 8000.

  • πŸ‘‰ So we have to map to the host machine (my local machine) and docker container port 8000 with the following command. If that application is running on that port then we can access it through my local machine.

  • πŸ‘‰ Once we are done with that port mapping of the host machine ( My Local Machine) post we have to open the port from the AWS console through the security group for accessing the application on the 8000 port.

  • & finally, we were able to access the application (node-to-do) through the browser. So we have successfully implemented the deployment of the application (node-to-do) with Docker.

    I hope you like this post!

    Happy Learning!!

Β