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

Prerequisites and Requirements

  1. An Alibaba Cloud account. Click here to create one.
  2. A freshly deployed Alibaba Cloud Ubuntu 16.04 64-bit server instance
  3. Minimum 2GB RAM (2 GB highly recommended due to Dockerised app size)
  4. Minimum Disk Space of 20 GB (but 40GB recommended)
  5. The instance security group should allow ingress on port 8080
  6. An Alibaba Cloud Elastic Container Registry repository

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

--

--

--

Follow me to keep abreast with the latest technology news, industry insights, and developer trends. Alibaba Cloud website:https://www.alibabacloud.com

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Build your own Objects Analytics Dashboard with ELK Stack

A Deep Insight of Alibaba Open Source Project — Pouch

Agile and Quality

Calling REST API From SQL Server Stored Procedure

Calling REST API From SQL Server Stored Procedure

Supply Chain Security with OPA in k8s

Cherry Picking 🍒 in Git

Python Pool: Is it Possible to Negate a Boolean in Python? [Answered] — Cooding Dessign

How I Built a Serverless SaaS Product on Alibaba Cloud

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
Alibaba Cloud

Alibaba Cloud

Follow me to keep abreast with the latest technology news, industry insights, and developer trends. Alibaba Cloud website:https://www.alibabacloud.com

More from Medium

Jenkins Distributed Architecture

[Study Notes] Kubernetes

Kafka install Ansible Playbook

DevOps — Deployment strategies