#!/bin/bash
mvn clean
mvn package -Dmaven.test.skip=true
#image_version=$(date +%Y%m%d%H%M)
image_version=$version
docker stop sentinel_dashboard || true
docker rm sentinel_dashboard || true

# 删除镜像
# docker rmi -f $(docker images | grep telpo/sentinel_dashboard | awk '{print $3}')

docker build . -t telpo/sentinel_dashboard:$image_version

#TODO:推送镜像到私有仓库
echo '=================开始推送镜像======================='
docker tag telpo/sentinel_dashboard:$image_version 139.224.254.18:5000/sentinel_dashboard:$image_version
docker push 139.224.254.18:5000/sentinel_dashboard:$image_version
echo '=================推送镜像完成======================='

#删除产生的None镜像
docker rmi -f $(docker images | grep none | awk '{print $3}')
# 查看镜像列表
docker images
# 启动容器
docker run -p 7777:7777 -v /home/data/sentineldashboard/log:/var/log/sentineldashboard -d -e active=test --network host --restart=always --name sentinel_dashboard 139.224.254.18:5000/sentinel_dashboard:$image_version
# 查看日志
# docker logs sentinel_dashboard
