Docker + LNMP + Jenkins + code cloud to realize automatic deployment of PHP code

Time:2020-11-3

Automated Deployment (continuous integration / CI + continuous delivery / CD) is a trend of software development, which is a good help to Devops. Today’s practice is based on docker + Jenkins + LNMP + code cloud to realize the automatic deployment process of PHP code.

Environment configuration

Operating system: CentOS Linux release 7.6.1810

Docker installation

Please refer to this article:CentOS install docker

Docker installing LNMP environment

Please refer to this article:Customizing LNMP environment by dockerfile

Docker install Jenkins

Please refer to this article:Docker builds Jenkins to realize automatic deployment

Code cloud warehouse preparation

Create project warehouse

Docker + LNMP + Jenkins + code cloud to realize automatic deployment of PHP code

Jenkins, get ready

Installing the SSH plug-in

Because of the need to execute some shell commands of the server, SSH login is used to communicate with the remote server.

Docker + LNMP + Jenkins + code cloud to realize automatic deployment of PHP code

Docker + LNMP + Jenkins + code cloud to realize automatic deployment of PHP code

New project task

The task name cannot be in Chinese. Select the first one: freestyle project custom project

Docker + LNMP + Jenkins + code cloud to realize automatic deployment of PHP code

Project task configuration

1. Source management selection: Git

Docker + LNMP + Jenkins + code cloud to realize automatic deployment of PHP code

Docker + LNMP + Jenkins + code cloud to realize automatic deployment of PHP code

After the credential configuration is successful, select the user name of the previous credential configuration. If the warehouse address is successfully connected, no error will be reported.

Docker + LNMP + Jenkins + code cloud to realize automatic deployment of PHP code

Build trigger selection: GitHub hook trigger for gitscm polling

Docker + LNMP + Jenkins + code cloud to realize automatic deployment of PHP code

Build environment: use secret text (s) or file (s) / / transfer files in private mode

Docker + LNMP + Jenkins + code cloud to realize automatic deployment of PHP code

Configure SSH

1. System Management > system configuration

Docker + LNMP + Jenkins + code cloud to realize automatic deployment of PHP code

Docker + LNMP + Jenkins + code cloud to realize automatic deployment of PHP code

Configure build shell scripts

Build: execute shell script on remote host Using SSH / / execute remote server shell script during build

Docker + LNMP + Jenkins + code cloud to realize automatic deployment of PHP code

Docker + LNMP + Jenkins + code cloud to realize automatic deployment of PHP code

After configuration, click save

Code cloud code push

Code cloud warehouse modifies the code, and then submits PR to the master branch

Docker + LNMP + Jenkins + code cloud to realize automatic deployment of PHP code

Docker + LNMP + Jenkins + code cloud to realize automatic deployment of PHP code

Deployment task manual build

Manually click build to realize code automatic deployment

Docker + LNMP + Jenkins + code cloud to realize automatic deployment of PHP code

Docker + LNMP + Jenkins + code cloud to realize automatic deployment of PHP code

If the task fails to build, there will be an error message and a red flag / / which is very convenient for management

Docker + LNMP + Jenkins + code cloud to realize automatic deployment of PHP code

Docker + LNMP + Jenkins + code cloud to realize automatic deployment of PHP code

Visit the website

After the automatic deployment task is successfully built, visit our project to see the modification effect

Docker + LNMP + Jenkins + code cloud to realize automatic deployment of PHP code

This work adoptsCC agreementThe author and the link to this article must be indicated in the reprint


Aduh

Recommended Today

Common auxiliary classes

CountDownLatch Subtraction counter import java.util.concurrent.CountDownLatch; //Counter public class CountDownLatchDemo { public static void main(String[] args) throws InterruptedException { //The total number is 6. It can be used when the task must be performed CountDownLatch countDownLatch = new CountDownLatch(6); for (int i = 0; i < 6; i++) { new Thread(()->{ System.out.println(Thread.currentThread().getName()+” Go out”); countDownLatch.countDown(); },String.valueOf(i)).start(); […]