saowu's Blog

Desktop Docker安装Gitlab、Gitlab Runner

Desktop Docker安装Gitlab、Gitlab Runner

Gitlab Docs
因为docker只支持专业版,Windows用户如果是家庭版需要去淘宝搞一个升级密钥,不必重装系统就能升级到专业版。将 Windows 家庭版升级到 Windows 专业版
安装完Docker如果下载镜像慢的话,参照另一篇文章添加阿里容器镜像源

一、通过docker-compose启动Gitlab、Gitlab Runner

#docker-compose.yml
version: "3.6"
services:
  gitlab:
    image: gitlab/gitlab-ee:latest
    ports:
      - "10022:22"
      - "18080:80"
      - "10443:443"
    volumes:
      - /data/gitlab:/var/opt/gitlab
      - /var/log/gitlab:/var/log/gitlab
      - /etc/gitlab:/etc/gitlab
  gitlab-runner:
    image: gitlab/gitlab-runner:alpine
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
      - /etc/gitlab-runner:/etc/gitlab-runner
    deploy:
      mode: replicated
      replicas: 4
#在docker-compose.yml目录下执行
$ docker-compose up -d

二、查看Gitlab初始密码

$ cat /etc/gitlab/initial_root_password

三、Gitlab Runner注册

获取 Gitlab Ci TOKEN

$ docker exec -it gitlab-runner gitlab-ci-multi-runner register
# 输入Gitlab url,输入的应该是容器随机ip(不必加端口),通过docker inspect查看
>http://172.18.0.2
# Gitlab Ci TOKEN
>_8iT1NFZVqf_yq2xDdH2
>"输入一些描述"
# tags 决定了pipeline分配
>java
# Runner 内执行的是什么
>docker
# 输入默认docker镜像
>alpine:3.15.6

四、M1 Desktop Docker 对应的Gitlab版本

#m1 docker-compose.yml
version: "3.6"
services:
  gitlab:
    image: yrzr/gitlab-ce-arm64v8:14.2.5-ce.0
    ports:
      - "10022:22"
      - "18080:80"
      - "10443:443"
    volumes:
      - /data/gitlab:/var/opt/gitlab
      - /var/log/gitlab:/var/log/gitlab
      - /etc/gitlab:/etc/gitlab
  gitlab-runner:
    image: gitlab/gitlab-runner:alpine
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
      - /etc/gitlab-runner:/etc/gitlab-runner
    deploy:
      mode: replicated
      replicas: 1


Copyright © 2020 - 2024 saowu. All Right Reserved
Powered by Gridea