1、gitlab服务器基础环境搭建
1) ubuntu和cmake安装
Ubuntu:18.04
Tensorflow:1.14.0
Cmake 3.16
说明:cmake要求3.16版本以上,此处以cmake-3.17安装为例
cmake –version(查看当前cmake版本)
sudo apt-get remove cmake (删除旧的cmake版本)
wget https://cmake.org/files/v3.17/cmake-3.17.1.tar.gz(下载cmake-3.17压缩包)
tar -xzvf cmake-3.17.1.tar.gz(解压cmake-3.17压缩包)
cd cmake-3.17.1
sudo apt-get install build-essential(安装cmake-3.17)
./bootstrap
若运行./bootstrap报错,请按照 错误1 的方法解决。然后再继续下面的安装步骤。
make
sudo make install
若make和make install错误,请按照 错误2 的方法解决。
cmake –version确认是否安装成功
2) protobuf安装问题
https://blog.csdn.net/FK2016/article/details/83375048?spm=1001.2101.3001.6661.1&utm_medium=distribute.pc_relevant_t0.none-task-blog-2%7Edefault%7ECTRLIST%7Edefault-1.essearch_pc_relevant&depth_1-utm_source=distribute.pc_relevant_t0.none-task-blog-2%7Edefault%7ECTRLIST%7Edefault-1.essearch_pc_relevant
版本3.7.1
sudo apt-get remove libprotobuf-dev
which protoc
rm /usr/bin/protoc
sudo apt-get install autoconf automake libtool curl make g++ unzip
git clone –b v3.7.1 https://github.com/protocolbuffers/protobuf.git
cd protobuf
git submodule update --init --recursive
cd protobuf
./autogen.sh
./configure
make -j4
make check | sudo make install
sudo ldconfig
protoc --version
3)gtest安装
git clone https://github.com/google/googletest.git
cd gtest
mkdir build
cmake ..
make –j4
sudo make install
4) jsoncpp安装问题
版本1.9.3
mkdir build; cd build; cmake .. ;make -j4; sudo make install
5)依赖项
sudo apt install clang
sudo apt-get install -y python3 python3-dev python3-setuptools gcc libtinfo-dev zlib1g-dev build-essential libedit-dev libxml2-dev python3-pip
sudo apt install graphviz
pip3 install --user numpy decorator attrs
pip3 install --user tornado psutil xgboost
sudo apt install protobuf-compiler
sudo apt install libprotobuf-dev
sudo apt-get install libboost-all-dev
pip3 install typed_ast scipy tensorflow
pip3 install onnx==1.9.0
pip3 install pytorch==1.10.0
pip3 install pytest==6.2.5
pip3 install pytest-forked==1.4.0
pip3 install pytest-parallel==0.1.1
pip3 install pytest-xdist==2.5.0
pip3 install onnxoptimize==x.x.x ( if use onnxoptimize )
6)环境变量设置
source ~/.bashrc
2、gitlab服务器部署、更新和备份恢复:
3、gitlab配置gitlab-runner,实现CI/CD流程:
1)下载gitlab-runner
Download and install binary # Download the binary for your system sudo curl -L --output /usr/local/bin/gitlab-runner https://gitlab-runner-downloads.s3.amazonaws.com/latest/binaries/gitlab-runner-linux-amd64
2)安装gitlab-runner
# Give it permissions to execute sudo chmod +x /usr/local/bin/gitlab-runner # Create a GitLab CI user sudo useradd --comment 'GitLab Runner' --create-home gitlab-runner --shell /bin/bash # Install and run as service sudo gitlab-runner install --user=gitlab-runner --working-directory=/home/gitlab-runner sudo gitlab-runner start
3)注册runner sudo gitlab-runner register --url http://192.168.10.99/ --registration-token avMBwSLHcaYAQzBHpMcj
然后一直回车,直到提示Registering runner... succeeded,后输入shell。
4)在代码工程目录下添加.gitlab-ci.yml,例子:
stages: # List of stages for jobs, and their order of execution
- build
- test
- deploy
build-job: # This job runs in the build stage, which runs first.
stage: build
script:
- echo "Compiling the code..."
- echo "Compile complete."
- ./build.sh #工程编译脚本
- ./run.sh #工程执行脚本
unit-test-job: # This job runs in the test stage.
stage: test # It only starts when the job in the build stage completes successfully.
script:
- echo "Running unit tests... This will take about 60 seconds."
- sleep 1
- echo "Code coverage is 90%"
lint-test-job: # This job also runs in the test stage.
stage: test # It can run at the same time as unit-test-job (in parallel).
script:
- echo "Linting code... This will take about 10 seconds."
- sleep 1
- echo "No lint issues found."
deploy-job: # This job runs in the deploy stage.
stage: deploy # It only runs when *both* jobs in the test stage complete successfully.
script:
- rm -rf dump_sv
- echo "Deploying application..."
- echo "Application successfully deployed."
5)如果提示
按照下面流程将gitlab-runner修改为可以执行没有标签的作用。