CentOS 7.6 on the use of Docker build Jenkins project to automate the deployment of Django

Under normal circumstances, will deploy a project to production process is as follows:

Needs analysis - Prototyping - development code - the network deployment - submit test - Confirm the line - backup data - outside the network update - the final test, if the code is deployed outside the network are found, the need for timely rollback.

The whole process is quite lengthy and complicated, which also need to enter a lot of commands, such as uploading the code, Git pulling or merging branches and the like.

Jenkins is currently a very popular continuous integration tool that can help you put the updated code is automatically deployed to the server is running, the whole process is very automated, you can understand visual interface for the deployment of command operations.

There are three main ways to install Jenkins

Download the official war package, put directly run tomcat.

yum install.

Using the official docker mirror.

There is no doubt, since there docker so simple and convenient tool, no need to select the first two of the complex installation.

First install docker

Installation Docker
1 Docker system requirements CentOS kernel version higher than 3.10 , see this page prerequisite to verify your CentOS version supports Docker
2 , log on Centos with root privileges. Ensure that the yum package up to date.
yum Update sudo
3 , uninstall the old version (if an old version is installed)
sudo yum Docker Docker the Remove
the -common Docker-SELinux docker- Engine
4, install the required packages, yum-util-config- provide yum Manager function, the other two one is dependent devicemapper driving
the sudo yum the install
-Y-yum-utils devicemapper persistent- Data LVM2
. 5 , yum source provided
the sudo yum
-config-Manager---add the repo https://download.docker.com/linux/ CentOS / docker- ce.repo
6 , you can view all versions of all warehouse docker, and select a particular version installed
yum list docker
--showduplicates -ce | the Sort - r
7 , install docker
sudo yum install docker
- ce
8 , start and join startup
sudo systemctl Start docker
sudo systemctl enable docker
9 , verify that the installation was successful (there are two parts, client and service representation installation docker launch had been successful)
Docker Version

Then download the official docker mirrored jenkins

docker pull jenkins/jenkins

View Mirror docker images

Read and write files to create a directory on the host, and add read-write access to applications running jenkins

mkdir /root/j_node
chmod 777 /root/j_node

The background image from the service in the form of a container, port mapping, while the just created directory is mounted to the container

docker run -d --name jenkins -p 8081:8080 -p 50000:50000 -v /root/j_node:/var/jenkins_home jenkins/jenkins

Note here that, if it is, then Ali cloud, security policy needs to be exposed port 8081

Through the Web site at http: // your ip: 8081

Then get install command keys

docker logs jenkins

With the password, enter the installation recommendations of the plug-in, plug-in contains the recommended version control software git.

After completion, the prompts to set access your account.

Then create a new project, the source code control the column, you enter the line item git repository address, note that the default should be the master branch, because the code is deployed in a production environment must be the main branch

After saving, click Build Now deploy, jenkins will automatically go git repository to extract the latest master branch to deploy, at the same time once every deployment history will be preserved

At this point, enter the / root / directory found under j_node project has been deployed in the workspace directory

The whole process is very simple, every time before the line, the project manager need only check the individual members of the code, and then merged into the master branch unified master, and finally into jenkins click the button deployment, saving a lot of time.

Guess you like

Origin www.linuxidc.com/Linux/2019-06/158946.htm