编写一个kubernetes构建脚本
由于需要多次打包镜像,于是写一个脚本自动执行
build.sh
v="5.3.8.1"
m="monitor-console"
time=$(date +"%Y%m%d%H%M")
img="harbor.k8s/agree/mp/${m}:v${v}_${time}"
echo "开始构建镜像:${img}"
docker build -t $img .
echo "开始导出镜像: ${img}"
tgz="${m}-v${v}_${time}.tar.gz"
docker save $img | gzip > $tgz
echo "构建导出完成: ${tgz}"
记得添加执行权限 chmod +x build.sh
Dockerfile
[root@k8s-master1 auth-center]# cat Dockerfile
FROM harbor.k8s/agree/alpine-jdk-curl:latest
ADD *.jar app.jar
EXPOSE 8080
ENTRYPOINT ["java","-Djava.security.egd=file:/dev/./urandom","-Duser.timezone=GMT+08","-jar","/app.jar"]