diff --git a/script/docker/server/Dockerfile b/script/docker/server/Dockerfile index b0f8b1c20be..7c7eba9c56d 100644 --- a/script/docker/server/Dockerfile +++ b/script/docker/server/Dockerfile @@ -1,12 +1,15 @@ FROM openjdk:11.0.16-jre-slim-buster +# add args version +ARG VERSION + MAINTAINER tancloud "tomsun28@outlook.com" # Install SSH RUN apt-get update && apt-get install -y openssh-server RUN mkdir /var/run/sshd -ADD hertzbeat-1.3.2.tar /opt/ +ADD hertzbeat-${VERSION}.tar /opt/ ENV TZ=Asia/Shanghai #ENV LANG=zh_CN.UTF-8 diff --git a/script/docker/server/build.sh b/script/docker/server/build.sh index c4b3d40df28..e57fc4957a4 100755 --- a/script/docker/server/build.sh +++ b/script/docker/server/build.sh @@ -15,22 +15,23 @@ # 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. - -VERSION="$1" - -if [ ! -n "$VERSION" ]; then - echo "MUST INPUT THE BUILD VERSION" - exit 1 -fi - +# 调整脚本目录 cd `dirname $0` # 当前脚本目录 CURRENT_DIR=`pwd` - +# 跳转制品目录 cd ../../../manager/target +# 自动捕获hertzbeat版本 +VERSION=`ls *.tar| awk -F"-" '{print $2}' | awk -F".tar" '{print $1}'` +# 强制使用版本参数 +if [ -n "$1" ]; then + VERSION="$1"; +fi + # 编译上下文目录 CONTEXT_DIR=`pwd` -echo "docker build -t tancloud/hertzbeat:$VERSION -f $CURRENT_DIR/Dockerfile $CONTEXT_DIR" +echo "docker build -t tancloud/hertzbeat:$VERSION -f $CURRENT_DIR/Dockerfile $CONTEXT_DIR --build-arg VERSION="$VERSION"" -docker build -t tancloud/hertzbeat:"$VERSION" -f $CURRENT_DIR/Dockerfile $CONTEXT_DIR +docker build -t tancloud/hertzbeat:"$VERSION" -f $CURRENT_DIR/Dockerfile $CONTEXT_DIR --build-arg VERSION="$VERSION" +#docker build -t tancloud/hertzbeat:latest -f $CURRENT_DIR/Dockerfile $CONTEXT_DIR --build-arg VERSION="$VERSION"