提交 8454d229 编写于 作者: sq3536's avatar sq3536

docker支持三种模式

上级 b7e0d8c4
...@@ -10,4 +10,4 @@ ADD ibizlabcli /usr/bin/ibizlabcli ...@@ -10,4 +10,4 @@ ADD ibizlabcli /usr/bin/ibizlabcli
CMD ["/usr/bin/ibizlabcli"] CMD ["/usr/bin/ibizlabcli"]
#docker buildx build --platform linux/arm64,linux/amd64 -t ibiz4j/ibizlab-cli:1.0.1 -t ibiz4j/ibizlab-cli:latest --push . #docker buildx build --platform linux/arm64,linux/amd64 -t ibiz4j/ibizlab-cli:1.0.2 -t ibiz4j/ibizlab-cli:latest --push .
\ No newline at end of file \ No newline at end of file
version: "3.2"
services:
ibizlab-cli:
image: ibiz4j/ibizlab-cli:latest
environment:
#是否在发布代码前更新发布引擎程序,不推荐开启
- CLI_UPDATE=true
#内置模板名,不设置该值时自动抓取GIT_REPO的git库根路径下generator.yml中embedTemplates属性
- TEMPLATENAME=ibizlab-template-ibizedge
#内置模板版本,不设置该值时自动抓取GIT_REPO的git库根路径下generator.yml中embedTemplates属性
- TEMPLATEVERSION=1.0-SNAPSHOT
volumes:
#挂载发布目标路径到docker中的/generator/output目录
- /xxx/project:/generator/output
#挂载模型目录路径到docker中的/model
- /xxx/remotemodel:/model
version: "3.2"
services:
ibizlab-cli:
image: ibiz4j/ibizlab-cli:latest
environment:
#git库repo
- GIT_REPO=http://oauth2:C5zdMHyeAyMwX5Qig-T@demo.ibizlab.cn/t48e9d7d8e2dab3018133378ca1d8a4b6/xftongdev
#git库分支,不设置默认取master
- GIT_BRANCH=master
#git库提交用户名称
- GIT_USER_NAME=ibizlabcli
#git库提交用户邮箱
- GIT_USER_EMAIL=ibizlabcli@ibizsys.net
#git commit时的message说明
- GIT_PUSH_MESSAGE=cli
#是否在发布代码前更新发布引擎程序,不推荐开启
# - CLI_UPDATE=true
#内置模板名,不设置该值时自动抓取GIT_REPO的git库根路径下generator.yml中embedTemplates属性
- TEMPLATENAME=ibizlab-template-ibizedge
#内置模板版本,不设置该值时自动抓取GIT_REPO的git库根路径下generator.yml中embedTemplates属性
- TEMPLATEVERSION=1.0-SNAPSHOT
...@@ -6,11 +6,11 @@ services: ...@@ -6,11 +6,11 @@ services:
#源git库repo,同义参数GIT_PROD_REPO #源git库repo,同义参数GIT_PROD_REPO
- CODEGEN_CODE_URL=http://demo.ibizlab.cn/t48e9d7d8e2dab3018133378ca1d8a4b6/xftong - CODEGEN_CODE_URL=http://demo.ibizlab.cn/t48e9d7d8e2dab3018133378ca1d8a4b6/xftong
#源git库oauth2令牌,同义参数GIT_PROD_REPO #源git库oauth2令牌,同义参数GIT_PROD_REPO
- CODEGEN_CODE_PASSWORD=pppppp - CODEGEN_CODE_PASSWORD=C5zdMHyeAyMwX5Qig-T
#源git库分支,同义参数GIT_PROD_BRANCH,不设置默认取master #源git库分支,同义参数GIT_PROD_BRANCH,不设置默认取master
- CODEGEN_CODE_BRANCH=master - CODEGEN_CODE_BRANCH=master
#目标git库repo,同义参数GIT_DEV_REPO #目标git库repo,同义参数GIT_DEV_REPO
- CODEGEN_RO_URL=http://oauth2:xxxx@demo.ibizlab.cn/t48e9d7d8e2dab3018133378ca1d8a4b6/xftongdev - CODEGEN_RO_URL=http://oauth2:C5zdMHyeAyMwX5Qig-T@demo.ibizlab.cn/t48e9d7d8e2dab3018133378ca1d8a4b6/xftongdev
#目标git库分支,同义参数GIT_DEV_BRANCH,不设置默认取master #目标git库分支,同义参数GIT_DEV_BRANCH,不设置默认取master
- CODEGEN_RO_BRANCH=master - CODEGEN_RO_BRANCH=master
#git提交用户,同义参数GIT_DEV_USER_NAME,CODEGEN_RO_USER #git提交用户,同义参数GIT_DEV_USER_NAME,CODEGEN_RO_USER
......
...@@ -11,11 +11,39 @@ if [ $CLI_UPDATE ];then ...@@ -11,11 +11,39 @@ if [ $CLI_UPDATE ];then
fi fi
fi fi
if [ $GIT_REPO ];then
echo "single mode (single git repo's checkout->generate->push)."
GIT_PROD_REPO=$GIT_REPO
GIT_DEV_REPO=$GIT_REPO
if [ ! $GIT_BRANCH ];then
GIT_BRANCH=master
echo "env GIT_BRANCH does not exist, using 'master'."
fi
GIT_PROD_BRANCH=$GIT_BRANCH
GIT_DEV_BRANCH=$GIT_BRANCH
if [ ! $GIT_USER_NAME ];then
GIT_USER_NAME=ibizlabcli
echo "env GIT_USER_NAME does not exist, using 'ibizlabcli'."
fi
if [ ! $GIT_USER_EMAIL ];then
GIT_USER_EMAIL=$GIT_USER_NAME@ibizsys.net
echo "env GIT_USER_EMAIL does not exist, using '$GIT_USER_NAME@ibizsys.net'."
fi
GIT_DEV_USER_NAME=$GIT_USER_NAME
GIT_DEV_USER_EMAIL=$GIT_USER_EMAIL
fi
if [ ! $GIT_PROD_REPO ];then if [ ! $GIT_PROD_REPO ];then
if [ ! $CODEGEN_CODE_URL ];then if [ ! $CODEGEN_CODE_URL ];then
if [ -d "/generator/output" ];then
echo "file mode (generate -> /generator/output)."
FASTOUTPUT=TRUE
else
echo "unknow prod git, env GIT_PROD_REPO or CODEGEN_CODE_URL does not exist." echo "unknow prod git, env GIT_PROD_REPO or CODEGEN_CODE_URL does not exist."
exit 1 exit 1
fi fi
fi
if [ $CODEGEN_CODE_PASSWORD ];then if [ $CODEGEN_CODE_PASSWORD ];then
if [[ ! "${CODEGEN_CODE_URL}" =~ "@" ]];then if [[ ! "${CODEGEN_CODE_URL}" =~ "@" ]];then
CODEGEN_CODE_URL=${CODEGEN_CODE_URL/#"http://"/"http://oauth2:${CODEGEN_CODE_PASSWORD}@"} CODEGEN_CODE_URL=${CODEGEN_CODE_URL/#"http://"/"http://oauth2:${CODEGEN_CODE_PASSWORD}@"}
...@@ -27,37 +55,53 @@ if [ ! $GIT_PROD_REPO ];then ...@@ -27,37 +55,53 @@ if [ ! $GIT_PROD_REPO ];then
GIT_PROD_REPO=$CODEGEN_CODE_URL GIT_PROD_REPO=$CODEGEN_CODE_URL
fi fi
if [ ! $GIT_PROD_BRANCH ];then if [ ! $FASTOUTPUT ];then
echo "extension mode (prod git repo's checkout -> generate -> dev git repo's push)."
if [ ! $GIT_PROD_BRANCH ];then
if [ ! $CODEGEN_CODE_BRANCH ];then if [ ! $CODEGEN_CODE_BRANCH ];then
GIT_PROD_BRANCH=master GIT_PROD_BRANCH=master
echo "env GIT_PROD_BRANCH or CODEGEN_CODE_BRANCH does not exist, using 'master'." echo "env GIT_PROD_BRANCH or CODEGEN_CODE_BRANCH does not exist, using 'master'."
else else
GIT_PROD_BRANCH=$CODEGEN_CODE_BRANCH GIT_PROD_BRANCH=$CODEGEN_CODE_BRANCH
fi fi
fi fi
if [ ! $GIT_DEV_REPO ];then if [ ! $GIT_DEV_REPO ];then
if [ ! $CODEGEN_RO_URL ];then if [ ! $CODEGEN_RO_URL ];then
echo "unknow dev git, env GIT_DEV_REPO or CODEGEN_RO_URL does not exist." echo "unknow dev git, env GIT_DEV_REPO or CODEGEN_RO_URL does not exist."
exit 1 exit 1
fi fi
GIT_DEV_REPO=$CODEGEN_RO_URL GIT_DEV_REPO=$CODEGEN_RO_URL
fi fi
if [ ! $GIT_DEV_BRANCH ];then if [ ! $GIT_DEV_BRANCH ];then
if [ ! $CODEGEN_RO_BRANCH ];then if [ ! $CODEGEN_RO_BRANCH ];then
GIT_DEV_BRANCH=master GIT_DEV_BRANCH=master
echo "env GIT_DEV_BRANCH or CODEGEN_RO_BRANCH does not exist, using 'master'." echo "env GIT_DEV_BRANCH or CODEGEN_RO_BRANCH does not exist, using 'master'."
else else
GIT_DEV_BRANCH=$CODEGEN_RO_BRANCH GIT_DEV_BRANCH=$CODEGEN_RO_BRANCH
fi fi
fi
fi fi
mkdir -p /generator mkdir -p /generator
cd /generator cd /generator
rm -rf /generator/* if [ $FASTOUTPUT ];then
git clone -b $GIT_PROD_BRANCH --depth=1 $GIT_PROD_REPO prod echo "ln -s /generator/output /generator/prod"
ln -s /generator/output /generator/prod
else
rm -rf /generator/prod
rm -rf /generator/dev
if [ $GIT_REPO ];then
git clone -b $GIT_PROD_BRANCH $GIT_PROD_REPO prod
else
git clone -b $GIT_PROD_BRANCH --depth=1 $GIT_PROD_REPO prod
fi
fi
if [ ! $MODELFOLDER ];then if [ ! $MODELFOLDER ];then
if [ ! $CODEGEN_MODEL_PATH ];then if [ ! $CODEGEN_MODEL_PATH ];then
...@@ -70,21 +114,51 @@ if [ ! $MODELFOLDER ];then ...@@ -70,21 +114,51 @@ if [ ! $MODELFOLDER ];then
fi fi
if [ ! $MODELFOLDER ];then if [ ! $MODELFOLDER ];then
if [ -f "/model/PSSYSTEM.json" ];then
MODELFOLDER=/model
else
echo "unknow model folder, env MODELFOLDER or CODEGEN_MODEL_PATH does not exist, ibizmodel.yaml not found." echo "unknow model folder, env MODELFOLDER or CODEGEN_MODEL_PATH does not exist, ibizmodel.yaml not found."
exit 1 exit 1
fi
fi fi
echo spec dir: $MODELFOLDER echo spec dir: $MODELFOLDER
if [ $FASTOUTPUT ];then
git clone -b $GIT_DEV_BRANCH $GIT_DEV_REPO dev echo "ln -s /generator/output /generator/dev"
ln -s /generator/output /generator/dev
else
if [ $GIT_REPO ];then
echo "ln -s /generator/prod /generator/dev"
ln -s /generator/prod /generator/dev
else
git clone -b $GIT_DEV_BRANCH $GIT_DEV_REPO dev
fi
fi
cd prod cd prod
java ${JAVA_OPTS} -Duser.timezone=$TZ -jar /root/.m2/repository/cn/ibizlab/ibizlab-generator-cli/1.0-SNAPSHOT/ibizlab-generator-cli-1.0-SNAPSHOT.jar generate -i $MODELFOLDER -c ../dev/generator.yml -o ../dev if [ -f "../dev/generator.yml" ];then
rm -rf dev/generator.xml java ${JAVA_OPTS} -Duser.timezone=$TZ -jar /root/.m2/repository/cn/ibizlab/ibizlab-generator-cli/1.0-SNAPSHOT/ibizlab-generator-cli-1.0-SNAPSHOT.jar generate -i "$MODELFOLDER" -c ../dev/generator.yml -o ../dev
else
if [ ! $TEMPLATENAME ];then
if [ ! $TEMPLATEDIR ];then
echo "unknow template, env TEMPLATENAME or TEMPLATEDIR does not exist, generator.yaml not found."
exit 1
else
java ${JAVA_OPTS} -Duser.timezone=$TZ -jar /root/.m2/repository/cn/ibizlab/ibizlab-generator-cli/1.0-SNAPSHOT/ibizlab-generator-cli-1.0-SNAPSHOT.jar generate -i "$MODELFOLDER" -t "$TEMPLATEDIR" -o ../dev
fi
else
if [ ! $TEMPLATEDIR ];then
java ${JAVA_OPTS} -Duser.timezone=$TZ -jar /root/.m2/repository/cn/ibizlab/ibizlab-generator-cli/1.0-SNAPSHOT/ibizlab-generator-cli-1.0-SNAPSHOT.jar generate -i "$MODELFOLDER" --embed-template "$TEMPLATENAME:$TEMPLATEVERSION" --embed-template "$TEMPLATENAME2:$TEMPLATEVERSION2" --embed-template "$TEMPLATENAME3:$TEMPLATEVERSION3" --embed-template "$TEMPLATENAME4:$TEMPLATEVERSION4" -o ../dev
else
java ${JAVA_OPTS} -Duser.timezone=$TZ -jar /root/.m2/repository/cn/ibizlab/ibizlab-generator-cli/1.0-SNAPSHOT/ibizlab-generator-cli-1.0-SNAPSHOT.jar generate -i "$MODELFOLDER" --embed-template "$TEMPLATENAME:$TEMPLATEVERSION" --embed-template "$TEMPLATENAME2:$TEMPLATEVERSION2" --embed-template "$TEMPLATENAME3:$TEMPLATEVERSION3" --embed-template "$TEMPLATENAME4:$TEMPLATEVERSION4" -t "$TEMPLATEDIR" -o ../dev
fi
fi
fi
rm -rf ../dev/generator.xml
cd ../dev/ cd ../dev/
if [ ! $FASTOUTPUT ];then
if [ ! $GIT_DEV_USER_NAME ];then if [ ! $GIT_DEV_USER_NAME ];then
if [ $CODEGEN_RO_USER ];then if [ $CODEGEN_RO_USER ];then
GIT_DEV_USER_NAME=$CODEGEN_RO_USER GIT_DEV_USER_NAME=$CODEGEN_RO_USER
else else
...@@ -95,17 +169,18 @@ if [ ! $GIT_DEV_USER_NAME ];then ...@@ -95,17 +169,18 @@ if [ ! $GIT_DEV_USER_NAME ];then
echo "env GIT_DEV_USER_NAME or CODEGEN_RO_USER or CODEGEN_CODE_USER does not exist, using 'ibizlabcli'." echo "env GIT_DEV_USER_NAME or CODEGEN_RO_USER or CODEGEN_CODE_USER does not exist, using 'ibizlabcli'."
fi fi
fi fi
fi fi
git config user.name "$GIT_DEV_USER_NAME" git config user.name "$GIT_DEV_USER_NAME"
if [ ! $GIT_DEV_USER_EMAIL ];then if [ ! $GIT_DEV_USER_EMAIL ];then
GIT_DEV_USER_EMAIL=$GIT_DEV_USER_NAME@ibizsys.net GIT_DEV_USER_EMAIL=$GIT_DEV_USER_NAME@ibizsys.net
fi fi
git config user.email "$GIT_DEV_USER_EMAIL" git config user.email "$GIT_DEV_USER_EMAIL"
set +e set +e
git add . git add .
git commit -m "generate by $GIT_DEV_USER_NAME. $GIT_PUSH_MESSAGE" git commit -m "generate by $GIT_DEV_USER_NAME. $GIT_PUSH_MESSAGE"
git push origin $GIT_DEV_BRANCH git push origin $GIT_DEV_BRANCH
set -e set -e
fi
exit 0 exit 0
\ No newline at end of file
...@@ -27,6 +27,8 @@ public class EmbedTemplate { ...@@ -27,6 +27,8 @@ public class EmbedTemplate {
tag=DynamicParamUtils.process(tag); tag=DynamicParamUtils.process(tag);
EmbedTemplate template=new EmbedTemplate(); EmbedTemplate template=new EmbedTemplate();
String tags[]=tag.split(":"); String tags[]=tag.split(":");
if(tags.length==0)
return null;
template.setName(tags[0].trim()); template.setName(tags[0].trim());
if(tags.length>1) if(tags.length>1)
template.setVersion(tags[1].trim()); template.setVersion(tags[1].trim());
......
...@@ -43,6 +43,8 @@ public class Volume { ...@@ -43,6 +43,8 @@ public class Volume {
tag=DynamicParamUtils.process(tag); tag=DynamicParamUtils.process(tag);
Volume volume=new Volume(); Volume volume=new Volume();
String tags[]=tag.split(":"); String tags[]=tag.split(":");
if(tags.length==0)
return null;
volume.setSource(tags[0].trim()); volume.setSource(tags[0].trim());
if(tags.length>1) if(tags.length>1)
volume.setTarget(tags[1].trim()); volume.setTarget(tags[1].trim());
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册