Skip to content

Commit

Permalink
Merge pull request WeBankBlockchain#636 from CodingCattwo/dev152
Browse files Browse the repository at this point in the history
v1.5.3
  • Loading branch information
mingzhenliu authored Aug 31, 2021
2 parents 77a05e2 + b267152 commit 60c6637
Show file tree
Hide file tree
Showing 26 changed files with 837 additions and 268 deletions.
22 changes: 11 additions & 11 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
name: Docker Build And Push To Docker Hub

on:
# schedule:
# - cron: '0 10 * * *' # everyday at 10am
schedule:
- cron: '0 10 * * *' # everyday at 10am
push:
tags:
- 'v*.*.*'
Expand Down Expand Up @@ -43,7 +43,7 @@ jobs:
id: set_docker_tag
run: |
[[ ${{github.ref}} == */tags/* ]] && DOCKER_TAG="${GIT_TAG_NAME}" || DOCKER_TAG="${BRANCH_NAME}"
DOCKER_TAG="${{ secrets.DOCKERHUB_ORG }}/${DOCKER_REPOSITORY}:${DOCKER_TAG}"
DOCKER_TAG="${{ secrets.DOCKER_WEBASEPRO_ORG }}/${DOCKER_REPOSITORY}:${DOCKER_TAG}"
echo "New docker tag is ${DOCKER_TAG}"
Expand All @@ -58,8 +58,8 @@ jobs:
- name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
username: ${{ secrets.DOCKER_WEBASEPRO_USERNAME }}
password: ${{ secrets.DOCKER_WEBASEPRO_TOKEN }}

# - name: Copy nginx config file
# id: copy-nginx-file
Expand All @@ -80,9 +80,9 @@ jobs:
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.
# - 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.
10 changes: 5 additions & 5 deletions docker/build/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
#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 \
&& rm -rf /var/lib/apt/lists/*

#COPY --from=builder /code/dist/lib /dist/lib
#COPY --from=builder /code/dist/conf_template /dist/conf
#COPY --from=builder /code/dist/apps /dist/apps
COPY gradle /dist/gradle
COPY static /dist/static
COPY lib /dist/lib
COPY conf_template /dist/conf
COPY apps /dist/apps

# run with 'sdk' volume
RUN mkdir -p /dist/sdk

WORKDIR /dist
EXPOSE 5002

Expand All @@ -23,4 +23,4 @@ ENV JAVA_OPTS " -server -Dfile.encoding=UTF-8 -Xmx512m -Xms512m -Xmn256m -Xss512
ENV APP_MAIN "com.webank.webase.front.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}
ENTRYPOINT cp -r /dist/sdk/* /dist/conf/ && 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-front"
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







Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,11 @@ public class ConstantCode {
public static final RetCode GET_EVENT_CALLBACK_TIMEOUT_ERROR = RetCode.mark(201311, "get event callback fail for time out");
public static final RetCode GET_EVENT_CALLBACK_ERROR = RetCode.mark(201312, "get event callback error");

// v1.5.3
public static final RetCode CNS_QUERY_FAIL = RetCode.mark(201321,"query cns info fail");



/* classify common error of web3j*/
// keystore
public static final RetCode WEB3J_CREATE_KEY_PAIR_NULL = RetCode.mark(201501, "web3sdk create key pair fail and return null");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import lombok.Data;
import lombok.extern.slf4j.Slf4j;
import org.fisco.bcos.sdk.BcosSDK;
import org.fisco.bcos.sdk.abi.ABICodec;
import org.fisco.bcos.sdk.client.Client;
import org.fisco.bcos.sdk.config.ConfigOption;
import org.fisco.bcos.sdk.config.exceptions.ConfigException;
Expand All @@ -35,6 +36,7 @@
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.DependsOn;

/**
* init web3sdk getService.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,7 @@ private void writeSdkFilesAndZip(Map<String, String> sdkContentMap) {
//├── sdk.crt
//└── sdk.key
try {
ZipUtils.generateZipFile(TEMP_SDK_DIR, TEMP_ZIP_DIR, "", TEMP_ZIP_FILE_NAME);
ZipUtils.generateZipFile(TEMP_SDK_DIR, TEMP_ZIP_DIR, TEMP_SDK_DIR, TEMP_ZIP_FILE_NAME);
} catch (Exception e) {
log.error("writeSdkAsFile generateZipFile fail:[]", e);
throw new FrontException(ConstantCode.WRITE_SDK_CRT_KEY_FILE_FAIL);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ public ResponseEntity sendAbi(@Valid @RequestBody ReqSendAbi reqSendAbi, Binding
* save contract.
*/
@ApiOperation(value = "save contract", notes = "save contract ")
@ApiImplicitParam(name = "req", value = "contract info", required = true,
@ApiImplicitParam(name = "contract", value = "contract info", required = true,
dataType = "ReqContractSave")
@PostMapping(value = "/save")
public Contract saveContract(@RequestBody @Valid ReqContractSave contract, BindingResult result)
Expand Down Expand Up @@ -305,6 +305,12 @@ public List<ContractPath> findPathList(@PathVariable("groupId") Integer groupId)
return contractService.findPathList(groupId);
}

/**
* only delete path, not delete contract
* @param groupId
* @param contractPath
* @return
*/
@DeleteMapping("/deletePath/{groupId}/{contractPath}")
public BaseResponse deletePath(@PathVariable("groupId") Integer groupId,
@PathVariable String contractPath) {
Expand All @@ -313,6 +319,12 @@ public BaseResponse deletePath(@PathVariable("groupId") Integer groupId,
return new BaseResponse(ConstantCode.RET_SUCCEED);
}

/**
* delete path and contracts in it
* @param groupId
* @param contractPath
* @return
*/
@DeleteMapping("/batch/{groupId}/{contractPath}")
public BaseResponse batchDeletePath(@PathVariable("groupId") Integer groupId,
@PathVariable String contractPath) {
Expand Down
Loading

0 comments on commit 60c6637

Please sign in to comment.