preface

It’s been on hold for a couple of months, going through lay-offs, travel, job hunting, hiring, and now it’s slowly getting back on the road

This is a continuous article, divided into the following stages, with one article in each stage (this is the last section) :

  • Introduction and use of the entire project process and achieved and unachieved goals
  • Overall analysis of vue3.0 used in the front end and what pits we will use in the future
  • How does the NodeJS backend do strong type qualification like Java springMVC
  • How to realize automatic cluster deployment of the whole project on small server

This article is just some automation tools I built, just to share with you my server as a whole what things

About my server

At present, I buy a 5M broadband server of Tianyi Cloud (relatively speaking, more than 200 points a year is cheap when I am engaged in activities), and then install the Centos7 + version of the system and connect the server with xshell + XFTP

I would like to mention here that I would install pagoda Linux system directly at the beginning when I got the server, but something went wrong later, which led to the reinstallation of the whole system (which happened to use Docker for service deployment after most of the migration).

Then there is a server, is borrowed from a friend, a 1M broadband small server, used specifically to form a cluster

Code management

Now my code is basically managed in Gitee (I have also been updating Github synchronously recently). I thought about building gitLab before, but I gave up because of my small server.

So the automation behind is to use Gitee’s Webhook to trigger the implementation.

jenkins

In order to keep up with The Times, all the construction was done by Jenkins, but from this stage on I gradually lost track of the best way to do it. Finally, THE solution I adopted was to package the front and back ends into a Docker image, and then publish the package. Here is the shell I executed:

Vue front-end scripts

#! /bin/bash echo $PATH cnpm install cnpm run build rm -rf .. /vue-assemble-ui-node/public/assemble/ cp -r assemble .. /vue-assemble-ui-node/publicCopy the code

Node background script

#! /bin/bash echo $PATH IMAGE_NAME='registry.cn-hangzhou.aliyuncs.com/bymycode/vue-assemble-ui' IMAGE_VERSION=$(date "H + % Y % m % d % % m % S") echo IMAGE_NAME = $IMAGE_NAME echo '= = = = = = = = = = = = = = = = begin to create image = = = = = = = = = = = = = = = =' docker build - t $IMAGE_NAME:$IMAGE_VERSION . docker tag $IMAGE_NAME:$IMAGE_VERSION $IMAGE_NAME:latest echo '= = = = = = = = = = = = = = = = began to push the mirror = = = = = = = = = = = = = = = =' docker login - username = * * * * * * *, password = * * * * * registry.cn-hangzhou.aliyuncs.com docker push $IMAGE_NAME:$IMAGE_VERSION docker push $IMAGE_NAME:latest echo '====================OK! = = = = = = = = = = = = = = = = 'Copy the code

In fact, the front end simply builds the dist folder and replaces the content of the back end, and then triggers the back end construction to generate the Docker package for push release

Image management

For the mirror management, I used the volume mirror service of Ali Cloud, and then created a trigger that could trigger the automatic deployment after the mirror push was completed.

Then there are a lot of explanations about ali Cloud on the Internet, so I will not introduce it.

Portainer

This is a platform that allows you to visually view your own volume, image, service and stack. The introduction method is also very simple, just need to execute Docker pull down. Thank you, you can search the name to find detailed instructions.

Then we can use this visualization to fill in the trigger link of the Ali Cloud, which will automatically trigger the pull and deployment of our service

Note that since our package belongs to the private library, we need to create a service pointing to the private library. Therefore, we recommend using the command line to create the service, otherwise it may not pull down the problem. My build statement looks like this

docker service create -p 9988:9988 --network vue-assemble-net --replicas 2 --name vue-assemble-ui --no-resolve-image --with-registry-auth registry.cn-hangzhou.aliyuncs.com/bymycode/vue-assemble-ui:latest
Copy the code

additional

So that’s basically what I’m using here, and then I’m using nginx to do a simple load balancing, like this:

Upstream vueAssemble{server 127.0.0.1:9988 weight=5; Server 127.0.0.1:6090 weight = 1; }Copy the code

One final word of caution:

In the case of installing Pagoda Linux, both servers failed to delegate the port normally. Finally, it was found that pagoda added an Nginx block in the normal environment, so you need to delegate the port locally in pagoda Nginx (please contact me for details).

At the end

That is all there is in this paper, the delay for a few months after finally finished update (though not necessarily someone see 😅), in this or forecast the following content: previous articles will be git automation submission tool to develop an open source library released 📢, stay in my next article update hope can facilitate everybody development git commits.

Finally, I hope you can give the project a little star

Making: github.com/wyx11223344…

Gitee: gitee.com/beon/vue-as…

Online access: http://36.111.183.168:9527/

If you have any questions or want me to help you with the development, please feel free to comment on my private chat, and post my wechat QR code below.