Halo
发布于 2023-02-23 / 76 阅读 / 0 评论 / 0 点赞

gitlab and runner

what’s this

install gitlab/gitlab runner in linux

install gitlab

gitlab home dir

export GITLAB_HOME=/srv/gitlab

run gitlab container

docker run --detach \
  --hostname gitlab \
  --publish 8003:443 --publish 8000:80 --publish 8002:22 \
  --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

login gitlab

docker ps --all | grep gitlab
cat $GITLAB_HOME/config/initial_root_password

wait gitlab up and then open: http://localhost:8000
root/$password

add ssh pub key

open: http://localhost:8000/-/profile/keys
and then attach your pub key

change ssh url

  • external url
nano $GITLAB_HOME/config/gitlab.rb
external_url 'http://10.60.2.43'
gitlab_rails['gitlab_ssh_host'] = '10.60.2.43'
gitlab_rails['gitlab_shell_ssh_port'] = 8002
  • restart
docker exec gitlab gitlab-ctl reconfigure
docker exec gitlab  gitlab-ctl restart
docker restart gitlab

change http url

menu->admin->settings->general->Visibility and access controls->Custom Git clone URL for HTTP(S)

install gitlab runner

apt install gitlab runner

run container

mkdir -p /home/user/gitlab-runner/config
mkdir -p /home/user/gitlab-runner/data
chmod 777 -R /home/user/gitlab-runner

docker run -id --name gitlab-runner --restart always \
 -m 2g \
 -v /home/user/gitlab-runner/config:/root/config \
 -v /home/user/gitlab-runner/data:/root/data \
 ubuntu:latest

setup gitlab-runner

docker exec -it gitlab-runner /bin/bash
apt update && apt upgrade -y
apt install -y curl
curl -L "https://packages.gitlab.com/install/repositories/runner/gitlab-runner/script.deb.sh" | bash
apt install gitlab-runner -y
gitlab-runner start
gitlab-runner status
ln -s /etc/gitlab-runner/config.toml /root/config/config.toml

regist runner

get ci/cd url and token

open: http://localhost:8000/project/-/settings/ci_cd
get then runner: url and token

config in runner

gitlab-runner register

Enter an executor: shell


评论