美文网首页
新云服务器初始化脚本

新云服务器初始化脚本

作者: eftales | 来源:发表于2020-03-26 20:44 被阅读0次

    基础配置

    安装 git screen node

    adduser eftales sudo
    nano /etc/sudoers
    # eftales ALL=(ALL:ALL) ALL
    usermod -s /bin/bash eftales
    su eftales
    sudo apt update
    sudo apt install screen git -y
    git config --global user.name "eftales"
    git config --global user.email "1479803084@qq.com"
    
    

    安装 docker,docker-compose

    # 安装 docker 和 docker-compose
    sudo apt-get remove docker docker-engine docker.io containerd runc
    sudo apt-get update
    sudo apt-get install  -y \
        apt-transport-https \
        ca-certificates \
        curl \
        gnupg-agent \
        software-properties-common
    curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
    sudo add-apt-repository \
    "deb [arch=amd64] https://download.docker.com/linux/ubuntu \
    $(lsb_release -cs) \
    stable"
    sudo apt-get update
    sudo apt-get install docker-ce docker-ce-cli containerd.io -y
    
    sudo curl -L "https://github.com/docker/compose/releases/download/1.25.3/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
    sleep 1
    sudo chmod +x /usr/local/bin/docker-compose
    
    sudo systemctl start docker
    sudo systemctl enable docker
    sudo groupadd docker #添加docker用户组
    sudo usermod -a -G docker $USER
    
    sudo mkdir -p /etc/docker
    echo "{" > daemon.json
    echo "\"registry-mirrors\": [\"https://ofyci9nf.mirror.aliyuncs.com\"]" >> daemon.json
    echo "}" >> daemon.json
    echo "" >> daemon.json
    
    sudo mv daemon.json  /etc/docker/daemon.json
    
    sudo systemctl daemon-reload
    sudo systemctl restart docker
    
    sleep 5
    
    sudo gpasswd -a $USER docker #将当前用户添加至docker用户组
    sudo newgrp docker #更新docker用户组
    

    安装 gitlab-runner

    sudo curl -L --output /usr/local/bin/gitlab-runner https://gitlab-runner-downloads.s3.amazonaws.com/latest/binaries/gitlab-runner-linux-amd64
    
    sudo chmod +x /usr/local/bin/gitlab-runner
    
    sudo useradd --comment 'GitLab Runner' --create-home gitlab-runner --shell /bin/bash -g root -G root
    
    sudo gitlab-runner install --user=gitlab-runner --working-directory=/home/gitlab-runner
    sudo gitlab-runner start
    
    sudo gitlab-runner register # 配置 gitlab runner
    
    sudo usermod -a -G docker gitlab-runner
    sudo gpasswd -a gitlab-runner docker #将当前用户添加至docker用户组
    sudo newgrp docker #更新docker用户组
    

    相关文章

      网友评论

          本文标题:新云服务器初始化脚本

          本文链接:https://www.haomeiwen.com/subject/kllhuhtx.html