Whole process online

Flowchart JIRA (project creation) Development (project development) branch(adding modules & branches) test(project testing &bug fixing) artifact(file archives) deployTest(Deployment test environment) Deploy (project live) deployPre jIRA --> Development --> test --> deploy development --> Branch test --> artifact --> Deploy deployTest deploy --> artifact ---> deployPre classDef boxUi fill:#ee5; class jira,development,test,deployPre,deploy boxUi; classDef artifactUI fill:#aea,stroke-dasharray: 4; class artifact artifactUI;

Refine node content

Flowchart Jira (project creation) Development (project development) branch(adding modules & branches) test(project testing &bug fixing) artifact(file archives) subgraph deployTestEnv[Deploy test environment] End deploy subgraph deployProdEnv[Deploy in production] DeployPre --> deployProd end jIRA --> development --> test --> deploy development --> branch test ---> artifact -.. -> deployTest & deployTest1 & deployTest2 deploy --> artifact ----> deployPre classDef boxUi fill:#ee5; class jira,development,test,deployPre,deploy boxUi; classDef artifactUI fill:#aea,stroke-dasharray: 4; class artifact artifactUI;

Optimization of online process

Optimize front-end project speed

The current status quo

Flowchart LR install --> compile --> build --> deploy classDef boxUi fill:#aef,stroke-dasharray: 4; class install boxUi;

== Currently optimizable node == project installed

70% of the changes are business code changes, not package.json, so it is necessary to cache node_module to reduce installation wait time.

1. Front-end process of the current task

Installation and compilation

1. FROM 192.168.100.36:1179/xiaoke/node:12.15.0 AS builder
2. WORKDIR /home/node/app                       Create a working directory
3. COPY package.json .yarnrc /home/node/app/    Copy package.json to the working directory
4. RUN yarn install                             # The project depends on installation
5. COPY . /home/node/app                        Copy the project files to the working directory
6. RUN npm run build:dev                        # project starts compiling
Copy the code
Flowchart flowchart Jenkins[Jenkins Wokspace] subgraph [compile/pack] F1 (flowchart) f2(project package) Artifact (docker) end yarnrc> yarnrc] project[(project)] end Yarnrc --copy--> preinstall preinstall --> f1  --> output output --> f2 f2 --> artifact project --copy--> f1 classDef boxUi fill:#aef,stroke-dasharray: 4; class node_module,preinstall boxUi;

Points that can be optimized

  1. The Node version cannot be selected and needs to be customized separately.
  2. The yarnrc/ NPMRC files need to be copied to the working directory before installation.
  3. The dependency installation node_module directory is regenerated each time.

2. Node_module is cached to the base image

The advantage of fixed versions is that each compile dependency is completely consistent. Disadvantages: Updates are cumbersome Ideal: the user is unaware of using the last node_modules

The optimization scheme will compile

  1. Build a compilation machine

  2. Use the compile machine, which compiles the project code

  3. Node_modules: Mount the local working directory == on the compile machine, and the node_modules generated during installation will be stored on the machine

    This will greatly improve installation efficiency without modifying package.json ==.

  4. Output: After compiling, the Output is also in the local working directory.

  5. The product is packaged and Docker is generated

    1. Copy the Output target compiled in the current working directory into the Docker.
Flowchart subgraph Jenkins[Jenkins Wokspace]; compile[compiler] f1; preinstall; end Package [Docker package] artifact(Docker) end node_module[(node_module)] output[/ intermediate /] end node_module <--volume mount to the compiler --> compile preinstall --> f1 --> output output --COPY--> f2 f2 --> artifact classDef boxUi fill:#aef,stroke-dasharray: 4; class node_module,preinstall boxUi;

On-line process

  1. All live projects must go through Pre and live now.
  2. The test account should not directly deploy production environment permissions.