DevOps 实践 之GitLab搭建配置(2)

前置条件

系统: CentOS

工具: docker, docker-compose

安装

1. 拉取GitLab镜像

[root@localhost docker]# docker pull gitlab/gitlab-ce
Using default tag: latest
latest: Pulling from gitlab/gitlab-ce
32f112e3802c: Pull complete 
bbf79b4b1bed: Pull complete 
cee64d6186ab: Pull complete 
77a652146c5b: Pull complete 
79bda19958dd: Pull complete 
c6917f66fb23: Pull complete 
a071c753b12f: Pull complete 
ce368e9fc390: Pull complete 
e39ee8568473: Pull complete 
Digest: sha256:182613a8f82544404884024c7f9acbd48f3c191349a52df25f2044761b0e45a1
Status: Downloaded newer image for gitlab/gitlab-ce:latest
docker.io/gitlab/gitlab-ce:latest
[root@localhost docker]# docker images
REPOSITORY         TAG       IMAGE ID       CREATED      SIZE
gitlab/gitlab-ce   latest    79a916da577b   4 days ago   3.73GB

2. 编写docker-compose.yaml

version: "3.1"
services:
  gitlab:
    image: gitlab/gitlab-ce:latest
    container_name: gitlab
    restart: always
    environment:
      GITLAB_OMNIBUS_CONFIG: |
        external_url 'http://192.168.183.144:8929'
        gitlab_rails['gitlab_shell_ssh_port'] = 2224
    ports:
      - '8929:8929'
      - '2224:2224'
    volumes:
      - './config:/etc/gitlab'
      - './logs:/var/log/gitlab'
      - './data:/var/opt/gitlab'

3. 启动容器

[root@localhost ~]# docker-compose up -d

初始化

找出initial passord, 并初始化GitLab

#找到initial password
[root@localhost gitlab_docker]# docker exec -it gitlab bash
root@a802df94d5fa:/# cat /etc/gitlab/initial_root_password 

打开GitLab,并登录

修改用户密码

user--> preference --> password

GitLab 上新建仓库

新建空白仓库,上传本地代码,本地Terminal执行

E:\z_zz\java_projects\java-web-test\java-web-test> git config --local user.name "Administrator"
E:\z_zz\java_projects\java-web-test\java-web-test> git config --local user.email "gitlab_admin_da113e@example.com"

Git提交本地项目

配置SSH Key

生成ssh key, 打开id_rsa 文件,复制内容

$ git config --global -l
user.name=xxx
user.email=xxx@qq.com  #设置自己的用户名和邮箱
credential.helper=manager-core

xxx /e/z_zz/java_projects/java-web-test
$ ssh-keygen -t rsa -C 'xxx@qq.com'
Generating public/private rsa key pair.
Enter file in which to save the key (/c/Users/xxx/.ssh/id_rsa):
/c/Users/xxx/.ssh/id_rsa already exists.
Overwrite (y/n)?

粘贴SSH Key到GitLab: user--> preference --> SSH Key

push 本地代码到仓库

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

☼←安于亥时→❦

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值