GIT + DOCKER + NODE.JS COMMAND SPPU BEIT 2019 PATTERN WAD
GIT
Step 1 : 1st we have to logout the previous user from git so use command
git config --global --unset user.name
git config --global --unset user.email
Step 2 : Then cheak the who is the user using this commands
git config --global --unset user.name
git config --global --unset user.email
step 3 :
1) git config --global user.name "Your Name"
2) git config --global user.email "your@email.com"
3) git init
4) git add .
5) git commit -m "Initial commit"
6) git branch -M main
7) git remote add origin <repository_url>
8) git push -u origin main
DOCKER
step 1 : Launch Docker desktop
step 2 : lauch vs code and install Docker extension
step 3 : create file named 'Dockerfile' and write this code in that file
FROM node:alpine
COPY . /<folder name>
CMD node /<folder name>/<.js file name>
step 4 : create file 'filename.js' and write this code in it
console.log("Anything");
console.log("Class : TEIT");
console.log("raww");
step 5 : open terminal and inistilized npm using
npm init
step 6 : then right click on 'DockerFile' and click on build image
step 7 : then go to docker --> image section --> you will see the image created by folder name run that image file and done.
NODE.JS
step 1: create index.js file on main folder
step 2: Write the following code in it
const express = require('express');
// Express Dependency into the application loaded the dependence
// Express is a module with functions or objects or variables assigned to it
const app = express();
// initialize an applicatoin imported express
const port = 4000;
// to make pages .html .txt .jpeg .mp3 .mp4 static content
app.use(express.static("public"));
// basically telling express framework to take content inside the folder public and into the website
app.listen(port, () => { console.log(`app started on port ${port}`) });
//start the web server in port
step 3 : create a folder named public under the main folder and add index.html (write any html code inside index.html) file to that folder
<!DOCTYPE html>
<html>
<head>
<title>Welcome Message</title>
<style>
/* CSS styles */
body {
font-family: Arial, sans-serif;
text-align: center;
}
h1 {
color: #333;
}
</style>
</head>
<body>
<h1>Welcome!</h1>
<p>Thank you for visiting our website.</p>
</body>
</html>
step 4 : then execute the following Commands
1) npm init (hit enter till get on directory)
2) npm i express --save
3) node index.js
then type on browser localhost:4000
0 Comments