Setting up CI/CD for a PREN app with Jenkins, Docker and GitHub Webhooks on Container Registry

Prerequisites and Requirements

Step 1: Set up Jenkins

sudo apt-get update
sudo apt-get install software-properties-common
sudo add-apt-repository ppa:webupd8team/java
sudo apt-get update
sudo apt-get install oracle-java8-installer
wget -q -O - https://pkg.jenkins.io/debian/jenkins-ci.org.key | sudo apt-key add -
echo deb https://pkg.jenkins.io/debian-stable binary/ | sudo tee /etc/apt/sources.list.d/jenkins.list
sudo apt-get update
sudo apt-get install jenkins
sudo service jenkins start
sudo service jenkins status
sudo cat /var/lib/jenkins/secrets/initialAdminPassword

Step 2: Setup Docker

curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
sudo apt-get update
sudo apt-get install -y docker-ce
sudo service docker status

Step 3: Setup GitHub Webhooks on Jenkins

set +x
if [ -d HelloBooks-Alibaba ]; then rm -rf HelloBooks-Alibaba; fi
git clone https://github.com/babadee001/HelloBooks-Alibaba
cd HelloBooks-Alibaba
sudo docker build -t hellobooks .
sudo docker login --username=yourusername registry-intl.yourregion.aliyuncs.com -p $password
sudo docker tag [ImageId] registry-intl.yourregion.aliyuncs.com/yournamespace/yourrepositoryname:[tag]
sudo docker push registry-intl.yourregion.aliyuncs.com/yournamespace/yourrepositoryname:[tag]
visudo -f /etc/sudoers
jenkins ALL= NOPASSWD: ALL

Step 4: Configure Container Registry

sudo docker login --username=yourusername registry-intl.yourregion.aliyuncs.com
sudo docker tag [ImageId] registry-intl.yourregion.aliyuncs.com/yournamespace/yourrepositoryname:[tag]
sudo docker push registry-intl.yourregion.aliyuncs.com/yournamespace/yourrepositoryname:[tag]

Conclusion

Original Source

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store