In this post we are create Docker Image of a Node–Express app which can be used to deploy and run the app. The image can be used to deploy multiple container as well. Following are the requirements for this tutorial
Requirements
- NPM
- Nodejs
- VSCode/Atom
Node-Express API
Lets create a folder and create file index.js and paste the following API site content
const express = require('express')
const app=express()
require("dotenv").config();
app.get('/',(req,res)=>
res.json([{name:'manoj',email:'codehat@outlook.com'
},
{name:'mariah',email:'codehat@outlook.com'
}])
)
app.listen(process.env.PORT || 3000,()=>console.log(`Server running on port ${process.env.PORT}`))
Our API is a simple USER API which shows a list of users. Let’s setup the package.json file by issuing npm command and install dependencies