Long story short, today we will talk about using Gitlab-CI to automatically deploy to remote servers. Friends who have read this article will notice that I automatically deployed the site on the Gitlab-Runner server. This time we will use SSH password-free login Again, CI/CD is essentially a scripting of our manual integration and copy deployment methods. The important aspect of remote deployment is to require password-free control. For Gitlab Runner to deploy to a remote machine, the remote machine must trust
Host: scp /home/gitlab-runner/.ssh/id_rsa.pub The party being controlled: cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys 4. Set permissions on the controlled machine: After that, the master CI machine will have the ability to log in to the remote machine without a password. How to deploy continuously? Continuous deployment using image tag: GitLab project just needs to type the tag --> execute the image building job (with this git tag as the image tag) --> execute the deployment job, get the git tag --> deploy the tag image
build_image:Front-end: stage: build_image script: - docker build -t $DOCKER_REGISTRY_HOST/eap/eap-front-end:$CI_COMMIT_REF_NAME . - docker login $DOCKER_REGISTRY_HOST -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD - docker push $DOCKER_REGISTRY_HOST/eap/eap-front-end:$CI_COMMIT_REF_NAME tags: -my-tag only: - tags deploy:alpha: stage: deploy variables: deploy_path: "/home/eap/website" script: - ssh -t ***@10.202.42.252 "cd $deploy_path && export TAG=$CI_COMMIT_REF_NAME && docker-compose -f docker-compose.yml build && docker-compose -f docker-compose.yml up -d" tags: -my-tag only: - tags The yellow background line above describes the scripting method of ssh remote login-->switch to the deployment directory-->insert the git tag of this build--->execute container deployment. That'all, this article records the process of gitlab-ci continuous deployment to remote machines: ssh password-free login is what I have recently mastered, and the continuous deployment method is simple and practical. This concludes this article on how to use Gitlab-ci to continuously deploy to remote machines (detailed tutorial). For more information about Gitlab-ci continuously deploying to remote machines, please search for previous articles on 123WORDPRESS.COM or continue to browse the following related articles. I hope you will support 123WORDPRESS.COM in the future! You may also be interested in:
|
<<: A quick guide to MySQL indexes
>>: React native ScrollView pull down refresh effect
Table of contents Preface 1. The effect is as sho...
1. Install a virtual machine (physical machine) Y...
I recently encountered a problem. The emoticons o...
Before we begin, we create two tables to demonstr...
1. Naming conventions 1. Database names, table na...
Preface This article uses pdo's preprocessing...
Win10 system locally installed MySQL8.0.20, perso...
"The great river flows eastward, the waves w...
docker-compose.yml version: '2' services:...
1: masterha_check_repl replica set error replicat...
I have been studying how to get https. Recently I...
When using CSS pseudo-elements to control element...
1. Storage Engine In the last section, we mention...
Table of contents 1. Communication method between...
Border Style The border-style property specifies ...