diff --git a/Dockerfile b/Dockerfile index 6534375..774bfdb 100644 --- a/Dockerfile +++ b/Dockerfile @@ -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"] diff --git a/Jenkinsfile b/Jenkinsfile new file mode 100644 index 0000000..5decf0f --- /dev/null +++ b/Jenkinsfile @@ -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}'" + } + } + } + } + } +} diff --git a/index.html b/index.html index 16c6d71..ac486df 100644 --- a/index.html +++ b/index.html @@ -467,7 +467,7 @@

Follow Us

-

Copyright 2019 All Right Reserved By Free html Templates

+

Copyright 2019 All Right Reserved By Prabhatsanu user Free html Templates