1 Star 1 Fork 1

EllieHy/tianji

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
startup.sh 1.94 KB
一键复制 编辑 原始数据 按行查看 历史
tjxt 提交于 2022-11-09 15:37 . 更新 'startup.sh'
#! /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
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/hywyll/tianji.git
git@gitee.com:hywyll/tianji.git
hywyll
tianji
tianji
lesson-init

搜索帮助

0d507c66 1850385 C8b1a773 1850385