2018年11月20日 星期二

GitLab 安裝流程 (Docker Image)

新版的 GitLab 安裝流程已經相當簡單了
原本是打算架實體服務,看完官方教學後,馬上投入 Docker 的懷抱

參考文件 : https://docs.gitlab.com/omnibus/docker/

請 D 大在 ESXi 切一個 VM 給 GitLab 用,環境為 :
  • OS : Ubuntu 16.04
  • CPU : 2.5 GHz (3 cores)
  • Memory : 4G
  • HD Space : 200G

1. 安裝 Docker CE


沒有安裝過的話,可以參考: Docker 安裝流程


2. 安裝 GitLab CE


2-1. GitLab Docker Image


sudo docker run --detach \
  --hostname gitlab.example.com \
  --publish 443:443 --publish 80:80 --publish 22:22 \
  --name gitlab \
  --restart always \
  --volume /srv/gitlab/config:/etc/gitlab \
  --volume /srv/gitlab/logs:/var/log/gitlab \
  --volume /srv/gitlab/data:/var/opt/gitlab \
  gitlab/gitlab-ce:latest

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


Run GitLab CE on public IP address, modifying the --publish flag
sudo docker run --detach \
  --hostname gitlab.example.com \
  --publish 1.1.1.1:443:443 \
  --publish 1.1.1.1:80:80 \
  --publish 1.1.1.1:22:22 \
  --name gitlab \
  --restart always \
  --volume /srv/gitlab/config:/etc/gitlab \
  --volume /srv/gitlab/logs:/var/log/gitlab \
  --volume /srv/gitlab/data:/var/opt/gitlab \
  gitlab/gitlab-ce:latest

Expose GitLab on different ports. For example, to expose the web interface on port 8929, and the SSH service on port 2289, use the following docker run command:
sudo docker run --detach \
  --hostname gitlab.example.com \
  --publish 8929:80 --publish 2289:22 \
  --name gitlab \
  --restart always \
  --volume /srv/gitlab/config:/etc/gitlab \
  --volume /srv/gitlab/logs:/var/log/gitlab \
  --volume /srv/gitlab/data:/var/opt/gitlab \
  gitlab/gitlab-ce:latest


2-2. 升級 GitLab 的流程


sudo docker stop gitlab
sudo docker rm gitlab
sudo docker pull gitlab/gitlab-ce:latest

sudo docker run --detach \
  --hostname gitlab.example.com \
  --publish 443:443 --publish 80:80 --publish 22:22 \
  --name gitlab \
  --restart always \
  --volume /srv/gitlab/config:/etc/gitlab \
  --volume /srv/gitlab/logs:/var/log/gitlab \
  --volume /srv/gitlab/data:/var/opt/gitlab \
  gitlab/gitlab-ce:latest


2-3. 常用指令


Enter running container:
sudo docker exec -it gitlab /bin/bash

You can also just edit /etc/gitlab/gitlab.rb:
sudo docker exec -it gitlab vi /etc/gitlab/gitlab.rb

After you make all the changes you want, you will need to restart the container in order to reconfigure GitLab:
sudo docker restart gitlab

Read container log:
sudo docker logs gitlab



3. 進入 GitLab 網站


Note: The initialization process may take a long time. You can track this process with the command:
sudo docker logs -f gitlab

3-1. 設定管理者的密碼


The very first time you visit GitLab, you will be asked to set up the admin password. After you change it, you can login with username root and the password you set up.





3-2. Login


用 root 帳號加上剛剛的設定密碼進行登入:


進入 GitLab 首頁


沒有留言:

張貼留言