본문 바로가기
DevOps/CICD

[DevOps]GitLAB 설치

by Yoon_estar 2024. 12. 6.
728x90

1. GitLab 패키지 저장소 추가

1.1 필수 패키지 설치

sudo apt update
sudo apt install -y curl ca-certificates gnupg

 

1.2 GitLab GPG 키 추가

curl -fsSL https://packages.gitlab.com/gitlab/gitlab-ce/gpgkey | sudo gpg --dearmor -o /usr/share/keyrings/gitlab-archive-keyring.gpg

 

1.3 GitLab 레포지토리 추가 저장소를 /etc/apt/sources.list.d/에 추가

echo "deb [signed-by=/usr/share/keyrings/gitlab-archive-keyring.gpg] https://packages.gitlab.com/gitlab/gitlab-ce/ubuntu/ $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/gitlab-ce.list

 

2. 패키지 목록 업데이트 및 설치

2.1 패키지 목록 업데이트

sudo apt update

 

2.2 GitLab 설치

sudo apt install -y gitlab-ce


Setting up gitlab-ce (17.6.1-ce.0) ...
It looks like GitLab has not been configured yet; skipping the upgrade script.

       *.                  *.
      ***                 ***
     *****               *****
    .******             *******
    ********            ********
   ,,,,,,,,,***********,,,,,,,,,
  ,,,,,,,,,,,*********,,,,,,,,,,,
  .,,,,,,,,,,,*******,,,,,,,,,,,,
      ,,,,,,,,,*****,,,,,,,,,.
         ,,,,,,,****,,,,,,
            .,,,***,,,,
                ,*,.



     _______ __  __          __
    / ____(_) /_/ /   ____ _/ /_
   / / __/ / __/ /   / __ `/ __ \
  / /_/ / / /_/ /___/ /_/ / /_/ /
  \____/_/\__/_____/\__,_/_.___/


Thank you for installing GitLab!
GitLab was unable to detect a valid hostname for your instance.
Please configure a URL for your GitLab instance by setting `external_url`
configuration in /etc/gitlab/gitlab.rb file.
Then, you can start your GitLab instance by running the following command:
  sudo gitlab-ctl reconfigure

 

3. GitLab 설정

3.1 GitLab 구성 파일 수정

vim /etc/gitlab/gitlab.rb

external_url 'http://gitlab.newDomain.com' # 도메인이 있다면 진행
external_url 'http://serverIP' # 도메인이 없을때 진행
external_url 'http://gitlab.newDomain.com:8443' # 도메인이 있고, 방화벽 포트 설정시 진행

-------------------------------------------------------> me
external_url 'http://192.168.207.210'

3.1 GitLab 설정 초기화 (시간이 오래 걸리므로 기다려준다.)

sudo gitlab-ctl reconfigure

 

3.2 GitLab 실행 상태 확인

sudo gitlab-ctl status

 

3.3 GitLab 서비스 중지 / 시작

sudo gitlab-ctl stop
sudo gitlab-ctl start

 

3.4 GitLab 서버 접속

# cat /etc/gitlab/initial_root_password
# WARNING: This value is valid only in the following conditions
#          1. If provided manually (either via `GITLAB_ROOT_PASSWORD` environment variable or via `gitlab_rails['initial_root_password']` setting in `gitlab.rb`, it was provided before database was seeded for the first time (usually, the first reconfigure run).
#          2. Password hasn't been changed manually, either via UI or via command line.
#
#          If the password shown here doesn't work, you must reset the admin password following https://docs.gitlab.com/ee/security/reset_user_password.html#reset-your-root-password.

Password: 64y3XMVH8rmKPVyW1nBZTKCVS8mdrU2sR3ffG6Jf+TI=

# NOTE: This file will be automatically deleted in the first reconfigure run after 24 hours.

 

3.5 웹페이지 작동 확인

 

 

4. TEST

  • git config 명령을 실행하여 Git 구성 정보를 확인합니다.
  • git config --list
  • Git 사용자 이름과 이메일 주소가 설정되어 있지 않으면 아래 명령을 실행하여 설정단일 리포지토리에 대해서만 Git 사용자 이름과 이메일 주소를 설정하려면 --global 옵션을 제거하고 실행합니다
git init
git config --list
git status
git add .
git status
git commit -m 'frs'
git remote add origin http://192.168.207.210:8888/eng/test.git
git pull --allow-unrelated-histories origin main
git push -u origin main