dockerbuild.sh 2.6 KB
Newer Older
1
#!/bin/bash
2 3
#

4 5 6 7 8 9 10
set -e
#set -x

# dockerbuild.sh 
#             -c [aarch32 | aarch64 | amd64 | x86 | mips64 ...]  
#             -n [version number]
#             -p [password for docker hub]
11 12
#             -V [stable | beta]
#             -f [pkg file]
13 14

# set parameters by default value
15 16
cpuType=""
version=""
17 18
passWord=""
pkgFile=""
19
verType="stable"
20

21
while getopts "hc:n:p:f:V:" arg
22 23 24 25 26 27 28
do
  case $arg in
    c)
      #echo "cpuType=$OPTARG"
      cpuType=$(echo $OPTARG)
      ;;
    n)
29 30
      #echo "version=$OPTARG"
      version=$(echo $OPTARG)
31 32 33 34 35 36 37 38 39
      ;;
    p)
      #echo "passWord=$OPTARG"
      passWord=$(echo $OPTARG)
      ;;
    f)
      #echo "pkgFile=$OPTARG"
      pkgFile=$(echo $OPTARG)
      ;;
40 41 42 43
    V)
      #echo "verType=$OPTARG"
      verType=$(echo $OPTARG)
      ;;
44
    h)
45
      echo "Usage: `basename $0`  -c [aarch32 | aarch64 | amd64 | x86 | mips64 ...] "
46 47
      echo "                      -n [version number] "
      echo "                      -p [password for docker hub] "
48 49 50
      echo "                      -V [stable | beta] "
      echo "                      -f [pkg file] "

51 52 53 54 55 56 57 58 59
      exit 0
      ;;
    ?) #unknow option 
      echo "unkonw argument"
      exit 1
      ;;
  esac
done

60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78
# if [ "$verType" == "beta" ]; then
#   pkgFile=TDengine-server-${version}-Linux-${cpuType}-${verType}.tar.gz
# elif [ "$verType" == "stable" ]; then
#   pkgFile=TDengine-server-${version}-Linux-${cpuType}.tar.gz
# else
#   echo "unknow verType, nor stabel or beta"
#   exit 1

if [ "$verType" == "beta" ]; then
  dockername=${cpuType}-${verType}
elif [ "$verType" == "stable" ]; then
  dockername=${cpuType}
else
  echo "unknow verType, nor stabel or beta"
  exit 1
fi


echo "cpuType=${cpuType} version=${version} pkgFile=${pkgFile} verType=${verType} "
79 80 81
echo "$(pwd)"
echo "====NOTES: ${pkgFile} must be in the same directory as dockerbuild.sh===="

82 83 84 85 86
scriptDir=$(dirname $(readlink -f $0))
comunityArchiveDir=/nas/TDengine/v$version/community   # community version’package directory
cd ${scriptDir}
cp -f ${comunityArchiveDir}/${pkgFile}  .

87
dirName=${pkgFile%-Linux*}
88
echo "dirName=${dirName}"
89

90

91
docker build --rm -f "Dockerfile"  --network=host -t tdengine/tdengine-${dockername}:${version} "." --build-arg pkgFile=${pkgFile} --build-arg dirName=${dirName}
92
docker login -u tdengine -p ${passWord}  #replace the docker registry username and password
93
docker push tdengine/tdengine-${dockername}:${version}
94 95

# set this version to latest version
96 97 98 99 100
docker tag tdengine/tdengine-${dockername}:${version} tdengine/tdengine-${dockername}:latest
docker push tdengine/tdengine-${dockername}:latest


rm -f ${pkgFile}