[Gitlab] Vue3+Quasar 프로젝트 Gitlab CI/CD 구축(1) - gitlab-runner 설치 및 등록
배포해야 할 서버 : CentOS 7
✅ 서버에 필요한 필수 프로그램을 설치
node를 가장 먼처 설치하는게 중요합니다. (npm이 필요하기 때문. node.js 설치하면 npm 자동 설치 됨)
1. Node.js(npm)
2. Git
3. Vue
4. Yarn
✅ Node.js 설치
- 아래 게시글 참고하여 설치 진행
- https://leewoogi.tistory.com/274
■ Git 설치
1. git 설치
[root@localhost ]# yum install git
2. rpm 다운로드(git 설치 안되는 경우에만)
[root@localhost ]# yum install http://opensource.wandisco.com/centos/7/git/x86_64/wandisco-git-release-7-1.noarch.rpm
3. git 버전 확인
[root@localhost ]# git --version
■ Vue 설치
1. 설치 명령어 입력
[root@localhost ~]# sudo npm install -g @vue/cli
2. vue 버전 확인
[root@localhost ~]# vue --version
■ yarn 설치
[root@localhost ~]# npm install -g yarn
■ gitlab-runner 설치 준비 ( Gitlab 웹사이트에서 진행 )
1. gitlab 사이트에 접속 후 owner 계정으로 로그인 한다.
2. 배포할 프로젝트 > Setting > CI / CD 선택 > Runners 옆에 Extend 클릭 하면 아래 처럼 펼쳐짐
여기서 Set up a specific Ruuner manaually 부분을 따라 하면 됩니다.
3. 우선 Install GitLab Runner 클릭하면 "Install GitLab Runner" 에 대한 설명이 나오는데 스크롤 아래로 내리자
- 난 리눅스에(CentOS 7)에 배포해야 하기 때문에 "Install on GNU/Linux" 선택
4. 아래와 같이 다운로드 하는 방법이 나온다. 다운로드 및 install 등 이 페이지를 계속 참고하면서 할 예정이다.
- 두번째 "curl -LJO "https://gitlab-runner-downloads.s3.amazonaws.com/latest/rpm/gitlab-runner_${arch}.rpm" 복사.
위 URL을 보면 ${arch} 부분이 있는데, 설명을 읽어보자.
# Replace ${arch} with any of the supported architectures, e.g. amd64, arm, arm64 해석 : ${arch} 이부분을 'e.g. amd64, arm, arm64' 요런걸로 바꾸란다. # A full list of architectures can be found here https://gitlab-runner-downloads.s3.amazonaws.com/latest/index.html 해석 : ... index.html 여기 URL 가면 아키텍처의 모든 리스트를 찾을 수 있단다. |
해당 URL로 접속합니다. https://gitlab-runner-downloads.s3.amazonaws.com/latest/index.html
그럼 아래 처럼 쭉 리스트가 있습니다. 저는 i686 선택했습니다.
위에서 복사한 URI ( "curl -LJO "https://gitlab-runner-downloads.s3.amazonaws.com/latest/rpm/gitlab-runner_${arch}.rpm" )중 ${arch} 부분을 내가 원하는 버전으로 변경해 주자
// "curl -LJO "https://gitlab-runner-downloads.s3.amazonaws.com/latest/rpm/gitlab-runner_${arch}.rpm"
"curl -LJO "https://gitlab-runner-downloads.s3.amazonaws.com/latest/rpm/gitlab-runner_i686.rpm"
■ gitlab-runner 설치
자 그럼 이제 설치할(프로젝트 배포할) 서버로 갑니다. root로 접속 합니다.
1. 위에서 복사한 URI 각자 원하는 위치에 다운로드 해 줍니다.
Ex. /usr/local/src
[root@localhost ]# curl -LJO "https://gitlab-runner-downloads.s3.amazonaws.com/latest/rpm/gitlab-runner_i686.rpm"
2. gitlab-runner 설치
[root@localhost ]# rpm -i gitlab-runner_i686.rpm
Git을 설치 하지 않고 명령어를 실행하면 아래 error를 만나게 됩니다.
※ 설치 명령어 확인 방법
다운로드 했으면 다시 "Install GitLab Runner manually on GNU/Linux" 요 페이지에 보면 아래 install 방법 있다.
rpm -i gitlab-runner_i686.rpm

3. gitlab-runner 설치 확인
[root@localhost ]# rpm -qa | grep gitlab-runner
4. gitlab-runner 실행 확인
[root@localhost ]# systemctl status gitlab-runner
5. 유저 root로 수정
[root@localhost ]# vim /etc/systemd/system/gitlab-runner.service
"--user" "gitlab-runner" -> "--user" "root" 로 변경.
6. gitlab-runner 재실행
[root@localhost ]# systemctl daemon-reload
[root@localhost ]# systemctl restart gitlab-runner
7. runner 등록
[root@localhost ]# gitlab-runner register
1번 : gitlab 사이트에서 프로젝트 > Setting > CI / CD 선택 > Runners 옆에 Extend 클릭 했을 때 "Set up a specific Runner manually" 의 2번 URL 적어주면 된다.
2번 : gitlab 사이트에서 프로젝트 > Setting > CI / CD 선택 > Runners 옆에 Extend 클릭 했을 때 "Set up a specific Runner manually" 의 3번 token 적어주면 된다.
3번 : 프로젝트 이름이나, 설명 적으면 됨.
4번 : gitlab-ci.yml에서 해당 tag를 참조하여 실행함 난 master 적었다. ( 이후 테스트 중 master는 배포가 되는데 develop은 배포가 되지 않는 문제가 발생. 이 부분에 master, develop을 해줘야 나중에 .gitlab-ci.yml 에 develop script가 실행 됨.)
5번 : 그냥 엔터
Error 발생한 경우
---------------------------------------------------------------------------------------------------------------------------------------------------------
gitlab 서버와 통신 중 timeout 발생함.

우선 해당 도메인 또는 IP 로 telnet 테스트 진행해 봅니다.
[root@localhost ]# telnet 3.34.204.67 80 / telnet gitlab.crizen.com 80
아래와 같이 통신이 안되는 경우 방화벽이 막혀 있는 상황입니다. gitlab server의 방화벽을 열어야 합니다.

---------------------------------------------------------------------------------------------------------------------------------------------------------
6번 : shell 입력.
■ gitlab-runner 삭제
1. runner 확인
[root@localhost ]# gitlab-runner list
2. runner 삭제 ( 위 gitlab-runner list에 등록된 token으로 삭제해줘야함)
gitlab-runner unregister --url <url> --token <token>
[root@localhost ]# gitlab-runner unregister --url http://gitlab.crizen.com/ --token m-RyFf8Nn.....
3. runner 확인
[root@localhost ]# gitlab-runner list
아래 기존 runner 사라짐.
다시 등록은 위 등록 과정 다시 그대로 하면 됨.
gitlab 사이트 가서 확인 합니다.
- 프로젝트 > Setting > CI / CD 선택 > Runners 옆에 Extend 클릭