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
Create a table CREATE TABLE `map` ( `id` int(11) ...
This article example shares the specific code of ...
Table of contents 1. Introduction to label statem...
Table of contents Preface Case optimization summa...
When I was writing the login page today, I needed...
Preface In the last issue, we explained LinearLay...
The document has been written for a while, but I ...
Scenario How to correctly render lists up to 1000...
1 System Installation Steps OS Version:1804 Image...
Table of contents 1. Check the current status of ...
1. Dynamic query rules The dynamic query rules ar...
summary: The following is a method for changing t...
This article aims to clarify the relationship bet...
Today, when I was using Nginx, a 500 error occurr...
Using Javascript to implement countdown to close ...