Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions Jenkinsfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
pipeline {
agent any

stages {

stage('Checkout Code') {
steps {
git branch: 'master', url: 'https://github.com/harshrajurkar/node-hello.git'
}
}

stage('Upload index.html to S3') {
steps {
withAWS(region: 'ap-south-1', credentials: 'aws-creds') {
s3Upload bucket: 'my-frontend-site-node',
file: 'index.html',
path: "index.html"
}
}
}
}

post {
success {
echo "index.html uploaded to S3 successfully!"
}
failure {
echo "Upload failed!"
}
}
}
35 changes: 35 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<!DOCTYPE html>
<html>
<head>
<title>My Simple Node Page</title>
<style>
body {
font-family: Arial, sans-serif;
background: #f4f4f4;
padding: 40px;
text-align: center;
}
.container {
background: white;
padding: 20px;
margin: auto;
max-width: 500px;
border-radius: 10px;
box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}
h1 {
color: #333;
}
p {
font-size: 18px;
color: #555;
}
</style>
</head>
<body>
<div class="container">
<h1>sucessfull deployemnt!</h1>
<p>This webpage is served from a separate index.html file for s3...1..2..3..4....5</p>
</div>
</body>
</html>
19 changes: 15 additions & 4 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,23 @@
const http = require('http');
const fs = require('fs');
const path = require('path');

const port = process.env.PORT || 3000;

const server = http.createServer((req, res) => {
res.statusCode = 200;
const msg = 'Hello Node!\n'
res.end(msg);
const filePath = path.join(__dirname, 'index.html');

fs.readFile(filePath, (err, content) => {
if (err) {
res.writeHead(500);
res.end('Error loading file');
} else {
res.writeHead(200, { 'Content-Type': 'text/html' });
res.end(content);
}
});
});

server.listen(port, () => {
console.log(`Server running on http://localhost:${port}/`);
console.log(`Server running at http://localhost:${port}`);
});
12 changes: 10 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.