Skip to content

Commit

Permalink
[script] dockerfile: detect app version and auto generator docker tag (
Browse files Browse the repository at this point in the history
…#1162)

Co-authored-by: yaoxf <yaoxf@unitay.com.cn>
  • Loading branch information
XimfengYao and yaoxf authored Aug 8, 2023
1 parent 7c72f23 commit 9a20e69
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 12 deletions.
5 changes: 4 additions & 1 deletion script/docker/server/Dockerfile
Original file line number Diff line number Diff line change
@@ -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
Expand Down
23 changes: 12 additions & 11 deletions script/docker/server/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"

0 comments on commit 9a20e69

Please sign in to comment.