ÔõÑùÔÚ NUC Éϴ×Ô¼ºµÄ Gitlab ЧÀÍÆ÷
ÔÚÈí¼þ¿ª·¢ÁìÓòÖУ¬°æ±¾¿ØÖÆÊǺÜÊÇÖ÷ÒªµÄ¹¤¾ß¡£Ëü¿ÉÒÔ×ÊÖúÍŶÓÔÚÂþÑÜÔÚ²î±ðµØÀíλÖõĿª·¢ÕßÖ®¼äÐ×÷£¬ÔÚ²î±ðµÄ°æ±¾¡¢·ÖÖ§ÉÏ¿ª·¢¡¢µ÷ÊԺͲâÊÔ´úÂë¡£gitÊÇ×îÊ¢ÐеĿªÔ´°æ±¾¿ØÖƹ¤¾ßÖ®Ò»¡£¶øÔÚСÎÒ˽¼Ò¿ª·¢Õß»òÕßСÐÍÍŶÓÖУ¬Ãâ·ÑµÄ gitlab ¿ÉÒÔ×ÊÖúËûÃÇʵÏÖ×Ô¼ºµÄ°æ±¾¿ØÖÆϵͳ¡£¶ø±¾ÎĽ«ÏÈÈÝÔõÑùÔÚ nuc Éϴ×Ô¼ºµÄ gitlab ЧÀÍÆ÷¡£
NUC ¼ò½é
Intel NUC£¨£Îext Unit of Computing£©ÊÇÒ»ÖÖÃÔÄãµçÄÔ£¬ËüµÄÌå»ýºÜÊÇС£¬¿ÉÊÇÉèÖúÜÊÇÇ¿Ê¢¡£NUC µÄ¸ßÐÔÄÜ´¦Öóͷ£Æ÷¡¢ÄÚ´æ¡¢Ó²Å̺ÍÍøÂç½Ó¿ÚÊÇÕâЩװ±¸µÄÖ÷ÒªÌØÕ÷¡£
´î½¨ÇéÐÎ
ÔÚ×îÏȴ×ðÁú¿Ê± Gitlab ЧÀÍÆ÷֮ǰ£¬ÎÒÃÇÐèҪ׼±¸Ò»¸ö NUC ÔËÐÐÇéÐΡ£ÎÒÃÇÒªÇóÕâ¸öÇéÐξßÓÐÒÔÏÂÌص㣺
²Ù×÷ϵͳ£ºUbuntu 18.04.5 LTS
Äڴ棺ÖÁÉÙ 4GB
Ó²ÅÌ£ºÖÁÉÙ 60GB
ÍøÂ磺ÓÐÒ»¸ö¹«ÍøIPµØµã£¬²¢ÄÜ»á¼û22ºÍ80¶Ë¿Ú
ÉèÖð취
µÚÒ»²½£º¸üÐÂÈí¼þ°ü
ÔÚÎÒÃÇ×îÏÈ×°Öà Gitlab ֮ǰ£¬ÎÒÃÇÐèÒª¸üÐÂÈí¼þ°ü£º
sudo apt update sudo apt upgrade
µÇ¼ºó¸´ÖÆ
µÚ¶þ²½£º×°Öñر¸Èí¼þ
ÔÚ×°Öà Gitlab Ç°ÎÒÃÇÐèҪװÖà Git¡¢PostgreSQL ºÍ Nginx£º
sudo apt install -y curl openssh-server ca-certificates sudo apt install -y postfix sudo apt install -y git-core sudo apt install -y postgresql postgresql-contrib sudo apt install -y nginx
µÇ¼ºó¸´ÖÆ
×°ÖÃÁËÕâЩÈí¼þ°üÖ®ºó£¬ÎÒÃÇÐèÒªÉèÖà PostgreSQL Êý¾Ý¿âºÍ Nginx ЧÀÍÆ÷¡£
µÚÈý²½£ºÉèÖà PostgreSQL Êý¾Ý¿â
ÔÚ Gitlab ÖУ¬ÎÒÃÇʹÓà PostgreSQL ×÷ΪÊý¾Ý¿âÒýÇæ¡£ÎÒÃÇÐèÒª½¨ÉèÒ»¸öÔËÐÐ Gitlab µÄÓû§£¬ÒÔ¼°Ò»¸öÃûΪgitlabhq_productionµÄÊý¾Ý¿â¡£
sudo su - postgres createuser --interactive createdb gitlabhq_production
µÇ¼ºó¸´ÖÆ
½¨ÉèÊý¾Ý¿âºó£¬ÎÒÃÇÐèÒª½«ÆäÉèÖõ½ Gitlab¡£ÎÒÃÇ·¿ª²¢±à¼ÉèÖÃÎļþ/etc/gitlab/gitlab.rb¡£ÔÚÆäÖÐÕÒµ½ÏÂÃæµÄÓï¾ä£¬×÷·Ï×¢ÊÍ£¬²¢ÐÞ¸ÄΪÒÔÏÂÄÚÈÝ£º
## GitLab Postgres connection settings gitlab_rails['db_adapter'] = 'postgresql' gitlab_rails['db_encoding'] = 'unicode' gitlab_rails['db_host'] = '127.0.0.1' gitlab_rails['db_port'] = '5432' gitlab_rails['db_username'] = 'git' gitlab_rails['db_password'] = 'password' gitlab_rails['db_database'] = 'gitlabhq_production'
µÇ¼ºó¸´ÖÆ
µÚËIJ½£º×°Öà Gitlab
ÎÒÃÇ¿ÉÒÔ´Ó Gitlab ¹Ù·½ÍøÕ¾ÖÐÏÂÔØ Gitlab ÉçÇø°æ£º
curl https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.deb.sh | sudo bash sudo apt-get install gitlab-ce
µÇ¼ºó¸´ÖÆ
ÆÚ´ý×°ÖÃÍê±Ïºó£¬ÔËÐÐÒÔÏÂÏÂÁîÆô¶¯ Gitlab ЧÀÍÆ÷£º
sudo gitlab-ctl reconfigure sudo gitlab-ctl restart
µÇ¼ºó¸´ÖÆ
µÚÎå²½£ºÉèÖà Nginx
Gitlab ʹÓà Nginx ×÷Ϊ Web ЧÀÍÆ÷¡£ÕâÀïÎÒÃÇÐèÒªÐÞ¸Ä Nginx µÄÉèÖÃÎļþ/etc/nginx/sites-available/gitlab£º
sudo cp /etc/nginx/sites-available/default /etc/nginx/sites-available/gitlab sudo nano /etc/nginx/sites-available/gitlab ## ÐÞ¸Ä Gitlab ÉèÖÃÎļþÖеÄÄÚÈÝÈçÏ ## upstream gitlab-workhorse { server unix:/var/opt/gitlab/gitlab-workhorse/socket fail_timeout=0; } server { listen 80; server_name yourdomain.com; server_tokens off; client_max_body_size 250m; location / { proxy_pass http://gitlab-workhorse; proxy_set_header Host $http_host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto https; proxy_read_timeout 300; } error_page 404 /404.html; location = /40x.html { } error_page 500 502 503 504 /50x.html; location = /50x.html { } }
µÇ¼ºó¸´ÖÆ
µ±ÐÞ¸ÄÍê³Éºó£¬ÔËÐÐÒÔÏÂÏÂÁ»îÉèÖÃÎļþ£º
sudo ln -s /etc/nginx/sites-available/gitlab /etc/nginx/sites-enabled/ sudo nginx -t sudo systemctl restart nginx
µÇ¼ºó¸´ÖÆ
×îºó£¬ÎÒÃÇ·¿ªä¯ÀÀÆ÷£¬»á¼û Gitlab ÔÚ NUC ÉÏÔËÐÐµÄ URL£ºhttp://yourdomain.com¡£
½áÂÛ
ÔÚ±¾ÎÄÖУ¬ÎÒÃÇѧϰÁËÔõÑùÔÚ NUC Éϴ×Ô¼ºµÄ Gitlab ЧÀÍÆ÷¡£ÎÒÃÇÊ×ÏÈ×¼±¸ÁËÒ»¸öÔËÐÐ Ubuntu 18.04.5 LTS µÄ NUC ÇéÐΣ¬È»ºó×°ÖÃÁËÐëÒªµÄÈí¼þ°ü£¬ÉèÖÃÁË PostgreSQL Êý¾Ý¿âºÍ Nginx ЧÀÍÆ÷£¬×°ÖÃÁË Gitlab ÉçÇø°æ£¬²¢½«ÆäÉèÖÃΪÔÚ NUC ÉÏÔËÐС£ÏÖÔÚ£¬ÎÒÃÇ¿ÉÒÔÈÃ×ðÁú¿Ê±ÍŶÓÔÚ×Ô¼ºµÄЧÀÍÆ÷ÉϹ²Ïí´úÂëÁË¡£
ÒÔÉϾÍÊÇÔõÑùÔÚ NUC Éϴ×Ô¼ºµÄ Gitlab ЧÀÍÆ÷µÄÏêϸÄÚÈÝ£¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡