โฮสต์ GitLab
GitLab คือตัวจัดการที่เก็บ Git แบบเว็บซึ่งมีฟีเจอร์วิกิและการติดตามปัญหา GitLab คล้ายกับ GitHub แต่ GitLab มีเวอร์ชันโอเพนซอร์ส ซึ่งแตกต่างจาก GitHub GitLab เป็นตัวจัดการที่เก็บ Git ที่โฮสต์เองได้ หมายถึงคุณสามารถโฮสต์เซิร์ฟเวอร์ GitLab ของคุณบนโครงสร้างพื้นฐานของคุณเอง
เพื่อโฮสต์ GitLab บน AnduinOS ให้รันคำสั่งต่อไปนี้
ก่อนอื่น ตรวจสอบให้แน่ใจว่า Docker ติดตั้งอยู่บนเครื่องของคุณแล้ว หากไม่ได้ติดตั้ง คุณสามารถติดตั้ง Docker ได้โดยรันคำสั่งต่อไปนี้:
sudo apt install -y docker.io
สร้างโฟลเดอร์ใหม่เพื่อเก็บไฟล์การกำหนดค่าบริการ:
# Please install Docker first
mkdir -p ~/Source/ServiceConfigs/GitLab
cd ~/Source/ServiceConfigs/GitLab
ตรวจสอบให้แน่ใจว่าไม่มีกระบวนการอื่นกำลังใช้งานพอร์ต 80, 443 และ 2202 บนเครื่องของคุณ
function port_exist_check() {
if [[ 0 -eq $(sudo lsof -i:"$1" | grep -i -c "listen") ]]; then
echo "$1 is not in use"
sleep 1
else
echo "Warning: $1 is occupied"
sudo lsof -i:"$1"
echo "Will kill the occupied process in 5s"
sleep 5
sudo lsof -i:"$1" | awk '{print $2}' | grep -v "PID" | sudo xargs kill -9
echo "Killed the occupied process"
sleep 1
fi
}
port_exist_check 80
port_exist_check 443
port_exist_check 2202
จากนั้น ให้สร้างไฟล์ docker-compose.yml พร้อมเนื้อหาต่อไปนี้:
cat << EOF > ./docker-compose.yml
version: "3.6"
services:
gitlab:
image: gitlab/gitlab-ee
ports:
- target: 2202
published: 2202
protocol: tcp
mode: host
- target: 80
published: 80
protocol: tcp
mode: host
- target: 443
published: 443
protocol: tcp
mode: host
volumes:
- gitlab-data:/var/opt/gitlab
- gitlab-log:/var/log/gitlab
- gitlab-config:/etc/gitlab
- /etc/localtime:/etc/localtime:ro
- type: tmpfs
target: /dev/shm
tmpfs:
size: 2147483648 # 2GB
tmpfs:
- /tmp:size=2G
environment:
GITLAB_OMNIBUS_CONFIG: |
external_url 'http://localhost'
gitlab_rails['gitlab_shell_ssh_port'] = 2202
gitlab_sshd['enable'] = true
gitlab_sshd['listen_address'] = '[::]:2202'
gitlab_rails['gitlab_default_theme'] = 2
letsencrypt['enabled'] = false
nginx['listen_port'] = 80
nginx['listen_https'] = false
nginx['redirect_http_to_https'] = false
nginx['proxy_protocol'] = false
nginx['http2_enabled'] = true
prometheus_monitoring['enable'] = false
sidekiq['metrics_enabled'] = false
puma['exporter_enabled'] = false
deploy:
resources:
limits:
memory: 22G
volumes:
gitlab-data:
driver: local
driver_opts:
type: none
o: bind
device: /swarm-vol/gitlab/data
gitlab-log:
driver: local
driver_opts:
type: none
o: bind
device: /swarm-vol/gitlab/log
gitlab-config:
driver: local
driver_opts:
type: none
o: bind
device: /swarm-vol/gitlab/config
EOF
sudo mkdir -p /swarm-vol/gitlab/data
sudo mkdir -p /swarm-vol/gitlab/log
sudo mkdir -p /swarm-vol/gitlab/config
จากนั้นให้ติดตั้งบริการ:
sudo docker swarm init --advertise-addr $(hostname -I | awk '{print $1}')
sudo docker stack deploy -c docker-compose.yml gitlab --detach
เรียบร้อยแล้ว! คุณได้ติดตั้ง GitLab บน AnduinOS สำเร็จแล้ว
คุณสามารถเข้าถึง GitLab ได้โดยการเปิด http://localhost ในเบราว์เซอร์ของคุณ
รหัสผ่านเริ่มต้นสำหรับผู้ใช้ root สามารถดูได้ที่ /swarm-vol/gitlab/config/initial_root_password
การถอนการติดตั้ง
ในการถอนการติดตั้ง GitLab ให้รันคำสั่งต่อไปนี้:
sudo docker stack rm gitlab
sleep 20 # Wait for the stack to be removed
sudo docker system prune -a --volumes -f # Clean up used volumes and images
หากต้องการลบไฟล์ข้อมูล บันทึก และไฟล์การกำหนดค่าด้วย ให้รันคำสั่งต่อไปนี้:
sudo rm /swarm-vol/gitlab -rf
เรียบร้อยแล้ว! คุณได้ถอนการติดตั้ง GitLab ออกจาก AnduinOS สำเร็จแล้ว
ความคิดเห็น (0)
ยังไม่มีความคิดเห็น เป็นคนแรกที่จะแสดงความคิดเห็น!