1. 安装docker替换国内镜像源

#卸载之前的docker版本
sudo apt-get remove docker docker-engine docker-ce docker.io

#apt元数据更新
sudo apt-get update

#安装以下包,以使apt可以通过https来使用repository
sudo apt-get install -y apt-transport-https ca-certificates curl software-properties-common

#添加docker官方GPG秘钥并更新元数据
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
sudo apt-get update

#添加docker仓库
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
sudo apt-get update

#列出docker可用版本,选择一个安装
sudo apt-cache madison docker-ce
sudo apt-get install docker-ce=

#替换docker镜像源
sudo vim /etc/docker/daemon.json,添加
{
"registry-mirrors": ["https://9w1hl6qt.mirror.aliyuncs.com"]
}

2. 安装docker-compose

yum -y install epel-release
yum -y install python-pip
pip install --upgrade pip
pip install docker-compose

#或者二进制安装
curl -L https://github.com/docker/compose/releases/download/1.23.2/docker-compose-`uname -s`-`uname -m` -o /usr/local/bin/docker-compose
chmod +x /usr/local/bin/docker-compose
#安装补全工具
yum install bash-completion
curl -L https://raw.githubusercontent.com/docker/compose/$(docker-compose version --short)/contrib/completion/bash/docker-compose > /etc/bash_completion.d/docker-compose

3. 建立工作路径,设置hosts

mkdir docker-workspace
cd docker-workspace

sudo vim /etc/hosts
添加 127.0.0.1	dongfeng.gitlab.top

4. 创建docker-compose.yaml

version: '3'
services:
    gitlab:
      image: 'twang2218/gitlab-ce-zh:9.4'
      restart: unless-stopped
      user: root
      privileged: true
      hostname: 'dongfeng.gitlab.top'
      environment:
        TZ: 'Asia/Shanghai'
        GITLAB_OMNIBUS_CONFIG: |
          external_url 'http://dongfeng.gitlab.top:9999'
          gitlab_rails['time_zone'] = 'Asia/Shanghai'
          # 需要配置到 gitlab.rb 中的配置可以在这里配置,每个配置一行,注意缩进。
          # 比如下面的电子邮件的配置:
          # gitlab_rails['smtp_enable'] = true
          # gitlab_rails['smtp_address'] = "smtp.exmail.qq.com"
          # gitlab_rails['smtp_port'] = 465
          # gitlab_rails['smtp_user_name'] = "xxxx@xx.com"
          # gitlab_rails['smtp_password'] = "password"
          # gitlab_rails['smtp_authentication'] = "login"
          # gitlab_rails['smtp_enable_starttls_auto'] = true
          # gitlab_rails['smtp_tls'] = true
          # gitlab_rails['gitlab_email_from'] = 'xxxx@xx.com'
      ports:
        - '9999:9999'
          #- '443:443'
          #- '22:22'
      volumes:
        - /home/dongfeng/app/docker/compose/gitlab/config:/etc/gitlab
        - /home/dongfeng/app/docker/compose/gitlab/data:/var/opt/gitlab
        - /home/dongfeng/app/docker/compose/gitlab/logs:/var/log/gitlab

5. 启动应用

docker-compose up -d

6. 访问

http://dongfeng.gitlab.top:9999

7. gitlab-ci

before_script:
  - echo "----job begin----"

after_script:
  - echo "----job over----"

stages:
  - build
  - test
  - deploy

cache:
  key: ${CI_BUILD_STAGE}
  untracked: true
  paths:
  #- .

variables:
  #GIT_STRATEGY: fetch
  GIT_DEPTH: "1"

#template
.job_template: &job_definiation
  stage: build
  tags:
    - 5gc-c-builder
  only:
    - master

docker-deploy:
  <<: *job_definiation
  script:
    - docker run -i
      --rm
      --user root
      --name=$USER
      --workdir="/root/baicells-5gc-c"
      -v $(pwd):/root/baicells-5gc-c
      compiler:1.0
  #environment:
     #name: production
     #url: http://workerwork.github.io

bins-distribute:
  <<: *job_definiation
  script:
    - author=$(git show -q | awk '/Author/{print $2}')
    - commit=$(git show -q | awk '/commit/{print $2}' | cut -c 1-8)
    - date=$(date +%Y%m%d)
    - mkdir /home/$author || true
    - cp -rf amf/bin/x86_64-ubuntu/amf /home/$author/amf-$commit-$date
    - cp -rf smf/bin/x86_64-ubuntu/smf /home/$author/smf-$commit-$date
    - chown $author:$author /home/$author/amf-$commit-$date
    - chown $author:$author /home/$author/smf-$commit-$date
  #when: manual

8. 略过gitlab-ci

git push -o ci.skip

9. gitlab-runner安装

https://docs.gitlab.com/runner/

# sudo curl -L --output /usr/bin/gitlab-runner https://gitlab-runner-downloads.s3.amazonaws.com/latest/binaries/gitlab-runner-linux-amd64
# sudo chmod +x /usr/bin/gitlab-runner
# sudo gitlab-runner install --user=root --working-directory=/root/gitlab-runner
# sudo gitlab-runner start
# sudo gitlab-runner register
# 选用shell