(1)web-server:mysql数据库安装
yum -y install mariadb mariadb-server
开机自启动
systemctl enable mariadb
systemctl start mariadb
mysqladmin -uroot password 'root'
mysql -uroot -proot
create database if not exists db01 default charset utf8 collate utf8_general_ci;
grant all on db01.* to 'root'@'%' identified by "root";
grant all on db01.* to 'root'@'localhost' identified by "root";
(2)harbor-server
mkdir tomcatdir
cd tomcatdir
首页
echo "tomcat is running" >> index.html
vim Dockerfile
tar xf jdk-8u341-linux-x64.tar.gz
目录如下之后
/root/tomcatdir/index.html
/root/tomcatdir/Dockerfile
/root/tomcatdir/jdk
docter设置国内镜像
vim /etc/docker/key.json
{
"registry-mirrors": ["https://registry.docker-cn.com"]
}
systemctl daemon-reload
systemctl restart docker
开始使用docker构建镜像
docker build -t [镜像名] .
docker build -t 192.168.19.130/library/demo .
查看
docker images
重启docker
systemctl restart docker
把镜像推送到镜像仓库
docker login 192.168.19.130
docker push 192.168.19.130/library/demo
验证容器镜像可用性
docker run -d 192.168.19.130/library/demo
docker ps
查看ip地址
docker inspect d470
访问后台数据
curl http://172.17.0.2:8080/person/get
(3)Jenkins新建Item:项目构建以及构建步骤
新任务
【Gitlab Connection】
this project is parameterized
git parameter
名称:TAG
描述:这是一个用于发布项目的测试
参数类型:标签
默认值:1.0.0
【源码管理】
把gitlab项目http地址拷贝过来、添加凭证jenkins-server to gitlab-server
指定分支$TAG 注意和上边的名称TAG一样
【Additional Behaviours】
递归更新子模块
Advanced sub-modules behavours
Update tracking...
Use credentials...
Build构建
pom.xml
clean package -Dmaven.test.skip=true
Post Steps 发布
execute shell 脚本文件
REPOSITORY=192.168.19.130/library/demo:${TAG}
#构建镜像
cat > Dockerfile << EOF
FROM 192.168.19.130/library/demo
docker run -p 8080:8080 -t 192.168.19.130/library/demo
EOF
docker build -t $REPOSITORY .
#上传镜像
docker login 192.168.19.130 -u admin -p Harbor12345
docker push $REPOSITORY文章来源:https://www.toymoban.com/news/detail-829848.html
docker logout 192.168.19.130文章来源地址https://www.toymoban.com/news/detail-829848.html
到了这里,关于DevOps实战十:完整流程的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!