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
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ RUN apt update
RUN apt install git -y
RUN rm -rf /var/lib/apt/lists/*
RUN rm -rf /usr/local/apache2/htdocs/*
RUN git clone https://github.com/akshu20791/apachewebsite/ /usr/local/apache2/htdocs/
RUN git clone https://github.com/Prabhatsanu/apachewebsite/ /usr/local/apache2/htdocs/
EXPOSE 80
CMD ["httpd-foreground"]
58 changes: 58 additions & 0 deletions Jenkinsfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
pipeline {
agent any

environment {
IMAGE_NAME = 'prabhatsanu1990/prabhatnewimg9june'
TAG = 'v1'
FULL_IMAGE = "${IMAGE_NAME}:${TAG}"
CONTAINER_NAME = 'My-apache'
REMOTE_USER = 'ubuntu'
REMOTE_HOST = '172.31.6.94'
}

stages {
stage('Clone Repo') {
steps {
git url: 'https://github.com/Prabhatsanu/apachewebsite/', branch: 'master'
}
}

stage('Build Docker Image') {
steps {
script {
sh "docker build -t ${FULL_IMAGE} ."
sh "docker images"
}
}
}

stage('Docker Login & Push') {
steps {
withCredentials([
usernamePassword(
credentialsId: 'dockerhub-pwd',
passwordVariable: 'PASS',
usernameVariable: 'USER'
)
]) {
sh "echo $PASS | docker login -u $USER --password-stdin"
sh "docker push ${FULL_IMAGE}"
}
}
}

stage('Remote Deploy') {
steps {
script {
def removeCmd = "sudo docker rm -f ${CONTAINER_NAME} || true"
def runCmd = "sudo docker run -itd --name ${CONTAINER_NAME} -p 8081:80 ${FULL_IMAGE}"

sshagent(['sshkeypair']) {
sh "ssh -o StrictHostKeyChecking=no ${REMOTE_USER}@${REMOTE_HOST} '${removeCmd}'"
sh "ssh -o StrictHostKeyChecking=no ${REMOTE_USER}@${REMOTE_HOST} '${runCmd}'"
}
}
}
}
}
}
2 changes: 1 addition & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -467,7 +467,7 @@ <h3>Follow Us</h3>
<div class="container">
<div class="row">
<div class="col-md-12">
<p>Copyright 2019 All Right Reserved By <a href="https://html.design/">Free html Templates</a></p>
<p>Copyright 2019 All Right Reserved By Prabhatsanu user <a href="https://html.design/">Free html Templates</a></p>
</div>
</div>
</div>
Expand Down