-
Notifications
You must be signed in to change notification settings - Fork 59
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #388 from WeBankFinTech/dev
v1.5.3 dev=>master
- Loading branch information
Showing
220 changed files
with
2,151 additions
and
835 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
|
||
|
||
|
||
|
||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.