代码拉取完成,页面将自动刷新
同步操作将从 余笙/天机学堂 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
#! /bin/sh
cd /usr/local/src/script || exit 1
BASE_PATH='/usr/local/src/jenkins/workspace/tjxt-dev-build'
PROJECT_NAME=""
PROJECT_PATH=''
CONTAINER_NAME=""
JAVA_OPTS="-Xms300m -Xmx300m"
PORT=8080
DEBUG_PORT=0
while getopts "c:n:d:p:o:a:" opt; do
case $opt in
c)
CONTAINER_NAME=$OPTARG
;;
n)
PROJECT_NAME=$OPTARG
;;
d)
PROJECT_PATH=$OPTARG
;;
p)
PORT=$OPTARG
;;
o)
[ -n "$OPTARG" ] && JAVA_OPTS=$OPTARG
;;
a)
[ -n "$OPTARG" ] && DEBUG_PORT=$OPTARG
;;
?)
echo "unkonw argument"
exit 1
;;
esac
done
if [ "$DEBUG_PORT" = "0" ]; then
JAVA_OPTS=$JAVA_OPTS
else
JAVA_OPTS="-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=*:5005"
fi
IMAGE_NAME="${CONTAINER_NAME}:latest"
echo "copy xx.jar from ${BASE_PATH}/${PROJECT_PATH}"
rm -f app.jar
cp ${BASE_PATH}/${PROJECT_PATH}/target/${PROJECT_NAME}.jar ./app.jar || exit 1
echo "begin to build ${PROJECT_NAME} image !!"
[ -n "`docker ps -a | grep ${CONTAINER_NAME}`" ] && docker rm -f ${CONTAINER_NAME}
[ -n "`docker images | grep ${CONTAINER_NAME}`" ] && docker rmi ${IMAGE_NAME}
docker build -t ${IMAGE_NAME} . || exit 1
echo "${PROJECT_NAME} image build success,java_opts = $JAVA_OPTS !!^_^"
echo "begin to create container ${CONTAINER_NAME},port: ${PORT} !!"
if [ "$DEBUG_PORT" = "0" ]; then
echo "run in normal mode"
docker run -d --name ${CONTAINER_NAME} \
-p "${PORT}:${PORT}" \
-e JAVA_OPTS="${JAVA_OPTS}" \
--memory 300m --memory-swap -1 \
--network heima-net ${IMAGE_NAME} \
|| exit 1
else
echo "run in debug mode"
docker run -d --name ${CONTAINER_NAME} \
-p "${PORT}:${PORT}" \
-p ${DEBUG_PORT}:5005 \
-e JAVA_OPTS="${JAVA_OPTS}" \
--network heima-net ${IMAGE_NAME} \
|| exit 1
fi
echo "container is running now !! ^_^"
exit 0
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。