개발관련/Docker

도커에 GitLab 설치 및 실행

Diademata 2023. 9. 21. 02:15
반응형

https://docs.gitlab.com/16.3/ee/install/docker.html

 

GitLab Docker images | GitLab

GitLab product documentation.

docs.gitlab.com

위의 문서를 참고하면 되지만 정리겸 올려본다.

 

OS 는 aws Linux 이다.

 

도커가 깔려있다는 조건하에 진행한다.


GitLab 이미지를 다운로드

sudo docker pull gitlab/gitlab-ce

컨테이너가 종료되면 저장된 정보들이 증발하기 때문에 볼륨을 통하여 데이터를 공유한다.

git이라는 폴더를 생성한다.

sudo mkdir git

 

폴더 권한도 설정한다.

sudo chmod -R 777 git

 

환경변수 지정
export GITLAB_HOME=/git

 

쉘 프로필에 즉시 적용
source ~/.bash_profile

 

볼륨에 대한 설명이다 아래의 폴더를 생성해줘야 한다.

Local location Container location Usage
$GITLAB_HOME/data /var/opt/gitlab For storing application data.
$GITLAB_HOME/log /var/log/gitlab For storing logs.
$GITLAB_HOME/config /etc/gitlab For storing the GitLab configuration files.

다음은 컨테이너를 설정하는 법이다.

 

도커 엔진을 이용

터미널에 아래의 내용을 입력한다.

 

sudo docker run --detach \
  --hostname 서버 주소 \
  --publish 50000:80 --publish 50022:22 --publish 50443:443 \ 
  --name gitlab \
  --restart always \
  --volume $GITLAB_HOME/config:/etc/gitlab \
  --volume $GITLAB_HOME/logs:/var/log/gitlab \
  --volume $GITLAB_HOME/data:/var/opt/gitlab \
  --shm-size 256m \
  gitlab/gitlab-ce:latest

 

docker-compose 이용

깃헙에서 최신 버전을 다운로드 받는다.

sudo curl -L https://github.com/docker/compose/releases/latest/download/docker-compose-$(uname -s)-$(uname -m) -o /usr/local/bin/docker-compose

실행 권한 부여

sudo chmod +x /usr/local/bin/docker-compose

 

버전 확인

docker-compose version

 

해당 파일을 docker-compose.yml 파일 이름으로 GITLAB_HOME에 설정했던 경로에 넣어준다.

※ GITLAB_HOME 환경 변수를 사용하지 않고 절대 경로를 통하여 볼륨을 설정해도 된다.

※ external_url : SSL 인증서를 사용하는 경우 Https 프로토콜을 입력한다. 사용하지 않는다면 Http 프로토콜을 입력한다.

version: '3.6'
services:
  web:
    image: 'gitlab/gitlab-ce:latest'
    restart: always
    hostname: '서버 주소'
    environment:
      GITLAB_OMNIBUS_CONFIG: |
        external_url 'https://서버 주소'
        # Add any other gitlab.rb configuration here, each on its own line
    ports:
      - '50000:80'
      - '50443:443'
      - '50022:22'
    volumes:
      - '/git/config:/etc/gitlab'
      - '/git/logs:/var/log/gitlab'
      - '/git/data:/var/opt/gitlab'
    shm_size: '256m'

다음 compose 파일을 실행할 수 있다.

docker-compose up -d

 

실행이 되면 세팅하는 시간이 좀 걸린다.

아래의 명령어로 진행 상황 로그를 확인 가능하다.

docker logs -f git-web-1

 

반응형

'개발관련 > Docker' 카테고리의 다른 글

Daemon.json 호스트 설정시 트러블 슈팅  (0) 2024.05.12
jenkins에서 도커 명령어 사용하기  (0) 2024.03.10
Docker 설치  (0) 2023.01.08