安装GitLab Runner
banner 2020-07-25 gitlabci/cd
# 安装GitLab Runner
# 1. 拉取gitlab-runner镜像
sudo docker pull gitlab/gitlab-runner:latest
1
# 2. 添加GitLab Runner container
sudo docker run -d --name gitlab-runner --restart always \
-v /srv/gitlab-runner/config:/etc/gitlab-runner \
-v /var/run/docker.sock:/var/run/docker.sock \
gitlab/gitlab-runner:latest
1
2
3
4
2
3
4
# 3. 注册 GitLab Runner
gitlab-runner register -n \
--url https://gitlab.com/ \
--registration-token REGISTRATION_TOKEN \
--executor docker \
--description "My Docker Runner" \
--docker-image "docker:19.03.12" \
--docker-volumes /var/run/docker.sock:/var/run/docker.sock
1
2
3
4
5
6
7
2
3
4
5
6
7
# 4. 定义项目构建流程 (.gitlab-ci.yml)
docker_image:
stage: deploy
image: docker:stable
only:
- master
script:
- docker build -t vue-blog .
- docker login --username=auto_deploy@banner --password=${PASSWORD} registry.cn-shenzhen.aliyuncs.com
- docker tag vue-blog registry.cn-shenzhen.aliyuncs.com/bannerxu/vue-blog
- docker push registry.cn-shenzhen.aliyuncs.com/bannerxu/vue-blog
1
2
3
4
5
6
7
8
9
10
11
12
13
2
3
4
5
6
7
8
9
10
11
12
13