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
Background Recently, I encountered such a problem...
1 Download MySQL8 from the official website and i...
It's the end of the year and there are fewer ...
NAT In this way, the virtual machine's networ...
This article example shares the specific code of ...
Preface The computer I use is a Mac, and the oper...
The detailed process of using MySQL database with...
error message: ERROR 1862 (HY000): Your password ...
First, download the installation package from the...
This article shares the specific code of js to ac...
1. Command Introduction The file command is used ...
After installing a centos8 service under vmware a...
Regarding some MySQL specifications, some compani...
Table of contents ReactHooks Preface WhyHooks? Fo...
Table of contents Written in front Requirements A...