Welcome to my GitHub

Github.com/zq2599/blog…

Content: all original article classification summary and supporting source code, involving Java, Docker, Kubernetes, DevOPS, etc.;

The cause is lazy

Recently, I started to worry about the CI function of GitLab, so I planned to deploy a GitLab at home. The usual practice is to open the computer, start GitLab, and then close the computer after use. I always feel that these operations are quite troublesome (do you want to scold me for being lazy? You are right…..)

Qunhui solve troubles

  1. Home has a QUNhui DS218+, never shut down, for the whole family to provide stable picture and video services, before the deployment of maven private server, MySQL, running very stable, today, GitLab is also deployed in the above, can be used at any time in the future, can be considered as a lazy savior.
  2. The picture below is the appearance of DS218+ just bought, with two NAS hard disks, which have been in stable service:

3. The picture below is the memory bar of online shopping. Now there is a total of 2+8=10G memory.

These links

Previous records of thrashing qunhui:

  1. CDH DS218+ mysql deployment
  2. CDH DS218+ Kafka deployment
  3. CDH DS218+ Maven private server (Nexus3)
  4. K8S uses NFS of QUNhui DS218+
  5. CDH DS218+ Harbor Deployment (1.10.3)

Train of thought

In fact, the operation is very simple: The deployment of GitLab is based on docker-compose, and qunhui has docker-compose. It can be operated according to the official deployment guide. The following points should be noted:

  1. The deployment operation requires administrator rights, so the operation is not performed on the web page, but on the background through SSH.
  2. GitLab had better use domain name to access, if using IP means that the file access address with IP, once the IP is changed, the original file access address is invalid

Environmental information

  1. CDH System: DSM 6.2.2-24922 Update 4
  2. GitLab: Community Edition 13.0.6

Configure the host

All files in GitLab have access addresses, and it is obviously inappropriate to use the IP address of GitLab server as the address (if the IP of GitLab server changes, the access address of this file will be invalid), so the following two points need to be met:

  1. Prepare the domain name for GitLab server. Here is the domain name for Qunhui’s IP address: gitlab.synology.com
  2. Make sure qunhui can access GitLab through the domain name
  3. Ensure that all visitors can access GitLab by domain name
  4. It is common to modify the hosts file of the visitor to achieve the goal of domain name access. Here, to save the problem, I configure the router: 192.168.50.43 gitlab.synology.com

Allow SSH Login

To enable SSH login:

  1. The operation in the red box is shown below:

2. As shown in the picture below, if SSH is enabled, port 22 will be used:

Now you can use SSH terminal to log in to Qunhui. I have used Xshell6 to log in on a Windows computer. You can use any SSH terminal tool.

4. Pay attention to the red box above, log on account of the home directory is/var/services/homes/zq2599

The deployment of

  1. Create a docker-comedy.yml file with the following content (most of the content can be used directly, any changes that need to be made will be explained later) :
Version: '2.3' services: redis: restart: always image: redis:5.0.9 Command: - --loglevel Warning volumes: - redis-data:/var/lib/redis:Z postgresql: restart: always image: sameersbn/postgresql:11-20200524 volumes: - postgresql-data:/var/lib/postgresql:Z environment: - DB_USER=gitlab - DB_PASS=password - DB_NAME=gitlabhq_production - DB_EXTENSION=pg_trgm gitlab: restart: always image: Volumes: - "10080:80" - "10022:22" Depends_on: - Redis-PostgresQL Ports: - "10080:80" - "10022:22" - gitlab-data:/home/git/data:Z healthcheck: test: ["CMD", "/usr/local/sbin/healthcheck"] interval: 5m timeout: 10s retries: 3 start_period: 5m environment: - DEBUG=false - DB_ADAPTER=postgresql - DB_HOST=postgresql - DB_PORT=5432 - DB_USER=gitlab - DB_PASS=password - DB_NAME=gitlabhq_production - REDIS_HOST=redis - REDIS_PORT=6379 - TZ=Asia/Kolkata - GITLAB_TIMEZONE=Kolkata - GITLAB_HTTPS=false - SSL_SELF_SIGNED=false - GITLAB_HOST=gitlab.synology.com - GITLAB_PORT=10080 - GITLAB_SSH_PORT=10022  - GITLAB_RELATIVE_URL_ROOT= - GITLAB_SECRETS_DB_KEY_BASE=long-and-random-alphanumeric-string - GITLAB_SECRETS_SECRET_KEY_BASE=long-and-random-alphanumeric-string - GITLAB_SECRETS_OTP_KEY_BASE=long-and-random-alphanumeric-string - GITLAB_ROOT_PASSWORD= - GITLAB_ROOT_EMAIL= - GITLAB_NOTIFY_ON_BROKEN_BUILDS=true - GITLAB_NOTIFY_PUSHER=false - [email protected] - [email protected] - [email protected] - GITLAB_BACKUP_SCHEDULE=daily - GITLAB_BACKUP_TIME=01:00 - SMTP_ENABLED=false - SMTP_DOMAIN=www.example.com - SMTP_HOST=smtp.gmail.com - SMTP_PORT=587 - [email protected] - SMTP_PASS=password - SMTP_STARTTLS=true - SMTP_AUTHENTICATION=login - IMAP_ENABLED=false - IMAP_HOST=imap.gmail.com - IMAP_PORT=993 - [email protected]  - IMAP_PASS=password - IMAP_SSL=true - IMAP_STARTTLS=false - OAUTH_ENABLED=false - OAUTH_AUTO_SIGN_IN_WITH_PROVIDER= - OAUTH_ALLOW_SSO= - OAUTH_BLOCK_AUTO_CREATED_USERS=true - OAUTH_AUTO_LINK_LDAP_USER=false - OAUTH_AUTO_LINK_SAML_USER=false - OAUTH_EXTERNAL_PROVIDERS= - OAUTH_CAS3_LABEL=cas3 - OAUTH_CAS3_SERVER= - OAUTH_CAS3_DISABLE_SSL_VERIFICATION=false - OAUTH_CAS3_LOGIN_URL=/cas/login - OAUTH_CAS3_VALIDATE_URL=/cas/p3/serviceValidate - OAUTH_CAS3_LOGOUT_URL=/cas/logout - OAUTH_GOOGLE_API_KEY= - OAUTH_GOOGLE_APP_SECRET= - OAUTH_GOOGLE_RESTRICT_DOMAIN= - OAUTH_FACEBOOK_API_KEY= - OAUTH_FACEBOOK_APP_SECRET= - OAUTH_TWITTER_API_KEY= - OAUTH_TWITTER_APP_SECRET= - OAUTH_GITHUB_API_KEY= - OAUTH_GITHUB_APP_SECRET= - OAUTH_GITHUB_URL= - OAUTH_GITHUB_VERIFY_SSL= - OAUTH_GITLAB_API_KEY= - OAUTH_GITLAB_APP_SECRET= - OAUTH_BITBUCKET_API_KEY= - OAUTH_BITBUCKET_APP_SECRET= - OAUTH_SAML_ASSERTION_CONSUMER_SERVICE_URL= - OAUTH_SAML_IDP_CERT_FINGERPRINT= - OAUTH_SAML_IDP_SSO_TARGET_URL= - OAUTH_SAML_ISSUER= - OAUTH_SAML_LABEL="Our SAML The Provider - OAUTH_SAML_NAME_IDENTIFIER_FORMAT = "urn: oasis: names: tc: SAML: 2.0: nameid - format: transient - OAUTH_SAML_GROUPS_ATTRIBUTE= - OAUTH_SAML_EXTERNAL_GROUPS= - OAUTH_SAML_ATTRIBUTE_STATEMENTS_EMAIL= - OAUTH_SAML_ATTRIBUTE_STATEMENTS_NAME= - OAUTH_SAML_ATTRIBUTE_STATEMENTS_USERNAME= - OAUTH_SAML_ATTRIBUTE_STATEMENTS_FIRST_NAME= - OAUTH_SAML_ATTRIBUTE_STATEMENTS_LAST_NAME= - OAUTH_CROWD_SERVER_URL= - OAUTH_CROWD_APP_NAME= - OAUTH_CROWD_APP_PASSWORD= - OAUTH_AUTH0_CLIENT_ID= - OAUTH_AUTH0_CLIENT_SECRET= - OAUTH_AUTH0_DOMAIN= - OAUTH_AUTH0_SCOPE= - OAUTH_AZURE_API_KEY= - OAUTH_AZURE_API_SECRET= - OAUTH_AZURE_TENANT_ID= volumes: redis-data: postgresql-data: gitlab-data:Copy the code
  1. In the above configuration, you need to modify four areas;
  • Gitlab. ports maps the HTTP port of the container with port 10080 of the host machine, and the SSH port of the container with port 10022 of the host machine
  • Second: gitlab. Environment. GITLAB_PORT, and map in front of the port 10080 is consistent, so gitlab file url will have on port 10080, ensure that access to the file on a web page can be normal
  • Third place: gitlab. Environment. GITLAB_SSH_PORT, and map in front of the port 10022 is consistent, so gitlab given on the warehouse address will have 10022, you in the client connection gitlab successful use git clone command
  • Fourth: gitlab. Environment. GITLAB_HOST, configured to host:gitlab.synology.com in front of the prepared
  • I don’t need to modify other parameters for the moment, please adjust them by yourself. Please refer to the document: github.com/sameersbn/d…
  1. Reconfirm that the domain name on cluster hui is accessible (192.168.50.43 is the IP address of cluster Hui) :

  1. Run sudo docker-compose up -d to complete the deployment and startup of GitLab.

  2. Wait to start successful, qunhui’s hardware performance is general, I wait for about 10 minutes or so here (during the webpage access will appear 502 error, such as successful start after good);

  3. After the success of the start, visit the address gitlab.synology.com: 10080, you will be prompted to set the root account password:

  1. After setting the password, you can log in as user root:

8. As shown in the picture below, please register another account, which will be used in the later actual operation. My registered account is ZQ2599, [email protected]

Verify: Create the project

  1. Log in with a new account and click Create a Project:

2. The information about the new warehouse is as follows:

3. On the page of the new warehouse, the red box below is the address of the warehouse, please write it down and use it later:

Validation: Submit code

  1. Looking for a computer to validate the submission code, I found a CentOS7 server;
  2. Install git: yum install -y
  3. To create an SSH key, run ssh-keygen -t rsa -c “[email protected]” and press Enter:

4. Run the following command to configure the account and email globally:

git config --global user.name "zq2599" \
&& git config --global user.email [email protected]
Copy the code
  1. Copy the contents of the ~/.ssh/id_rsa.pub file to the following location:

6. Go back to the client machine and try the clone project:

git clone ssh://[email protected]:10022/zq2599/test001.git
Copy the code
  1. As shown below, the code was downloaded successfully:

8. Try again to see if the modification can be successfully submitted. The operation command is as follows:

9. Check the website again, the content has been submitted successfully:

At this point, QUNhui server has been successfully installed GitLab, the next can happily toss GitLab CI;

You are not alone, Xinchen original accompany all the way

  1. Java series
  2. Spring series
  3. The Docker series
  4. Kubernetes series
  5. Database + middleware series
  6. The conversation series

Welcome to pay attention to the public number: programmer Xin Chen

Wechat search “programmer Xin Chen”, I am Xin Chen, looking forward to enjoying the Java world with you…

Github.com/zq2599/blog…