navigation
[Deep 01] Execution context [Deep 02] Prototype chain [Deep 03] Inheritance [Deep 04] Event loop [Deep 05] Curri Bias function [Deep 06] Function memory [Deep 07] Implicit conversions and operators [Deep 07] Browser caching mechanism (HTTP caching mechanism) [Deep 08] Front-end security [Deep 09] Deep copy [Deep 10] Debounce Throttle [Deep 10] Front-end routing [Deep 12] Front-end modularization [Deep 13] Observer mode Publish subscribe mode Bidirectional data binding [Deep 14] Canvas [Deep 15] webSocket Webpack HTTP and HTTPS CSS- Interview Handwriting Promise
[react] Hooks
[Deployment 01] Nginx [Deployment 02] Docker deployVue project [Deployment 03] gitlab-CI
[source code – Webpack01 – precompiler] AST abstract syntax tree [source code – Webpack02 – Precompiler] Tapable [source code – Webpack03] hand written webpack-compiler simple compilation process [source code] Redux React-redux01 [source] Axios [source] vuex [source -vue01] Data reactive and initialize render [source -vue02] Computed responsive – Initialize, access, Update Procedure [source -vue04] Watch Listening properties – Initialize and update [source -vue04] vue. set and vm.$set [source -vue05] vue.extend
Vue. NextTick and VM.$nextTick
Front knowledge
Some words
2. The cI-continuous Integration, reference to the special consideration prior to the conversion, Prior to getting started You may want to hold yourself with these prior to getting started You might want to familiarize yourself with this before you start.) Pipeline explain brief, indent attention. (2) You have to pay extra attention to indentation (2) I didn't leave the factory. It is necessary to be Specific and fundamental. Jobs are the most fundamental element of a. gitlab-ci.yml file. Reserved: Reserved keywords are used. Artifacts: Artifacts SSH key pair Recursive: RecursionCopy the code
Some common Linux commands
- which
- whichThe "search" command searches for the location of a system command in the PATH specified by the PATH variable and returns the first search result. - When the first program file that meets the requirements is found, the search is stopped immediately and the remaining unsearched directories are omitted. - That is to say, usewhichCommand, you can see whether a certain system command exists, and the execution of the exactly which location of the command. -scp-scp [optional parameter] file_source file_target - -r: Recursively copies the entire directory. 1. Copy from local to remote SCP local_file remote_IP :remote_folder SCP local_file remote_username@remote_ip:remote_folder Specifies the username - Ssh-keyscan - Browse the SSH common key on the system - ssh-t [email protected] - verify that the SSH key uname is correctly added on gitlab-a-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- check the server environment / / such as: Linux VM_0_16_centos 3.10.0-862. El7. X86_64#1 SMP Fri Apr 20 16:44:24 UTC 2018 x86_64 x86_64 x86_64 GNU/LinuxMkdir -p -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- recursive create the directory folder mkdir -p create a/b a/b such a relationship between two folders su user name -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- Switch user name su root Switch to user root su gitlab-runner Switch to user gitlab-root Su is whoami of switch user -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- to view the current login user name su gitlab - runner whoami / / gitlab - runner SCP -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- the user copies files and directory SCP is the abbreviation of secure copy - safe copy SCP/optional parameters file_source file_target - r: Recursively copy the entire directory (recursively) scp-r${DIST_DIR}[email protected]: / root/d /Copy the code
Pipeline, Pipeline
A Pipeline is actually equivalent to a build task, which can contain multiple processes, such as install dependencies, run tests, compile, deploy test servers, deploy production servers and other processes. Any Merge of submit or Merge requests can trigger a Pipeline
- One pipeline equals one (build task) and contains multiple (processes)
- Push or merge request
+------------------+ +----------------+
| | trigger | |
| Commit / MR +---------->+ Pipeline |
| | | |
+------------------+ +----------------+
Copy the code
Stages – The construction phase
Stages, which stands for the construction phase, is the process above. Multiple Stages can be defined in a Pipeline
- Sequence: All Stages run sequentially, that is, when one Stage is completed, the next Stage starts
- Success: The build task (Pipeline) is successful only when all Stages are completed
- Failure: If any Stage fails, the later Stages do not execute and the build task (Pipeline) fails
- Conclusion:
- A pipeline contains multiple stages
- The next stage can be executed only after the previous stage is executed
- Pipeline is successful only when all stages are successful. If only one stage fails, the entire pipeline will fail
+--------------------------------------------------------+
| |
| Pipeline |
| |
| +-----------+ +------------+ +------------+ |
| | Stage 1 |---->| Stage 2 |----->| Stage 3 | |
| +-----------+ +------------+ +------------+ |
| |
+--------------------------------------------------------+
Copy the code
Jobs – the work of building
Jobs represents the build work, the work performed within a Stage. You can define multiple Jobs in Stages
- Order: Jobs in the same Stage are executed (in parallel)
- Success: A Stage is successful only when all Jobs in the same Stage are successfully executed
- Failure: If any Job fails, then the Stage fails, that is, the build task (Pipeline) fails
- Conclusion:
A Pipeline contains multiple stages and a Stage contains multiple jobs.
(Stage) in the (Job) is (parallel) -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- the Job in parallel
If the Job is successful, the Stage is successful
A (Job) failure, (Stage) failure, (Pipeline) failure
+------------------------------------------+
| |
| Stage 1 |
| |
| +---------+ +---------+ +---------+ |
| | Job 1 | | Job 2 | | Job 3 | |
| +---------+ +---------+ +---------+ |
| |
+------------------------------------------+
Copy the code
YAML language basics
- Yaml is a language for writing configuration files. The important thing to notice is indentation
#
Represents a comment, which is ignored by the parser all the way to the end of the line.- There are three kinds of data structures: object, array, and scalar
(1) the scalar - individual, not the value of the floating-point number Null string Boolean value integer time date - Null: use ~ said - the parent: ~ - into js -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- {parent: Null} -string - If the string contains (Spaces) or (special characters), it must be inside (quotes) -str:'Content: string'----------------------------- {parent: Null} - can be used for single and double quotes, double quotes will not escape to the special characters - multi-line string can use (|) retain a newline, can also use the fold line (>). - (+) preserves the newline at the end of the text block, and (-) deletes the newline at the end of the string. - references - (&) anchors - (*) aliases, note: * is used to refer to -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- namely & representative content - * (&) is used to establish the anchor (defaults), a (< <) incorporated into the current data, used to refer to the anchor point (*). defaults: &defaults --------------------------------------------------- & adapter: postgres host: localhost development: database: myapp_development <<: *defaults ------------------------------------------------------- *test: database: myapp_test <<: *defaults equals to defaults: Adapter: postgres host: localhost development: database: Myapp_development adapter: postgres -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- - * & replace the content of the host: localhosttest: database: myapp_test Adapter: postgres host: localhost (2) Pets into js -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- {animal:'pets'} (3) - a group of conjunction line at the beginning of line array, constitute an array - Cat - Dog - Goldfish into js -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -'Cat'.'Dog'.'Goldfish'] -- -- Cat Dog - Goldfish into js -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- [['Cat'.'Dog'.'Goldfish'] (4) languages: -ruby-perl-python websites: YAML: yaml.org Ruby: ruby-lang.org Python: python.org Use.perl.org = js {languages: ['Ruby'.'Perl'.'Python' ],
websites:
{ YAML: 'yaml.org',
Ruby: 'ruby-lang.org',
Python: 'python.org',
Perl: 'use.perl.org'}}Copy the code
The RPM package
- The RPM file
- Naming rules:
<name>-<version>-<release>.<arch>.rpm
- Name: indicates the name of the package, including the main package name and subcontract name
- Version: indicates the version of the package
- Release: Identifies the release number of the RPM package itself and may include the applicable operating system
- Arch: indicates the host platform. Noarch means that this package can be installed on any platform, irrespective of the architecture
sshpass
- Sshpass is a simple, lightweight command-line tool.
- Yum install -y sshpass
- Install: apt-get install -y sshpass
- Common operations are as follows
1. Connect to the local host sshpass -p XXXX SSH xxx@xxx sshpass -p {password} SSH {user name}@{host IP address} 2. Connect the remote host sshpass -p {password} SSH -p {port number} {user name}@{host IP address} 3. Read the password in the file to connect to the remote host sshpass-fSSH {user name}@{host IP address} 4. Copy the directory from the remote host to the local!! Sshpass -p {password} SCP {username}@{host}:{remote directory} {local directory or file} 5. Copy from local to remote!! Sshpass -p {password} SCP {local directory} {username}@{host}:{remote directory} 6. Connect to the remote host and execute the command!! Sshpass -p {password} ssh-o StrictHostKeyChecking=no {user name}@{host IP address} Command to be executed // -o StrictHostKeyChecking=no: ignore the password prompt // For example'rm -rf /tmp/test
Copy the code
Yum (centos) and apt-get(Ubuntu
- Yum and apt-get are package management tools. Yum is mainly used for centos, and apt-get is mainly used for Ubuntu
Redhat: Redhat, Centos, and Fedora Redhat: Debian, Ubuntu Redhat: Redhat, Debian, and Ubuntu Redhat 1. Common installation packages are in the following format: RPM package. RPM - parameter 2, package management tool: yum 3, support tar package Debian series 1, common installation package format: deb, install deb command: DKG - parameter 2, package management tool: apt-get 3, support tar packageCopy the code
Setting up CI continuous integration requires only two steps
- (1) Create a.gitlab-ci.yml file in the project directory
- (2) Install GitLab Runner on the server
- Note: The Executor for GitLab Runner is the Dokcer used in this article
(a). Gitlab – ci. Yml
- After the code is pushed to the Gitlab repository or when merge-requset, Gitlab will parse the. Gitlab-cli. Yml file and call the corresponding runner to execute the job in the stage of pipeline
- To verify that.gitlab-ci.yml has syntax errors, use CI Lint
- Gitlab-ci. yml official website document
- The following table lists the parameters
The keyword | describe |
---|---|
script | Shell scripts that can be executed by runner, who needs to install GitLab Runner on the server |
stages | Definition of pipeline stage, (that is, define the construction phase) is an array — — — — — — — — — — — — — — — — — — — all of the stage |
stage | A job process, the default test — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — the specific stage |
variables | Define a variable |
image | Use docker images. Also available: image: name and image: entryPoint |
tags | Manage or match runners by tag, that is, which runner is used to execute the job |
cache | List of files that should be cached between subsequent runs. Also available: Cache: Paths, cache: key, cache: untracked and cache: policy. |
only | Specify a list of Git refs(branches, tags) for the current job ———– branch, variable, change, etc |
except | In addition to other what branch of git, use the job — — — — — — — — — — — — — — — — — branch, variables, change, etc |
artifacts | Pass the dependencies generated by this job to the next job To pass results between stages, it is common to define files that are packaged in the build phase as artifacts that can be used directly in the deploy phase expire_in: The expiration time of artiFacets. Since these data are kept on Gitlab machines, resources that are too old can be deleted pathsThe: path is relative to the project directory ($CI_PROJECT_DIR) and cannot be linked directly outside it. Wildcards that follow wildcard patterns and filepath.Match can be used. |
- Gitlab CI Predefined environment variables]
- Gitlab CI Predefined environment variables
- she key
- SSH Key: When your CI/CD jobs are running in a Docker container (meaning the environment is included) and you want to deploy your code on a private server, you need a way to access it. This is where SSH key pairs come in handy.
- Note that docker is used here, so see the link below
- SSH keys when using the Docker executor
- Generating a new SSH key pair
- Generating a new SSH key pair Generating a new SSH key pair before setting an SSH key
# image: Docker image
image: node
# Define variables
variables:
CENTOS_IP: '[email protected]'
# cache
cash:
path:
- node_modules/
# statges: All phases of the build, an array states
# state: You can also use stage for each job
stages:
- echo
- build
- deploy
echo-statge:
stage: echo
tags:
- dockernoderunner
only:
- master
script:
echo ${CI_COMMIT_SHA}
echo ${CI_PROJECT_NAME}
echo ${CI_PROJECT_NAMESPACE}
echo ${CI_PROJECT_PATH}
echo ${CI_PROJECT_URL}
echo ${GITLAB_USER_NAME}
echo ${GITLAB_USER_EMAIL}
echo ${CI_PROJECT_DIR}
echo ${CI_PIPELINE_ID}
echo ${CI_COMMIT_REF_NAME}
# build-stage: The name of each job, which can be arbitrary, is an object
build-stage:
# stage: Needs to correspond to the values in the array in stages
stage: build
The tags are used to execute different runners for different jobs
tags:
- dockernoderunner
script:
- npm install --registry=https://registry.npm.taobao.org
- npm run build --registry=https://registry.npm.taobao.org
# only: only pushes or merges on the master branch
only:
- master
Artifacts: Artifacts that are passed to the next job, passing the dist folder
artifacts:
# expire_in: Expiration time
expire_in: 1 week
paths:
Setting -> CI/CD -> Variables
# - ${DIST_DIR
- $DIST_DIR
deploy-stage:
stage: deploy
only:
- master
tags:
- dockernoderunner
before_script:
# SSH no-password login is required when executing script
# Create the SSH_PRIVATE_KEY variable
- 'which ssh-agent || ( apt-get update -y && apt-get install openssh-client -y )'
- eval $(ssh-agent -s)
- echo "$SSH_PRIVATE_KEY" | tr -d '\r' | ssh-add -
- mkdir -p ~/.ssh
- chmod 700 ~/.ssh
- echo "$SSH_KNOWN_HOSTS" > ~/.ssh/known_hosts
- chmod 644 ~/.ssh/known_hosts
# #
## You can optionally disable host key checking. Be aware that by adding that
## you are susceptible to man-in-the-middle attacks.
## WARNING: Use this only with the Docker executor, if you use it with shell
## you will overwrite your user's SSH config.
# #
# - '[[ -f /.dockerenv ]] && echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config'
# -ssh-p22 [email protected]
script:
# -ssh-p22 [email protected]
# -sshpase-p ${PASSWORD} SSH -p 22 [email protected]
# - yum -y install sshpass
- apt-get update
- apt-get install -y sshpass
- sshpass -p ${PASSWORD} scp -r ${DIST_DIR}[email protected]: / root/d /# [ssh key](https://docs.gitlab.com/ee/ci/ssh_keys/README.html)
# - When your CI/CD jobs are running in a Docker container (meaning the environment is included) and you want to deploy your code on a private server, you need a way to access it. This is where SSH key pairs come in handy.
# [Generating a new SSH key pair] (https://docs.gitlab.com/ee/ssh/README.html#generating-a-new-ssh-key-pair) in the set up SSH Key You need to generate an SSH key pair
After copying the files to the server, you can use the Nginx container to do the data volume mapping to start the service of the latest code
Copy the code
(二) gitlab runner
(1) Download and install on CentOS Linux (Gitlab Runner)
- Download the RPM package for Gitlab Runner
- Install GitLab Runner installation tutorial
- Sign up for the GitLab Runner Registration tutorial
- Note: Here runner’s executor selects docker-image as node
Download the RMP package for GitLab Runner // curl -lJO https://gitlab-runner-downloads.s3.amazonaws.com/latest/rpm/gitlab-runner_<arch>.rpm curl -LJO https://gitlab-runner-downloads.s3.amazonaws.com/latest/rpm/gitlab-runner_amd64.rpm / / curl: // -l /--location: trace redirection // -j: // -o /--remote-name: write output to this file, keep the name of the remote file // <arch> : Note: If the download is slow, Windows platform can be downloaded after the local xshell and XFTP directly to the server // Note: I am using Tencent cloud serverCopy the code
Install gitlab runner's RMP package RPM -i gitlab-runner_amd64. RPM error: Failed dependencies: Git is needed by Gitlab-runner 12.8.0-1.x86_64 --nodeps --force RPM -i gitlab-runner_amd64. RPM --nodeps --force // Install git if you don't have gitCopy the code
Registering a Runner is the process of binding a Runner to a GitLab instance. 3. There are two things you need to do before registering GitLab Runner: (1) Install Doker, Docker-docker pull nod-docker run-id --name=node_c1 node (2) CI/CD -> Runners 4. The Gitlab Runner register allows you to use interactivity, Please enter the gitlab-ci coordinator URL (e.g. https://gitlab.com/):) https://gitlab.com/ 2. Please enter the gitlab-ci tokenfor this runner
_GAFfSTQcz57k-hWzowr
3. Please enter the gitlab-ci description for this runner
runner-test
4. Please enter the gitlab-ci tags forthis runner (comma separated): tag-test 5. Please enter the executor: ssh, docker+machine, docker-ssh+machine, kubernetes, docker, parallels, virtualbox, docker-ssh, shell: Docker 6. Please enter the Docker image (eg. Ruby :2.6): nodeCopy the code
-
Error while adding the deploy key:
-
Fingerprint has already been taken, Deploy keys projects deploy key fingerprint has already been taken
-
An error is reported during the deployment phase after build
-
Host key verification failed.
- Blog.csdn.net/ljw1412/art…
- Blog.csdn.net/ljw1412/art…
- gitlab-runner is not in the sudoers file.This incident will be reported. The solution of
data
Description juejin.cn/post/684490… A simple. Gitlab – ci. Yml file configuration segmentfault.com/a/119000001… Deploying a simple vue project www.jianshu.com/p/4bbef46a2… The RPM file literacy www.jianshu.com/p/27ebb82d2… Gitlab runner installation tutorial www.jianshu.com/p/1c1ecd3ce… Gitlab Runner installation steps: juejin.cn/post/684490… The curl command: www.jianshu.com/p/07c4dddae… Keyword blog.didiyun.com/index.php/2. Gitlab – ci. Yml… . Gitlab – ci. Yml keyword, rounding cloud.tencent.com/developer/a…
Available yml configuration text blog.csdn.net/BalaBalaYi/ 】… [Available YML configuration files] juejin.cn/post/684490… 【 】 juejin. Cn/post / 684490… [Available YML configuration files] juejin.cn/post/684490… Segmentfault.com/a/119000002 available yml configuration file 】 【… 【 】 www.jqhtml.com/50142.html
Sshpass common commands linux.51yip.com/search/sshp…