From 8c030fcbe04f121d354b6218807ec162f5e46068 Mon Sep 17 00:00:00 2001 From: shaheennabi Date: Mon, 14 Oct 2024 00:52:35 -0700 Subject: [PATCH] cicd added with jenkins --- .jenkins/Jenkinsfile | 2 +- scripts/ec2_setup.sh | 2 +- scripts/jenkins.sh | 47 ++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 49 insertions(+), 2 deletions(-) diff --git a/.jenkins/Jenkinsfile b/.jenkins/Jenkinsfile index 35900a5..108060f 100644 --- a/.jenkins/Jenkinsfile +++ b/.jenkins/Jenkinsfile @@ -47,7 +47,7 @@ pipeline { stage('Continuous Deployment') { steps { sshagent(['ssh_key']) { - sh "ssh -o StrictHostKeyChecking=no -l ubuntu 54.80.194.59 'cd /home/ubuntu/ && wget https://raw.githubusercontent.com/entbappy/End-to-end-Object-Detection-Project/main/docker-compose.yml && export IMAGE_NAME=${ECR_REPOSITORY}:latest && aws ecr get-login-password --region us-east-1 | docker login --username AWS --password-stdin ${AWS_ACCOUNT_ID}.dkr.ecr.us-east-1.amazonaws.com && docker compose up -d '" + sh "ssh -o StrictHostKeyChecking=no -l ubuntu 52.55.47.4 'cd /home/ubuntu/ && wget https://raw.githubusercontent.com/shaheennabi/Object_detection-End-to-End-project/refs/heads/main/docker-compose.yml && export IMAGE_NAME=${ECR_REPOSITORY}:latest && aws ecr get-login-password --region us-east-1 | docker login --username AWS --password-stdin ${AWS_ACCOUNT_ID}.dkr.ecr.us-east-1.amazonaws.com && docker compose up -d '" } } } diff --git a/scripts/ec2_setup.sh b/scripts/ec2_setup.sh index e0cfc44..59540fd 100644 --- a/scripts/ec2_setup.sh +++ b/scripts/ec2_setup.sh @@ -12,7 +12,7 @@ sudo sh get-docker.sh sudo usermod -aG docker $USER -newgrp docker +sudo usermod -aG docker $USER sudo apt install awscli -y diff --git a/scripts/jenkins.sh b/scripts/jenkins.sh index e69de29..0b4207f 100644 --- a/scripts/jenkins.sh +++ b/scripts/jenkins.sh @@ -0,0 +1,47 @@ +#!bin/bash + +sudo apt update + +sudo apt install openjdk-8-jdk -y + +https://pkg.jenkins.io/ +https://pkg.jenkins.io/debian-stable/ + +sudo systemctl start jenkins + +sudo systemctl enable jenkins + +sudo systemctl status jenkins + + + +## Installing Docker + +curl -fsSL https://get.docker.com -o get-docker.sh + +sudo sh get-docker.sh + +sudo usermod -aG docker $USER + +sudo usermod -aG docker jenkins + + +newgrp docker + +sudo apt install awscli -y + +sudo usermod -a -G docker jenkins + + +## AWS configuration & restarts jenkins + +aws configure + + +## Now setup elastic IP on AWS + + + +## For getting the admin password for jenkins + +sudo cat /var/lib/jenkins/secrets/initialAdminPassword \ No newline at end of file