HackerRank DevOps Interview Solution of Docker: Node Deployment

 HackerRank DevOps Interview Solution of Docker: Node Deployment

 

 


Docker: Node Deployment

QUESTION DESCRIPTION

You want to deploy a web application using Docker.  As part of the process, complete a file stub "/home/ubuntu/1090236-docker-node-deployment/Dockerfile" with one or more steps that do the following:

  • Inherit a "node" image (from Dockerhub) on the "12" tag.
  • Copy the "application" folder with all contents to the "/application" path.
  • Change the working directory context to "/application"
  • Execute the "npm install" command.
  • Override "CMD" (in "exec" form) to run the "node" executable with "application.js" as its parameter.
  • Expose port "8000" to the outside.

Note

  • The completed solution will be evaluated in a new, clean environment. Be sure everything is in the "/home/ubuntu/1090236-docker-node-deployment" folder.
  • All the tasks should be done within a simple "sudo solve" execution invoked from the question directory.
  • You have sudo access.

Grading

  • The execution result of "sudo solve" invoked from the question directory solves the task.
  • The execution result of "wget -qO- http://localhost:8000/api/token" shows a valid JSON output.


                               Download Books to Get HackerRank Interview Solution 

 
Solution:

At first ssh into the server

ssh [email protected]

Then type ls and go to docker node deployment folder

You can see a Dockerfile here. Edit it

vi Dockerfile

FROM node:12-alpine
WORKDIR /application
COPY /application /application
RUN npm install
CMD [ "node", "application.js" ]
EXPOSE 8000

Then run this command

sudo solve


Download Coding Interview Book and Get More Tutorials for Coding and Interview Solution: Click Here

Download System Design Interview Book and Get More Tutorials and Interview Solution: Click Here

Do you need more Guidance or Help? Then Book 1:1 Quick Call with Me: Click Here

Share on Google Plus

About Ashadullah Shawon

I am Ashadullah Shawon. I am a Software Engineer. I studied Computer Science and Engineering (CSE) at RUET. I Like To Share Knowledge. Learn More: Click Here
    Blogger Comment
    Facebook Comment

0 comments:

Post a Comment