前言
Jenkins和docker的安装,随便百度吧,实际场景中我们很多微服务的架构,都是有公共包,肯定是希望一个任务能够把公共包的配置加进去,一并构建,ok,直接上干货。
Jenkins
全局环境安装
pwd
echo "开始部署....."
docker version
echo "删除历史镜像...."
if test "$(docker images -q szls-auth:1.0.0 2> /dev/null)" = ""
then
echo '不存在历史镜像'
else
docker rm -f szls-auth
docker rmi szls-auth:1.0.0
fi
cd szls-auth
echo "打包新镜像"
docker build -t szls-auth:1.0.0 .
echo "服务正在启动....."
docker-compose -f /home/compose/05-szls-auth.yml up -d
echo "部署完成...."
使用docker内部网络,分配ip,参考docker创建网络
docker-compose.yml
version: '3.7'
services:
szls-auth:
image: szls-auth:1.0.0
restart: always
container_name: szls-auth
ports:
- 8890:80
deploy:
restart_policy:
condition: on-failure
delay: 15s
networks:
gwfd-network:
ipv4_address: 172.16.0.7
networks:
gwfd-network:
external: true