add docker scripts

This commit is contained in:
CaiHQ 2021-12-03 09:16:35 +08:00
parent 6dd0c9283f
commit 6f541469a1
6 changed files with 86 additions and 4 deletions

View File

@ -2,10 +2,8 @@ plugins {
id 'java'
id 'idea'
}
def currVersion = "1.5.0"
def currVersion = "1.6.0"
ext.projectIds = ['group': 'com.bdware.sc', 'version': currVersion]
//group 'com.bdware.sc'
//version '1.4.4-SNAPSHOT'
sourceCompatibility = 1.8
project(':genparser') {

15
docker/AgentDockerfile Normal file
View File

@ -0,0 +1,15 @@
FROM openjdk:8
ARG GOPRIVATE=bdware.org/*
ARG GOPROXY=https://goproxy.cn
LABEL maintainer="caihuaqian@internetapi.cn"
LABEL org.bdware.version="1.6.0"
LABEL org.bdware.version.isproduction="true"
LABEL org.bdware.release-date="2021-12-02"
COPY ./output /bdcontract
WORKDIR /bdcontract
VOLUME /bdcontract/ContractManagerDB /bdcontract/rocksdb /bdcontract/ContractDB /bdcontract/BDWareProjectDir
ENTRYPOINT ["java"]
CMD ["-Dfile.encoding=UTF-8", "-Djava.library.path='./dynamicLibrary'", "-cp", "./libs/*:bdagent.jar", "org.bdware.server.CMHttpServer"]

28
docker/buildAgentDocker.sh Executable file
View File

@ -0,0 +1,28 @@
#!/bin/bash
if [ $# -lt 1 ]; then
echo "missing arguments,\nusage: \$version [-,push,save] \$saveDir"
exit 1
fi
cp ./docker/AgentDockerfile ./agent-backend/build/output/Dockerfile
cd ./agent-backend/build
DOCKER_CLI_EXPERIMENTAL=enabled
if [ "$2" == "push" ]; then
echo "push to docker hub"
rm -rf ./output/BDWareProjectDir/public/TF*
docker buildx build --platform linux/arm64/v8,linux/amd64 -t bdware/bdcontract:$1 ./ --push
elif [ "$2" == "save" ]; then
echo "save to $3"
rm -rf ./output/BDWareProjectDir/public/TFMac
rm -rf ./output/WebContent/bdcontract4baas
docker buildx build --platform linux/arm64/v8 -t bdware/bdcontract:$1 ./ --load
docker save -o $3/bdcontract-$1.tar bdware/bdcontract:$1
else
echo "create at local"
# docker build -t bdware/bdcontract-tf:$1 ./
# docker tag bdware/bdcontract-tf:$1 bdware/bdcontract-tf:latest
rm -rf ./output/BDWareProjectDir/public/TFMac
rm -rf ./output/WebContent/bdcontract4baas
docker build -t bdware/bdcontract:$1 ./
docker tag bdware/bdcontract:$1 bdware/bdcontract:latest
fi

22
docker/buildClusterDocker.sh Executable file
View File

@ -0,0 +1,22 @@
#!/bin/bash
DOCKER_CLI_EXPERIMENTAL=enabled
cp ./docker/ClusterDockerfile ./router-backend/build/Dockerfile
cd ./router-backend/build
if [ $# -lt 1 ]; then
echo "missing arguments,\nusage: \$version [-,push,save] \$saveDir"
exit 1
fi
#linux/arm64/v8,
if [ "$2" == "push" ]; then
docker buildx build --platform linux/amd64 -t bdware/bdcluster:$1 ./ --push
elif [ "$2" == "save" ]; then
docker buildx build --platform linux/amd64 -t bdware/bdcluster:$1 ./ --load
docker save -o $3/bdcluster-$1.tar bdware/bdcluster:$1
else
# docker buildx build --platform linux/arm64/v8 -t bdware/bdcluster:$1 ./ --load
docker build -t bdware/bdcluster:$1 ./
docker tag bdware/bdcluster:$1 bdware/bdcluster:latest
fi

19
docker/prepareVersion.sh Executable file
View File

@ -0,0 +1,19 @@
#!/bin/bash
version=$(awk '/currVersion = / { sub(/[^"]*"/,"") ; sub(/".*$/,""); print $0 } ' build.gradle)
echo version extract from build.gradle '-->' $version
if [ $# -gt 0 ]; then
time=$1
else
time=$(date "+%Y-%m-%d")
fi
echo time is $time
cd ./docker/
awk ' {gsub(/version=\".*\"/,"version=\"'$version'\""); print $0; } ' AgentDockerfile >AgentDockerfile.2
awk ' {gsub(/release-date=\".*\"/,"release-date=\"'$time'\""); print $0; } ' AgentDockerfile.2 >AgentDockerfile
rm AgentDockerfile.2
awk ' {gsub(/version=\".*\"/,"version=\"'$version'\""); print $0; } ' ClusterDockerfile >ClusterDockerfile.2
awk ' {gsub(/release-date=\".*\"/,"release-date=\"'$time'\""); print $0; } ' ClusterDockerfile.2 >ClusterDockerfile
rm ClusterDockerfile.2

@ -1 +1 @@
Subproject commit 242cd6d3145f181e208837b1922c1d0df1affa7e
Subproject commit c8cf9cca586da1b2df260cc2eb6a7ad3441eb7f5