Dockerfile以及一些实例脚本
FROM ${docker.base.image.name}
ENV LANG C.UTF-8
ENV TZ=Asia/Shanghai
#ENV JAVA_OPTS="-XX:PermSize=64M -XX:MaxPermSize=128m -Xms512m -Xmx1024m "
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
ADD ./*.jar /usr/local/hcdata.jar
#CMD ["catalina.sh", "run"]
ENTRYPOINT ["java","-jar","-Duser.timezone=GMT+8","/usr/local/hcdata.jar"]
一个创建dockerfile脚本及修改k8s镜像更新pod脚本示例
#!/bin/sh -ilex
/usr/bin/cp /usr/local/test/api/target/api.jar /jar/api/
cd /jar/api/
/usr/bin/cat > /jar/api/Dockerfile << EOF
FROM java:8
ADD api.jar /opt/api.jar
RUN ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
ENTRYPOINT ["java","-jar","-Duser.timezone=GMT+8","/opt/api.jar"]
EOF
cd /jar/api/
datetime=`date +%m%d%H%M`
/usr/bin/docker build -t 10.10.49.40/lottery/api:$datetime . && echo "SUCCESS_INFO "镜像制作成功"" || echo "FAIL_INFO "镜像制作失败,请检查!""
/usr/bin/docker push 10.10.49.40/lottery/api:$datetime && echo -e "SUCCESS_INFO "推送镜像成功!"" || echo -e "\e[5;31mFAIL_INFO "push镜像失败,请检查!\e[m0""
kubectl patch deployment api --patch '{"spec": {"template": {"spec": {"containers": [{"name": "api","image":"10.10.49.40/lottery/api:'$datetime'"}]}}}}'