gitci(Git Container Image)是指一种特殊的 Git 仓库,其中包含了 Docker 镜像构建的相关信息和配置文件。通过将 Dockerfile 和其他构建所需的文件直接存储在 Git 仓库中,可以实现对基于 Docker 的应用程序或服务的版本控制和持续集成。
git项目中的 .gitlab-ci.yml
#流水线的stages的顺序可以自己定义
#相同阶段的任务将会并发的执行,上一个阶段的任务完整的结束之后,下一个阶段的任务才会开始执行
build-jar:
stage: build
tags:
- maven-gradle-docker-java8-247
script:
- mvn clean
- mvn package -DskipTests
artifacts:
paths:
- ivsign-website-api/target/*.jar
build-web:
stage: build
image: node:16.20.0
tags:
- nodejs
cache:
paths:
- ivsign-website-vue/node_modules
script:
- cd ivsign-website-vue
- npm --registry https://registry.npmmirror.com install
- npm --registry https://registry.npmmirror.com run build
artifacts:
paths:
- ivsign-website-vue/dist
build-web-deply:
stage: deploy
tags:
- maven-gradle-docker-java8-247
needs: [build-web]
script:
- cd ivsign-website-vue/dist
- sshpass -p 'pwd@2018' scp -o StrictHostKeyChecking=no -r * root@192.xxx.168.162:/home/softwares/bio-web/pages/webHtml_new
build-image-ivsign-website-api:
stage: deploy
tags:
- maven-gradle-docker-java8-247
script:
- cd ivsign-website-api/
- cp target/*.jar script
- cd script
- ls -l
- cd ..
- # 登录docker服务,登录成功后,你就可以在本地 Docker 客户端执行推送和拉取镜像的操作
- sudo docker login -u 'admin' -p 'Harbor12345' 192.168.xx.xx:61234/ivsign-website
- sudo docker build -t 192.168.xx.xxx:61234/ivsign-website/ivsign-website-api:1.0.0 --network=host script
- sudo docker push 192.168.xx.xxx:61234/ivsign-website/ivsign-website-api:1.0.0
- sshpass -p root ssh -o StrictHostKeyChecking=no root@192.168.xx.xx "sh /home/softwares/ivsign-website-api/restart.sh ivsign-website-api 192.168.xx.xxx:61234/ivsign-website/ivsign-website-api:1.0.0"
CI/CD => Pipelines
查看推送打包记录