Skip to content

Commit

Permalink
Merge pull request #388 from WeBankFinTech/dev
Browse files Browse the repository at this point in the history
v1.5.3 dev=>master
  • Loading branch information
mingzhenliu authored Sep 28, 2021
2 parents 9eaf2e4 + fc984aa commit 820bf98
Show file tree
Hide file tree
Showing 220 changed files with 2,151 additions and 835 deletions.
89 changes: 89 additions & 0 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
name: Docker Build And Push To Docker Hub

on:
# test
# schedule:
# - cron: '0 10 * * *' # everyday at 10am
push:
tags:
- 'v*.*.*'
# pull_request:

env:
DOCKER_REPOSITORY: webase-node-mgr


jobs:
main:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- uses: actions/setup-java@v1
with:
java-version: 8
- uses: eskatos/gradle-command-action@v1
with:
arguments: clean build -x test

- name: Get branch name
uses: nelonoel/[email protected]

- name: Fetch tag
run: |
git fetch --tags --force
- name: Get git tag
uses: little-core-labs/[email protected]
id: tag_data
with:
tagRegex: (.*) # Optional. Returns specified group text as tag name. Full tag string is returned if regex is not defined.
tagRegexGroup: 1 # Optional. Default is 1.

- name: Set docker tag from tag
id: set_docker_tag
run: |
[[ ${{github.ref}} == */tags/* ]] && DOCKER_TAG="${GIT_TAG_NAME}" || DOCKER_TAG="${BRANCH_NAME}"
DOCKER_TAG="${{ secrets.DOCKER_WEBASEPRO_ORG }}/${DOCKER_REPOSITORY}:${DOCKER_TAG}"
echo "New docker tag is ${DOCKER_TAG}"
echo "::set-output name=docker_tag::$(echo ${DOCKER_TAG})"
- name: Set up QEMU
uses: docker/setup-qemu-action@v1

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1

- name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_WEBASEPRO_USERNAME }}
password: ${{ secrets.DOCKER_WEBASEPRO_TOKEN }}

# - name: Copy nginx config file
# id: copy-nginx-file
# run: |
# cp ./docker/weoracle-web.conf dist/

- name: Build and push
id: docker_build
uses: docker/build-push-action@v2
with:
context: ./dist
push: true
file: ./docker/build/Dockerfile
platforms: linux/amd64
tags: ${{ steps.set_docker_tag.outputs.docker_tag }}

- name: Image digest
run: echo ${{ steps.docker_build.outputs.digest }}


# - name: send custom message with args
# uses: appleboy/telegram-action@master
# with:
# to: ${{ secrets.TELEGRAM_TO }}
# token: ${{ secrets.TELEGRAM_TOKEN }}
# args: ${{ steps.set_docker_tag.outputs.docker_tag }} of ${{github.repository }} build success.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ dependencies {
compile "org.fisco-bcos.java-sdk:fisco-bcos-java-sdk:2.7.2"
compile "org.mybatis.spring.boot:mybatis-spring-boot-starter:2.1.0"
compile "org.apache.commons:commons-lang3:3.8.1"
compile 'org.apache.commons:commons-collections4:4.4'
compile "mysql:mysql-connector-java:8.0.22"
compile "com.zaxxer:HikariCP:3.2.0"
compile "com.github.sgroschupf:zkclient:0.1"
Expand All @@ -124,7 +125,6 @@ dependencies {
}
compile 'org.thymeleaf:thymeleaf:3.0.11.RELEASE'
compile 'ognl:ognl:3.2.14'
compile 'org.apache.commons:commons-collections4:4.4'

testCompile test,mbg

Expand Down
25 changes: 25 additions & 0 deletions docker/build/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#FROM openjdk:8-jdk-alpine as prod
FROM ubuntu:18.04 as prod

#RUN apk --no-cache add bash curl wget
RUN apt-get update \
&& apt-get -y install openjdk-8-jre \
&& apt-get -y install mysql-client \
&& rm -rf /var/lib/apt/lists/*

COPY script /dist/script
COPY gradle /dist/gradle
COPY lib /dist/lib
COPY conf_template /dist/conf
COPY apps /dist/apps

WORKDIR /dist
EXPOSE 5001

ENV CLASSPATH "/dist/conf/:/dist/apps/*:/dist/lib/*"

ENV JAVA_OPTS " -server -Dfile.encoding=UTF-8 -Xmx512m -Xms512m -Xmn256m -Xss512k -XX:MetaspaceSize=256m -XX:MaxMetaspaceSize=512m -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=/log/heap_error.log -XX:+UseG1GC -XX:MaxGCPauseMillis=200 "
ENV APP_MAIN "com.webank.webase.node.mgr.Application"

# start commond
ENTRYPOINT java ${JAVA_OPTS} -Djdk.tls.namedGroups="secp256k1", -Duser.timezone="Asia/Shanghai" -Djava.security.egd=file:/dev/./urandom, -Djava.library.path=/dist/conf -cp ${CLASSPATH} ${APP_MAIN}
116 changes: 116 additions & 0 deletions docker/build/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
#!/usr/bin/env bash

LOG_WARN() {
local content=${1}
echo -e "\033[31m[WARN] ${content}\033[0m"
}

LOG_INFO() {
local content=${1}
echo -e "\033[32m[INFO] ${content}\033[0m"
}

# 命令返回非 0 时,就退出
set -o errexit
# 管道命令中任何一个失败,就退出
set -o pipefail
# 遇到不存在的变量就会报错,并停止执行
set -o nounset
# 在执行每一个命令之前把经过变量展开之后的命令打印出来,调试时很有用
#set -o xtrace

# 退出时,执行的命令,做一些收尾工作
trap 'echo -e "Aborted, error $? in command: $BASH_COMMAND"; trap ERR; exit 1' ERR

# Set magic variables for current file & dir
# 脚本所在的目录
__dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
# 脚本的全路径,包含脚本文件名
__file="${__dir}/$(basename "${BASH_SOURCE[0]}")"
# 脚本的名称,不包含扩展名
__base="$(basename ${__file} .sh)"
# 脚本所在的目录的父目录,一般脚本都会在父项目中的子目录,
# 比如: bin, script 等,需要根据场景修改
__root="$(cd "$(dirname "${__dir}")" && pwd)"/../ # <-- change this as it depends on your app
__root=$(realpath -s "${__root}")


########################### properties config ##########################
image_organization=webasepro
image_name="webase-node-mgr"
docker_push="no"
latest_tag=latest
new_tag=


########################### parse param ##########################
__cmd="$(basename $0)"
# 解析参数
# usage help doc.
usage() {
cat << USAGE >&2
Usage:
${__cmd} [-h] [-t new_tag] [-p] [-i fiscoorg]
-t New tag for image, required.
-p Push image to docker hub, default no.
-i Default organization, default webasepro.
-h Show help info.
USAGE
exit 1
}
while getopts t:i:ph OPT;do
case $OPT in
t)
new_tag=$OPTARG
;;
p)
docker_push=yes
;;
i)
image_organization=${OPTARG}
;;
h)
usage
exit 3
;;
\?)
usage
exit 4
;;
esac
done


# 必须设置新镜像的版本
if [[ "${new_tag}"x == "x" ]] ; then
LOG_WARN "Need a new_tag for new docker image!! "
usage
exit 1
fi

########################### build docker image ##########################
image_repository="${image_organization}/${image_name}"

## compile project
cd "${__root}" && chmod +x ./gradlew && ./gradlew clean build -x test

## docker build
cd "${__root}"/dist

docker build -t ${image_repository}:${new_tag} -f "${__root}"/docker/build/Dockerfile .
docker tag "${image_repository}:${new_tag}" "${image_repository}:${latest_tag}"


########################### push docker image ##########################
if [[ "${docker_push}"x == "yesx" ]] ; then
docker push "${image_repository}:${new_tag}"
docker push "${image_repository}:${latest_tag}"
fi







1 change: 1 addition & 0 deletions script/upgrade/v150_v151.sql
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
SET NAMES utf8mb4;
SET FOREIGN_KEY_CHECKS = 0;

CREATE TABLE IF NOT EXISTS tb_warehouse (
id int(11) NOT NULL COMMENT '自增编号',
warehouse_name varchar(255) binary NOT NULL COMMENT '合约仓库名',
Expand Down
5 changes: 5 additions & 0 deletions script/upgrade/v151_v152.sql
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
SET NAMES utf8mb4;
SET FOREIGN_KEY_CHECKS = 0;

-- warehouse asset
INSERT INTO `tb_warehouse` (`id`, `warehouse_name`, `warehouse_name_en`, `type`, `warehouse_icon`, `description`, `description_en`, `warehouse_detail`, `warehouse_detail_en`, `create_time`, `modify_time`) VALUES
(5, '资产应用', 'Asset', 4, 'pointsId', '一套非同质化资产合约,具有于唯一性资产类型,如房产、汽车、道具、版权等', 'Asset Contract suite', '一套非同质化资产合约,具有于唯一性资产类型,如房产、汽车、道具、版权等', 'Asset Contract suite', now(), now());
Expand Down Expand Up @@ -30,3 +33,5 @@ INSERT INTO `tb_contract_item` (`id`, `warehouse_id`, `contract_folder_id`, `con
INSERT INTO `tb_contract_item` (`id`, `warehouse_id`, `contract_folder_id`, `contract_name`, `contract_source`, `description`, `description_en`, `create_time`, `modify_time`) VALUES
(30, 1, 1, 'Counters', 'cHJhZ21hIHNvbGlkaXR5IF4wLjQuMjU7CmltcG9ydCAiLi9TYWZlTWF0aC5zb2wiOwoKCmxpYnJhcnkgQ291bnRlcnMgewogICAgdXNpbmcgU2FmZU1hdGggZm9yIHVpbnQyNTY7CgogICAgc3RydWN0IENvdW50ZXIgewogICAgICAgIC8vIFRoaXMgdmFyaWFibGUgc2hvdWxkIG5ldmVyIGJlIGRpcmVjdGx5IGFjY2Vzc2VkIGJ5IHVzZXJzIG9mIHRoZSBsaWJyYXJ5OiBpbnRlcmFjdGlvbnMgbXVzdCBiZSByZXN0cmljdGVkIHRvCiAgICAgICAgLy8gdGhlIGxpYnJhcnkncyBmdW5jdGlvbi4gQXMgb2YgU29saWRpdHkgdjAuNS4yLCB0aGlzIGNhbm5vdCBiZSBlbmZvcmNlZCwgdGhvdWdoIHRoZXJlIGlzIGEgcHJvcG9zYWwgdG8gYWRkCiAgICAgICAgdWludDI1NiBfdmFsdWU7IC8vIGRlZmF1bHQ6IDAKICAgIH0KCiAgICBmdW5jdGlvbiBjdXJyZW50KENvdW50ZXIgc3RvcmFnZSBjb3VudGVyKSBpbnRlcm5hbCB2aWV3IHJldHVybnMgKHVpbnQyNTYpIHsKICAgICAgICByZXR1cm4gY291bnRlci5fdmFsdWU7CiAgICB9CgogICAgZnVuY3Rpb24gaW5jcmVtZW50KENvdW50ZXIgc3RvcmFnZSBjb3VudGVyKSBpbnRlcm5hbCB7CiAgICAgICAgY291bnRlci5fdmFsdWUgKz0gMTsKICAgIH0KCiAgICBmdW5jdGlvbiBkZWNyZW1lbnQoQ291bnRlciBzdG9yYWdlIGNvdW50ZXIpIGludGVybmFsIHsKICAgICAgICBjb3VudGVyLl92YWx1ZSA9IGN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yB0aGlzIHdvcmtzLgogICAgICAgIC8vIFRPRE8gQ2hlY2sgdGhpcyBhZ2FpbiBiZWZvcmUgdGhlIFNlcmVuaXR5IHJlbGVhc2UsIGJlY2F1c2UgYWxsIGFkZHJlc3NlcyB3aWxsIGJlCiAgICAgICAgLy8gY29udHJhY3RzIHRoZW4uCiAgICAgICAgLy8gc29saGludC1kaXNhYmxlLW5leHQtbGluZSBuby1pbmxpbmUtYXNzZW1ibHkKICAgICAgICBhc3NlbWJseSB7IHNpemUgOj0gZXh0Y29kZXNpemUoYWNjb3VudCkgfQogICAgICAgIHJldHVybiBzaXplID4gMDsKICAgIH0KfQ==',
'IyBDb3VudGVycwoKQ291bnRlcnMgdG9vbCBjb250cmFjdAo=', 'IyBDb3VudGVycwoKQ291bnRlcnMgdG9vbCBjb250cmFjdAo=', now(), now());

SET FOREIGN_KEY_CHECKS = 1;
Loading

0 comments on commit 820bf98

Please sign in to comment.