dockercompose搭建GITLAB上传代码

1.创建挂载目录:

mkdir -p /home/yuexin/gitlab/etc /home/yuexin/gitlab/log /home/yuexin/gitlab/data

2.编写dockercompose

version: '3.7'
services:
  gitlab:
    image: 'gitlab/gitlab-ee:latest'
    restart: always
    container_name: gitlab
    environment:
      GITLAB_OMNIBUS_CONFIG: |
        external_url 'http://{IP}:8090'          #若有域名可以写域名
        gitlab_rails['gitlab_shell_ssh_port'] = 2224
        #gitlab_rails['smtp_enable'] = true
        #gitlab_rails['smtp_address'] = "smtpdm.aliyun.com"
        #gitlab_rails['smtp_port'] = 465
        #gitlab_rails['smtp_user_name'] = "邮箱用户@域名.com"
        #gitlab_rails['smtp_password'] = "smtp服务密码"
        #gitlab_rails['smtp_domain'] = "域名.com"
        #gitlab_rails['smtp_authentication'] = "login"
        #gitlab_rails['smtp_enable_starttls_auto'] = false
        #gitlab_rails['smtp_tls'] = true
        #gitlab_rails['smtp_ssl'] = false
        #gitlab_rails['gitlab_email_from'] = '同smtp_user_name'
        #gitlab_rails['gitlab_email_display_name'] = '邮件标识符'
    ports:
      - "8443:443"
      - "8090:8090"
      - "222:22"
    volumes:
      - '/home/yuexin/gitlab/etc:/etc/gitlab'
      - '/home/yuexin/gitlab/log:/var/log/gitlab'
      - '/home/yuexin/gitlab/data:/var/opt/gitlab'
    shm_size: '512m'

3.执行 docker-compose up -d  (保证足够的磁盘容量)

增加规则,开放端口

如不够清理磁盘:

cd / 回到根目录

df -h 查询占用情况,我这里是/home占用最大

# du -sh /*    一级一级筛查占用最多的文件夹,并删除即可
8.8M /bin
30M /boot
0 /dev
5.3M /etc
24K /home
0 /initrd.img
205M /lib
4.0K /lib64
16K /lost+found
8.0K /media
4.0K /mnt
4.0K /opt
0 /proc
2.5G /root
232K /run
5.2M /sbin
8.0K /srv
0 /sys
4.0K /tmp
2.6G /usr
1.8G /var
0 /vmlinuz

4.访问  http://IP:8090/users/sign_in,初始密码在 /home/yuexin/gitlab/etc/initial_root_password 里,使用root登录

5.上传代码

Create a new repository on GitHub.com
git init
git add .
git commit -m 'first commit'
git remote add origin <REMOTE_URL> # 第二次上传就不需要使用了
git push -u origin master

 

posted @ 2023-01-16 17:45  蔡徐坤1987  阅读(62)  评论(0编辑  收藏  举报