ÔõÑù´î½¨×Ô¼ºµÄ GitLab ЧÀÍÆ÷
Ëæ×Å¿ªÔ´ºÍÔÆÅÌËãµÄÐËÆð£¬gitlab Öð½¥³ÉΪÁË×îÊܽӴýµÄ´úÂë¿ÍջЧÀÍÖ®Ò»¡£ËüÌṩµÄ¹¦Ð§Ç¿Ê¢¶øÊÊÓ㬰üÀ¨´úÂë¿ÍÕ»¡¢´úÂëÉó²é¡¢ci/cd µÈ¡£¶ø´î½¨×Ô¼ºµÄgitlabЧÀÍÆ÷£¬Ò²³ÉΪÁËÔ½À´Ô½¶àÈ˵ÄÑ¡Ôñ¡£±¾ÎĽ«ÏÈÈÝÔõÑù´î½¨×Ô¼ºµÄ gitlab ЧÀÍÆ÷¡£
¹ºÖà VPS Ö÷»ú
Ê×ÏÈ£¬ÄúÐèÒª¹ºÖÃһ̨ VPS Ö÷»ú¡£VPSÖ÷»úÊÇÒ»ÖÖÐéÄâЧÀÍÆ÷£¬Í¨³£¿ÉÔÚÔÆÅÌËãƽ̨ÉÏ»ñµÃ¡£ËüÃÇÌṩÁ˸üºÃµÄÇå¾²ÐԺͿɶ¨ÖÆÐÔ£¬Òò´Ë³ÉΪÁ˴GitLabЧÀÍÆ÷µÄÊ×Ñ¡¡£
×°ÖÃGitLab
½ÓÏÂÀ´£¬ÄúÐèҪװÖà GitLab¡£ÒÔÏÂÊÇ×°Öð취£º
2.1 ×°ÖÃÐëÒªµÄÈí¼þ
ÔÚ×îÏÈ×°Öà GitLab ֮ǰ£¬ÎÒÃÇÐèҪװÖÃÐëÒªµÄÈí¼þ¡£ÕâЩÈí¼þ°üÀ¨curl¡¢openssh-server¡¢ca-certificatesºÍpostfix¡£Äú¿ÉÒÔʹÓÃÒÔÏÂÏÂÁî×°ÖÃËüÃÇ£º
sudo apt-get install curl openssh-server ca-certificates postfix
2.2 Ìí¼Ó GitLab ´æ´¢¿â
ÄúÐèÒª½« GitLab ´æ´¢¿âÌí¼Óµ½ÏµÍ³¡£
curl https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.deb.sh | sudo bash
2.3 ×°ÖÃGitLab
ÏÖÔÚÄú¿ÉÒÔ×°Öà GitLab ÁË¡£Ê¹ÓÃÒÔÏÂÏÂÁî×°Öà GitLab£º
sudo apt-get install gitlab-ce
ÉèÖÃGitLab
×°Öà GitLab ºó£¬ÎÒÃÇÐèÒªÉèÖÃһЩÏêϸÐÅÏ¢¡£
3.1 ÉèÖÃÓòÃûºÍ SSL ÈÏÖ¤
Ê×ÏÈ£¬ÄúÐèÒªÉèÖà GitLab µÄÓòÃûºÍ SSL ÈÏÖ¤¡£Õ⽫ȷ±£ÄúµÄGitLab ЧÀÍÆ÷ÓÐÒ»¸öÇå¾²µÄ±êʶ£¬²¢ÇÒÄú¿ÉÒÔͨ¹ý HTTPS »á¼ûËü¡£Äú¿ÉÒÔʹÓÃÒÔÏÂÏÂÁîΪÄúµÄGitLabЧÀÍÆ÷ÉèÖÃSSLÖ¤Ê飺
sudo openssl req -newkey rsa:2048 -nodes -keyout /etc/gitlab/ssl/gitlab.example.com.key -out /etc/gitlab/ssl/gitlab.example.com.csr
sudo openssl x509 -req -days 365 -in /etc/gitlab/ssl/gitlab.example.com.csr -signkey /etc/gitlab/ssl/gitlab.example.com.key -out /etc/gitlab/ssl/gitlab.example.com.crt
×¢Öؽ« “example.com” Ì滻ΪÄúµÄÓòÃû¡£
3.2 ÉèÖà GitLab »á¼ûȨÏÞ
GitLab ÔÊÐíÄú½¨Éè²î±ðµÄÓû§ºÍÓû§×顣ĬÈÏÇéÐÎÏ£¬³ýÁËÖÎÀíÔ±Í⣬ÆäËûÈ˶¼ÎÞ·¨»á¼ûÄúµÄ GitLab ЧÀÍÆ÷¡£Äú¿ÉÒÔʹÓÃÒÔÏÂÏÂÁîΪÄúµÄGitLabЧÀÍÆ÷Ìí¼ÓÐÂÓû§£º
sudo gitlab-rails console
ÔÚÕâÀÄú¿ÉÒÔÔÚ¿ØÖÆ̨ÉÏÖ´ÐÐÒÔÏÂÏÂÁîÒÔ½¨ÉèÐÂÓû§£º
user = User.new(:name => ‘New User’, :username => ‘new_username’, :email => ‘new_user@example.com’, :password => ‘password’, :password_confirmation => ‘password’)
user.save
3.3 ÉèÖÃSMTPЧÀÍÆ÷
ÄúÐèÒªÉèÖÃÒ»¸öSMTPЧÀÍÆ÷£¬Ê¹ GitLab Äܹ»·¢ËÍÓʼþ¡£Äú¿ÉÒÔʹÓÃÒÔÏÂÏÂÁSMTPЧÀÍÆ÷Ìí¼Óµ½ GitLab£º
sudo vim /etc/gitlab/gitlab.rb
ÔÚ “gitlab_rails[‘smtp_enable’]” ÏÂÌí¼ÓÒÔÏÂÓï¾ä£º
gitlab_rails[‘smtp_address’] = “smtp.gmail.com”
gitlab_rails[‘smtp_port’] = 587
gitlab_rails[‘smtp_authentication’] = “plain”
gitlab_rails[‘smtp_enable_starttls_auto’] = true
gitlab_rails[‘smtp_user_name’] = “youremail@gmail.com”
gitlab_rails[‘smtp_password’] = “password”
¸üÐÂÉèÖãº
sudo gitlab-ctl reconfigure
4.ʹÓÃGitLab
ÏÖÔÚÄúÒѾÉèÖúÃÁË GitLab£¬¿ÉÒÔ×îÏÈʹÓÃËüÁË¡£ºÜÈÝÒ׵ؽ¨ÉèÄúµÄµÚÒ»¸öÏîÄ¿¡£ÉÏ°¶ÄúµÄ GitLab ЧÀÍÆ÷£¬½¨ÉèÐÂÏîÄ¿²¢ÔÚÆäÖÐÌí¼Ó´úÂë¼´¿É¡£Í¨¹ýGitLab£¬Äú¿ÉÒÔÇáËɵؾÙÐдúÂëÉó²éºÍ¹¹½¨×Ô¶¯»¯Á÷Ë®Ïß¡£Äú»¹¿ÉÒÔΪÿ¸öÏîÄ¿ÉèÖûá¼ûȨÏ޺ͿØÖÆÓû§È¨ÏÞ¡£
×ܽ᣺
´î½¨×Ô¼ºµÄ GitLab ЧÀÍÆ÷¿ÉÄÜÐèҪһЩÊÖÒÕ֪ʶ£¬µ«Ëü¿ÉÒÔΪÄúÌṩÐí¶àÀûÒæ¡£Ëü²»µ«¿ÉÒÔÌá¸ß´úÂ뿪·¢ºÍÐ×÷µÄЧÂÊ£¬»¹¿ÉÒÔ×ÊÖúÄúÔöÇ¿Çå¾²ÐÔ¡£Ö»¹ÜÐèҪһЩʱ¼äºÍ³¤×ãµÄѧϰ£¬µ«Ëü¿ÉÒÔʹÄúµÄÍŶÓÔ½·¢Ðͬ²¢ÓиüºÃµÄ±àÂëʵ¼ù¡£
ÒÔÉϾÍÊÇÔõÑù´î½¨×Ô¼ºµÄ GitLab ЧÀÍÆ÷µÄÏêϸÄÚÈÝ£¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡