introduce

  • React (UMI) is used in the front end and Egg is used in the node
  • Front-end deployment Jenkins + Gitee
  • An egg to deploy Jenkins

1. Automatic deployment of front-end projects

React (umi) Precautions We need to use hash:true. Contenthash :8 is used by default for hash umijs

1.1,Jenkins installation

1.2 The plug-in that needs to be downloaded after Jenkins is successfully installed

  • Nodejs Note: Jenkins will need to be restarted after downloading successfully
  • SSH related plug-ins
  • Gitee manages code through the code cloud

1.3, gitee

Enter Jenkins container and generate public and private keys

Docker exec it [Jenkins container ID] /bin/bash CD /root/.ssh// Check to see if there are public keys and keys
ssh-keygen -t rsa // Generate public and private keysAfter generation, put the public key in Gitee and the private key in JenkinsCopy the code

1.4 Jenkins deployment begins

  • When we deploy the project, add the private key location

  • Build the trigger, select Gitee

  • Build environment

  • Build, select shell

npm install –registry=registry.npm.taobao.org

  • After the build is complete, upload the target server
# copy cp -r /home/packagea/* home/cp/packageB/ # move mv home/packageA/* home/packageB/ #Copy the code

2. Egg deployment

Note: you need to use hostname:0.0.0.0 instead of 127.0.0.1, otherwise you will have startup problems

Cross domain, we use nGINx reverse proxy way to solve cross domain

# nginx/conf.d/default.conf # interface forward location ~/api/ {
  proxy_pass http://xxx:7002;
}
Copy the code

Jenkins continues to deploy major configurations

3. Jenkins container time zone problem

The default time of Jenkins container is American time. The following is the modification method

Docker exec -it [Jenkins container ID] /bin/bash

Linux The time zone is changed to Shanghai time

In the third step, vi /etc/sysconfig/clock, the corresponding file cannot be found. The following is the replacement step

  • echo Asia/Shanghai >/etc/timezone

All other operations remain the same

4. Jenkins set parameters