Member-only story
Dockerize a Node.Js App — with Job Scenario/DevOps ticket
Creating a Dockerized Node.js App and Deploying it on a Remote Server
Prerequisites:
- Access to a remote server (App Server 3 in this example) with Docker installed.
- A Node.js application with a
package.json
file and aserver.js
file. These should be placed in the/node_app
directory on the remote server. - Basic knowledge of Docker and Node.js.
Objectives:
- Dockerize a Node.js app.
- Deploy the Docker container on a remote server.
- Expose the Node.js app on a specific port.
- Test the deployed app using a
curl
command.
Job Scenario:
There is a requirement to Dockerize a Node app and to deploy the same on App Server 3. Under /node_app directory on App Server 3, we have already placed a package.json file that describes the app dependencies and server.js file that defines a web app framework.
Create a Dockerfile (name is case sensitive) under /node_app directory:
Use any node image as the base image.
Install the dependencies using package.json file.
Use server.js in the CMD.
Expose port 5000.
The build image should be named as nautilus/node-web-app.