How to build a private remote warehouse Gitlab on Windows

  • 1.Background
  • 2. Implementation steps
    • 2.1 Install Docker
    • 2.2 Install Gitlab and deploy
    • 2.3 Launch GitLab via the Web
    • 2.4 Change GitLab password

1. Background

Let me talk about the background first. Since the computer does not have a Linux system, it is a Win10 system, but the team requires it to be deployed in a remote warehouse on its own server. This is because the code has protection requirements and is always unsafe on a human server. There are several options here. The first is Github. Due to scientific Internet requirements, file transfer is too slow; then there is Gitee, a domestic server, but the number of collaborative developers allowed is limited. I remember correctly it should be 5. It seems that the private free library There are also size restrictions;
Finally, we recommend 3 plans, you can choose them according to your needs:
①VisualSVN solution: Using SVN, an ancient software, is very useful. However, considering that most of my work is code, not art resources, it is not used. However, it is also very simple to deploy. I will provide a tutorial on another blog;
②BonoboGtiServer solution: It is good to choose BonoboGitServer. It can be easily deployed on Windows. The disadvantage is naturally that it has fewer functions (but it also has the advantage that it does not require a large memory to run. It has basic functions and is enough for a small team). Another blog is dedicated to tutorials;
③GitLab solution: This is the way that most software company teams now achieve private control on their own servers. The only troublesome thing about choosing GitLab is how to deploy it on Win, but in my opinion, it is child’s play. . Doctor – head size 0.0.
Here is the third option. There are a lot of pitfalls in the middle. Follow my step-by-step instructions to ensure there is no problem. Website:yii666.com

2. Implementation steps

2.1 Install Docker

I won’t introduce what Docker is. For the time being, it can be understood as a software engine to avoid installing a virtual system. When the time comes, just let Gitlab run on the Docker container. Before installing, check which version of win10 you have. The home version needs special treatment. I won’t introduce it yet. Here is the professional version 64-bit.
① To install docker, first download docker and then make sure whether the computer has virtual configuration enabled. This should be the case in Win10 Home Edition (not sure, it is said to be). Go to Control Panel-Programs-Turn Windows features on or off-check Hyper-V and click OK to let it configure automatically.


Go to the Docker official website to download DockerWindows. The URL is given below. The installation of this Docker is very simple. Just go all the way to next. You can change the installation path yourself.
Docker download URL:
https://docs.docker.com/desktop/install/windows-install/

②After the installation is completed, find DockerDesktop in the program and run it. A whale icon will appear in the lower right corner of the taskbar.
Then a pop-up box will prompt that you need to install a wsl.msl, and the URL is given in the pop-up box. Just go to the URL given by it to download and install the following one, which is also very fast.

It looks like this after downloading, just double-click to run it. This thing is actually the Linux kernel. I won’t go into more details to avoid being confused (it’s actually unprofessional).

2.2 Install Gitlab and deploy

Make sure DockerDesktop is running, open the cmd run box and enter

docker search gitlab/gitlab-ce
docker pull gitlab/gitlab-ce

Go to the location where you want to install and create three new folders:
DockerData/GitlabData/config
DockerData/GitlabData/log
DockerData/GitlabData/data
For example, I created the config in a folder on the F drive. For example, I created the config in the following path.
f/s111/D/Docker/fazb/DockerData/GitlabData/config

Next is the key point. Many online tutorial problems come from here. There are a few points you must pay attention to before running the following code:
① 8880:8880 and 443:443 in the code below represent mapped ports. Many tutorials write that 80:80 is easily occupied, causing unnecessary trouble, so it is recommended to follow mine directly.
②The path after -v below is the path to the three folders you just created. Note that it must be written according to my writing method, *The drive letter is in lowercase without a colon, there is a slash in front, and the path uses / Spaced, not *
The above two points solve most of the pitfalls, otherwise you will have to wait for problems such as absolute path errors.

docker run -d ^
  --hostname localhost ^
  -p 8880:8880 ^
  -p 443:443 ^
  --name gitlab ^
  --restart unless-stopped ^
  -v /f/s111/D/Docker/fazb/DockerData/GitlabData/config:/etc/gitlab ^
  -v /f/s111/D/Docker/fazb/DockerData/GitlabData/log:/var/log/gitlab ^
  -v /f/s111/D/Docker/fazb/DockerData/GitlabData/data:/var/data/gitlab ^
  gitlab/gitlab-ce:latest

After running the above, if there are no problems, a combination of numbers and letters will be given. This is the ID of the Docker container. It doesn’t matter what it is used for.
③Modify the url by finding the gitlab.rb file in your own installation path and modifying it. Here is
Find the gitlab.rb file under F:\s111\D\Docker\fazb\DockerData\GitlabData\config, open it with text software, and add it at the end. The 192.168.63.90 here is your own server. LAN IP, 8880 is the mapped port number above
external_url http://192.168.63.90:8880’
gitlab_rails[gitlab_ssh_host’] = 192.168.63.90:8880’
gitlab_rails[gitlab_shell_ssh_port’] = 222
④Then enter cmd and restart gitlab

docker restart gitlab

⑤ If there is an error in the above steps, you can first remove the previous container and then re-create it. That is, after removing it, run cmd again and enter the following code, where the container ID is the previous one.

docker rm container ID

Then re-run the code in point 2 to create a container. Article source address https://www.yii666.com/blog/475038.html

2.3 Start GitLab via the Web

1. After ensuring that Docker Desktop is running, open the browser and enter the value you just set, http://192.168.63.90:8880 to access (no one is stupid enough to enter my IP directly) 0.0
Then the key point comes again:
① Not surprisingly, many people encounter the situation that they cannot open it. If you encounter a 502 error, then you only need to wait for a while and then refresh it repeatedly, because the system consumes a lot of memory when running Gitlab, and it takes a certain amount of time to open it. Open
② If it shows access denied, then manually enter http://192.168.63.90:8880 one by one without assigning a value and pasting it, and then check to make sure Docker Desktop is running, otherwise you will definitely not be able to open it.
2. The initial user name for login is root, and the password is in initial_root_password under the config folder above.

Then the key point comes again:
Not surprisingly, if someone says the password is wrong and cannot log in, or they think the password is too anti-human, then just change it.

2.4 Change GitLab password

1. Run cmd and enter the following command. The ID of the current container will be displayed. Are you familiar? This is the combination of numbers and letters given when we created it (it may be shorter, but it is the same). Impact, the same long string as above can be used), this is the ID of the Docker container.

docker ps

2. Enter the following code to enter the container environment

docker exec -it your container’s ID /bin/bash

The cmd at this time should display as follows

Enter the following code after the # above:

cd /opt/gitlab/bin
gitlab-rails console

You will be prompted for some Ruby configuration information, and then you can change the password.
Then the key point came again 0.0
①The password here cannot be simple, such as 12345678, or simple letters.
②u.save! # It is recommended to add one here! , because if the saving fails, you will be prompted with the reason for the failure, so don’t add it! It’s okay to return true. If it is false, it will not prompt where the failure occurred, and will only return false.

u=User.where(id:1).first # Find the root user
u.password='csdnnice123' # Modify the password. The password here cannot be simple, such as 12345678, or simple letters.
u.password_confirmation='csdnnice123' # Confirm password
u.save! # It is recommended to add one here! It will prompt you whether there is an error, otherwise it is okay to return true. If it is false, it will not prompt you where the failure occurred.

Returning true means the modification is successful.
We enter the Web, use the previous http://ip: port, and log in to GitLab again with the root username and the above password!