In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-27 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)05/31 Report--
This article introduces the knowledge of "how to deploy the docker+gitlab+gitlab-runner environment". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!
Environment
Server: centos7
Client: window
By deploying docker+gitlab+gitlab-runner,win10 on centos7 using ssh connection, developers can upload project files, package images, release and run tests by submitting code.
Install docker and docker-compose on centos7
Install docker:
1. Docker requires that the kernel version of the centos system is higher than 3.10. Check the prerequisites on this page to verify whether your centos version supports docker.
Check your current kernel version with the uname-r command
2. Log in to centos with root permission. Make sure the yum package is up to date.
3. Uninstall the old version (if the old version is installed)
4. Install the required software packages. Yum-util provides yum-config-manager functions, and the other two are dependent on devicemapper drivers.
5. Set the yum source
6. You can view all docker versions in all repositories and select a specific version to install
7. Install docker
8. Start and join the boot boot
9. Verify whether the installation is successful (both client and service indicate that the docker installation starts successfully)
10. It is recommended to replace the mirror source of docker:
1. Modify or create a daemon.json file: vi / etc/docker/daemon.json
Write the following configuration to a file, save and exit (if you don't know how to operate, issue the vi command from Baidu):
two。 Restart docker:systemctl restart docker
Install docker-compose:
Refer to the official website:
1 、 run this command to download the latest version of docker compose:
2 、 apply executable permissions to the binary:
2. Pull the image of gitlab Chinese version
Address:
1. Use xshell+xftp to create a folder in centos7 to store logs, configurations and data.
The folder structure is as follows:
2. Start with docker-compose.yml
If your server has a domain name, replace the above gitlab.domain.com with the actual domain name.
During the experiment, you can also modify / etc/hosts directly to facilitate testing. For example: 127.0.0.1 gitlab.example.com
3. Cd to the gitlab directory to execute docker-compose up-d startup, wait a moment.
4. Open a browser to access gitlab.domain.com after startup
5. Ssh connects to gitlab
First we need to get a ssh key, enter
If the character "ssh-rsa" appears, it means that we already have a ssh key locally, then we can use it directly. If not, we need to create a ssh key ourselves.
6. Create ssh key
Enter the following command to create a ssh key.
When you are finished, you can enter the above cat command or pbcopy to copy the generated ssh key directly.
In the gitlab account-"Settings, find the ssh keys to add this key."
7. Ssh connects to port 1022
Normally you can use the git command to connect to our deployed gitlab, but the difference here is that we have mapped port 22 of the container to 1022 of host, and we need to specify a port to connect.
We also need to change the ssh port in the configuration file of gitlab (not if it has been configured above), otherwise the project connection address generated for us in gitlab will not be connected. / gitlab/config/gitlab.rb
Restart the gitlab container after changing the ssh port, and then the ssh connection address of our project will be:
At this point, we have completed the deployment of gitlab.
3. Pull gitlab-runner image
Address:
1. Use xshell+xftp to create a folder in centos7 to store logs, configurations and data.
The folder structure is as follows:
2. Start with docker-compose.yml
Where gitlab_default is the network of the above gitlab
Note: the version of gitlab-runner should correspond to gitlab as much as possible, otherwise there will be no connection to gitlab.
3. Cd to gitlab directory to execute docker-compose up-d startup
4. Configure gitlab-runner to connect to gitlab
1. Register gitlab-runner
two。 We will enter http://gitlab.domain.com or http://ip:port, which is the gitlab that we installed locally.
3. Please enter the gitlab-ci token for this runner requires input gitlab-ci token
It can be found in the project management area-> runners (here the share type runner is registered)
4. Enter a description, such as: test
5. Enter tag (leave it blank, you can edit it later)
6. To choose whether or not to execute an untagged submission, we choose true
7. Whether to lock this runner to the current project, we choose false
8. Choose an executor, executor
This step is important (ssh, docker+machine, docker-ssh+machine, kubernetes, docker, parallels, virtualbox, docker-ssh, shell)
We choose docker.
9. Select the default image: docker:stable
After registering, we can see the runner we just registered on the page where gitlab gets the gitlab-ci token.
At the same time, you can see the file that generates a config.toml under gitlab-runner/config, with the following contents:
Or just configure it first, and the configuration file will be loaded automatically by the gitlab-runner runtime.
Reference address:
5. Submit the project code to complete ci/cd
1. Add the. gitlab-ci.yml to the root directory of the project, and automatically run the file to package the project after submitting the project code
2. Submit the code through git on win10
Cd to the root directory of the project. If git is installed, you can open git bash directly under the root directory for execution, or open powershell if there is no installation.
That's all for "how to deploy the docker+gitlab+gitlab-runner Environment". Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.