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

docker

上级 202fd912
FROM maven:3.8.3-adoptopenjdk-8
ENV TZ=Asia/Shanghai \
JAVA_OPTS=""
WORKDIR /
ADD settings.xml /root/.m2/settings.xml
ADD pom.xml /pom.xml
RUN mvn package && mvn ibizlabcli:help && git config --global user.name "ibizlabcli" && git config --global user.email "ibizlabcli@ibizsys.net"
ADD ibizlabcli /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 .
\ No newline at end of file
version: "3.2"
services:
maven:
#image: maven:3.8.3-adoptopenjdk-8
image: ibiz4j/ibizlab-cli:latest
environment:
- CODEGEN_CODE_URL=http://demo.ibizlab.cn/t48e9d7d8e2dab3018133378ca1d8a4b6/xftong #源git库repo,同义参数GIT_PROD_REPO
- CODEGEN_CODE_PASSWORD=pppppp #源git库oauth2令牌,同义参数GIT_PROD_REPO
- CODEGEN_CODE_BRANCH=master #源git库分支,同义参数GIT_PROD_BRANCH,不设置默认取master
- CODEGEN_RO_URL=http://oauth2:xxxx@demo.ibizlab.cn/t48e9d7d8e2dab3018133378ca1d8a4b6/xftongdev #目标git库repo,同义参数GIT_DEV_REPO
- CODEGEN_RO_BRANCH=master #目标git库分支,同义参数GIT_DEV_BRANCH,不设置默认取master
- CODEGEN_CODE_USER=ibiz4j #git提交用户,同义参数GIT_DEV_USER_NAME
- CODEGEN_RO_USER=ibiz4j #git提交用户,同义参数GIT_DEV_USER_NAME
# - GIT_PROD_REPO=http://oauth2:xxxx@demo.ibizlab.cn/t48e9d7d8e2dab3018133378ca1d8a4b6/xftong
# - GIT_PROD_BRANCH=master
# - GIT_DEV_REPO=http://oauth2:xxxx@demo.ibizlab.cn/t48e9d7d8e2dab3018133378ca1d8a4b6/xftongdev
# - GIT_DEV_BRANCH=maste
# - GIT_DEV_USER_NAME=ibizlabcli
# - GIT_DEV_USER_EMAIL=ibizlabcli@ibizsys.net
# - GIT_PUSH_MESSAGE=cli
# - CLI_UPDATE=true
#!/bin/bash
if [ $CLI_UPDATE ];then
if [ "TRUE" == `echo $CLI_UPDATE` ];then
mvn package
fi
if [ "true" == `echo $CLI_UPDATE` ];then
mvn package
fi
if [ "True" == `echo $CLI_UPDATE` ];then
mvn package
fi
fi
if [ ! $GIT_PROD_REPO ];then
if [ ! $CODEGEN_CODE_URL ];then
echo "unknow prod git, env GIT_PROD_REPO or CODEGEN_CODE_URL does not exist."
exit 1
fi
if [ $CODEGEN_CODE_PASSWORD ];then
if [[ ! "${CODEGEN_CODE_URL}" =~ "@" ]];then
CODEGEN_CODE_URL=${CODEGEN_CODE_URL/#"http://"/"http://oauth2:${CODEGEN_CODE_PASSWORD}@"}
else
CODEGEN_CODE_URL=${CODEGEN_CODE_URL#*@}
CODEGEN_CODE_URL="http://oauth2:${CODEGEN_CODE_PASSWORD}@"$CODEGEN_CODE_URL
fi
fi
GIT_PROD_REPO=$CODEGEN_CODE_URL
fi
if [ ! $GIT_PROD_BRANCH ];then
if [ ! $CODEGEN_CODE_BRANCH ];then
GIT_PROD_BRANCH=master
echo "env GIT_PROD_BRANCH or CODEGEN_CODE_BRANCH does not exist, using 'master'."
else
GIT_PROD_BRANCH=$CODEGEN_CODE_BRANCH
fi
fi
if [ ! $GIT_DEV_REPO ];then
if [ ! $CODEGEN_RO_URL ];then
echo "unknow dev git, env GIT_DEV_REPO or CODEGEN_RO_URL does not exist."
exit 1
fi
GIT_DEV_REPO=$CODEGEN_RO_URL
fi
if [ ! $GIT_DEV_BRANCH ];then
if [ ! $CODEGEN_RO_BRANCH ];then
GIT_DEV_BRANCH=master
echo "env GIT_DEV_BRANCH or CODEGEN_RO_BRANCH does not exist, using 'master'."
else
GIT_DEV_BRANCH=$CODEGEN_RO_BRANCH
fi
fi
mkdir -p /generator
cd /generator
rm -rf /generator/*
git clone -b $GIT_PROD_BRANCH --depth=1 $GIT_PROD_REPO prod
if [ ! $MODELFOLDER ];then
if [ ! $CODEGEN_MODEL_PATH ];then
if [ -f "prod/ibizmodel.yaml" ];then
MODELFOLDER=`sed '/^modelfolder: /!d;s/.*: //' prod/ibizmodel.yaml`
fi
else
MODELFOLDER=$CODEGEN_MODEL_PATH
fi
fi
if [ ! $MODELFOLDER ];then
echo "unknow model folder, env MODELFOLDER or CODEGEN_MODEL_PATH does not exist, ibizmodel.yaml not found."
exit 1
fi
echo spec dir: $MODELFOLDER
git clone -b $GIT_DEV_BRANCH $GIT_DEV_REPO dev
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
rm -rf dev/generator.xml
cd ../dev/
if [ ! $GIT_DEV_USER_NAME ];then
if [ $CODEGEN_RO_USER ];then
GIT_DEV_USER_NAME=$CODEGEN_RO_USER
else
if [ $CODEGEN_CODE_USER ];then
GIT_DEV_USER_NAME=$CODEGEN_CODE_USER
else
GIT_DEV_USER_NAME=ibizlabcli
echo "env GIT_DEV_USER_NAME or CODEGEN_RO_USER or CODEGEN_CODE_USER does not exist, using 'ibizlabcli'."
fi
fi
fi
git config user.name "$GIT_DEV_USER_NAME"
if [ ! $GIT_DEV_USER_EMAIL ];then
GIT_DEV_USER_EMAIL=$GIT_DEV_USER_NAME@ibizsys.net
fi
git config user.email "$GIT_DEV_USER_EMAIL"
set +e
git add .
git commit -m "generate by $GIT_DEV_USER_NAME. $GIT_PUSH_MESSAGE"
git push origin $GIT_DEV_BRANCH
set -e
exit 0
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>cn.ibizlab</groupId>
<artifactId>ibizlab-generator-docker</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<dependencies>
<dependency>
<groupId>cn.ibizlab</groupId>
<artifactId>ibizlab-generator-cli</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>cn.ibizlab</groupId>
<artifactId>ibizlab-generator-core</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>cn.ibizlab</groupId>
<artifactId>ibizlab-generator-plugin</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>cn.ibizlab</groupId>
<artifactId>ibizlab-template-ibizboot</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>cn.ibizlab</groupId>
<artifactId>ibizlab-template-ibizedge</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
</dependencies>
<distributionManagement>
<repository>
<id>ibizmvnrepository-plugin</id>
<url>http://172.16.240.220:8081/repository/releases</url>
</repository>
<snapshotRepository>
<id>ibizmvnrepository-plugin</id>
<url>http://172.16.240.220:8081/repository/snapshots</url>
</snapshotRepository>
</distributionManagement>
<repositories>
<repository>
<id>aliyunmaven</id>
<name>阿里云公共仓库</name>
<url>https://maven.aliyun.com/repository/public/</url>
<layout>default</layout>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
<updatePolicy>always</updatePolicy>
</snapshots>
</repository>
<repository>
<id>ibizmvnrepository</id>
<name>ibizmvnrepository</name>
<url>http://172.16.240.220:8081/repository/public/</url>
<layout>default</layout>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
<updatePolicy>always</updatePolicy>
</snapshots>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>ibizmvnrepository-plugin</id>
<url>http://172.16.240.220:8081/repository/public/</url>
<layout>default</layout>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
<updatePolicy>always</updatePolicy>
</snapshots>
</pluginRepository>
<pluginRepository>
<id>aliyun-plugin</id>
<url>https://maven.aliyun.com/repository/public</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
</pluginRepository>
</pluginRepositories>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>versions-maven-plugin</artifactId>
<configuration>
<generateBackupPoms>false</generateBackupPoms>
</configuration>
</plugin>
<plugin>
<groupId>cn.ibizlab</groupId>
<artifactId>ibizlab-generator-plugin</artifactId>
<version>1.0-SNAPSHOT</version>
<configuration>
<output>
/target
</output>
<inputSpec>
/target
</inputSpec>
<packageName>
${project.groupId}
</packageName>
<name>
${project.artifactId}
</name>
</configuration>
</plugin>
</plugins>
</build>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->
<!--
| This is the configuration file for Maven. It can be specified at two levels:
|
| 1. User Level. This settings.xml file provides configuration for a single user,
| and is normally provided in ${user.home}/.m2/settings.xml.
|
| NOTE: This location can be overridden with the CLI option:
|
| -s /path/to/user/settings.xml
|
| 2. Global Level. This settings.xml file provides configuration for all Maven
| users on a machine (assuming they're all using the same Maven
| installation). It's normally provided in
| ${maven.home}/conf/settings.xml.
|
| NOTE: This location can be overridden with the CLI option:
|
| -gs /path/to/global/settings.xml
|
| The sections in this sample file are intended to give you a running start at
| getting the most out of your Maven installation. Where appropriate, the default
| values (values used when the setting is not specified) are provided.
|
|-->
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
<!-- localRepository
| The path to the local repository maven will use to store artifacts.
|
| Default: ${user.home}/.m2/repository
<localRepository>/path/to/local/repo</localRepository>
-->
<!-- interactiveMode
| This will determine whether maven prompts you when it needs input. If set to false,
| maven will use a sensible default value, perhaps based on some other setting, for
| the parameter in question.
|
| Default: true
<interactiveMode>true</interactiveMode>
-->
<!-- offline
| Determines whether maven should attempt to connect to the network when executing a build.
| This will have an effect on artifact downloads, artifact deployment, and others.
|
| Default: false
<offline>false</offline>
-->
<!-- pluginGroups
| This is a list of additional group identifiers that will be searched when resolving plugins by their prefix, i.e.
| when invoking a command line like "mvn prefix:goal". Maven will automatically add the group identifiers
| "org.apache.maven.plugins" and "org.codehaus.mojo" if these are not already contained in the list.
|-->
<pluginGroups>
<!-- pluginGroup
| Specifies a further group identifier to use for plugin lookup.
<pluginGroup>com.your.plugins</pluginGroup>
-->
</pluginGroups>
<!-- proxies
| This is a list of proxies which can be used on this machine to connect to the network.
| Unless otherwise specified (by system property or command-line switch), the first proxy
| specification in this list marked as active will be used.
|-->
<proxies>
<!-- proxy
| Specification for one proxy, to be used in connecting to the network.
|
<proxy>
<id>optional</id>
<active>true</active>
<protocol>http</protocol>
<username>proxyuser</username>
<password>proxypass</password>
<host>proxy.host.net</host>
<port>80</port>
<nonProxyHosts>local.net|some.host.com</nonProxyHosts>
</proxy>
-->
</proxies>
<!-- servers
| This is a list of authentication profiles, keyed by the server-id used within the system.
| Authentication profiles can be used whenever maven must make a connection to a remote server.
|-->
<servers>
<!-- server
| Specifies the authentication information to use when connecting to a particular server, identified by
| a unique name within the system (referred to by the 'id' attribute below).
|
| NOTE: You should either specify username/password OR privateKey/passphrase, since these pairings are
| used together.
|
<server>
<id>deploymentRepo</id>
<username>repouser</username>
<password>repopwd</password>
</server>
-->
<!-- Another sample, using keys to authenticate.
<server>
<id>siteServer</id>
<privateKey>/path/to/private/key</privateKey>
<passphrase>optional; leave empty if not used.</passphrase>
</server>
-->
</servers>
<!-- mirrors
| This is a list of mirrors to be used in downloading artifacts from remote repositories.
|
| It works like this: a POM may declare a repository to use in resolving certain artifacts.
| However, this repository may have problems with heavy traffic at times, so people have mirrored
| it to several places.
|
| That repository definition will have a unique id, so we can create a mirror reference for that
| repository, to be used as an alternate download site. The mirror site will be the preferred
| server for that repository.
|-->
<mirrors>
<!-- mirror
| Specifies a repository mirror site to use instead of a given repository. The repository that
| this mirror serves has an ID that matches the mirrorOf element of this mirror. IDs are used
| for inheritance and direct lookup purposes, and must be unique across the set of mirrors.
|
<mirror>
<id>mirrorId</id>
<mirrorOf>repositoryId</mirrorOf>
<name>Human Readable Name for this Mirror.</name>
<url>http://my.repository.com/repo/path</url>
</mirror>
-->
<mirror>
<id>nexus-aliyun</id>
<mirrorOf>central</mirrorOf>
<name>Nexus aliyun</name>
<url>https://maven.aliyun.com/nexus/content/groups/public</url>
</mirror>
<mirror>
<id>ibizmvnrepository</id>
<mirrorOf>external:http:*</mirrorOf>
<url>http://172.16.240.220:8081/repository/public/</url>
</mirror>
</mirrors>
<!-- profiles
| This is a list of profiles which can be activated in a variety of ways, and which can modify
| the build process. Profiles provided in the settings.xml are intended to provide local machine-
| specific paths and repository locations which allow the build to work in the local environment.
|
| For example, if you have an integration testing plugin - like cactus - that needs to know where
| your Tomcat instance is installed, you can provide a variable here such that the variable is
| dereferenced during the build process to configure the cactus plugin.
|
| As noted above, profiles can be activated in a variety of ways. One way - the activeProfiles
| section of this document (settings.xml) - will be discussed later. Another way essentially
| relies on the detection of a system property, either matching a particular value for the property,
| or merely testing its existence. Profiles can also be activated by JDK version prefix, where a
| value of '1.4' might activate a profile when the build is executed on a JDK version of '1.4.2_07'.
| Finally, the list of active profiles can be specified directly from the command line.
|
| NOTE: For profiles defined in the settings.xml, you are restricted to specifying only artifact
| repositories, plugin repositories, and free-form properties to be used as configuration
| variables for plugins in the POM.
|
|-->
<profiles>
<!-- profile
| Specifies a set of introductions to the build process, to be activated using one or more of the
| mechanisms described above. For inheritance purposes, and to activate profiles via <activatedProfiles/>
| or the command line, profiles have to have an ID that is unique.
|
| An encouraged best practice for profile identification is to use a consistent naming convention
| for profiles, such as 'env-dev', 'env-test', 'env-production', 'user-jdcasey', 'user-brett', etc.
| This will make it more intuitive to understand what the set of introduced profiles is attempting
| to accomplish, particularly when you only have a list of profile id's for debug.
|
| This profile example uses the JDK version to trigger activation, and provides a JDK-specific repo.
<profile>
<id>jdk-1.4</id>
<activation>
<jdk>1.4</jdk>
</activation>
<repositories>
<repository>
<id>jdk14</id>
<name>Repository for JDK 1.4 builds</name>
<url>http://www.myhost.com/maven/jdk14</url>
<layout>default</layout>
<snapshotPolicy>always</snapshotPolicy>
</repository>
</repositories>
</profile>
-->
<!--
| Here is another profile, activated by the system property 'target-env' with a value of 'dev',
| which provides a specific path to the Tomcat instance. To use this, your plugin configuration
| might hypothetically look like:
|
| ...
| <plugin>
| <groupId>org.myco.myplugins</groupId>
| <artifactId>myplugin</artifactId>
|
| <configuration>
| <tomcatLocation>${tomcatPath}</tomcatLocation>
| </configuration>
| </plugin>
| ...
|
| NOTE: If you just wanted to inject this configuration whenever someone set 'target-env' to
| anything, you could just leave off the <value/> inside the activation-property.
|
<profile>
<id>env-dev</id>
<activation>
<property>
<name>target-env</name>
<value>dev</value>
</property>
</activation>
<properties>
<tomcatPath>/path/to/tomcat/instance</tomcatPath>
</properties>
</profile>
-->
</profiles>
<!-- activeProfiles
| List of profiles that are active for all builds.
|
<activeProfiles>
<activeProfile>alwaysActiveProfile</activeProfile>
<activeProfile>anotherAlwaysActiveProfile</activeProfile>
</activeProfiles>
-->
</settings>
#目标开发库git根目录中必须存在此 generator.yml 文件,用来指定选用模板等参数
#配置文件支持环境变量设置,参照${系统环境变量键值:默认值}格式
generator:
#模板和版本,支持多个模板组合
#目前后台模板有全代码版ibizlab-template-ibizedge和扩展cloud版ibizlab-template-ibizboot两种可选
embedTemplates:
- ${templateName:ibizlab-template-ibizedge}:${templateVersion:1.0-SNAPSHOT}
#文件夹订阅复制,源代码库路径文件夹或文件相对路径:开发代码库路径文件夹或文件相对路径
volumes:
- ${modelFolder}:${modelFolder} #模型文件夹复制,可以直接用modelFolder环境变量,通常模型文件夹是必须的
- app_web:app_web #本项目前端vue文件复制,注意路径,不拷贝请删除该行
- xxxxxx-core/src/main/resources/application-sys.yml:xxxxxx-core/src/main/resources/application-sys.yml #本项目配置文件复制,自行选择,注意路径,不拷贝请删除该行
- xxxxxx-core/src/main/resources/application-nacos.yml:xxxxxx-core/src/main/resources/application-nacos.yml #本项目配置文件复制,自行选择,注意路径,不拷贝请删除该行
- xxxxxx-boot/pom.xml:xxxxxx-boot/pom.xml #本项目配置文件复制,自行选择,注意路径,不拷贝请删除该行
\ No newline at end of file
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册