gitlab.com/evatix-go/core@v1.3.55/scripts/docker-deploy.sh (about)

     1  #!/bin/bash
     2  
     3  WorkDir="$PWD/.."
     4  BinDir=$WorkDir/bin
     5  Platforms="darwin linux windows"
     6  Architectures="386 amd64"
     7  
     8  echo $Platforms
     9  echo $Architectures
    10  
    11  echo ""
    12  echo " ---- [Start] deploy for platforms ($Platforms [$Architectures]) [Start]-----"
    13  echo ""
    14  echo "Work dir     : $WorkDir"
    15  echo "Binaries dir : $BinDir"
    16  
    17  docker run --rm -it -v "$WorkDir":/usr/src/myapp -v "$GOPATH":/go -w /usr/src/myapp golang:1.17.8 bash -c '
    18  rm -rf bin && \
    19  mkdir bin && \
    20  cp -R assets bin && \
    21  cp -R configs bin && \
    22  for CliName in main; do
    23    for GOOS in darwin linux windows; do
    24      for GOARCH in 386 amd64; do
    25  
    26      export GOOS=$GOOS
    27      export GOARCH=$GOARCH
    28  
    29      if [ $GOOS == "windows" ]
    30      then
    31         echo "Building $GOOS-$GOARCH.exe"
    32         go build -o bin/cli-$GOOS-$GOARCH.exe cmd/$CliName/*.go
    33      else
    34         echo "Building $GOOS-$GOARCH"
    35        go build -o bin/cli-$GOOS-$GOARCH cmd/$CliName/*.go
    36      fi
    37      done
    38    done
    39  done' &&
    40    echo "Build complete" &&
    41    echo "" &&
    42    echo "Permission adding:" &&
    43    echo "chown -R root:root $BinDir" &&
    44    echo "chmod -R 777 $BinDir" &&
    45    echo "" &&
    46    chown -R root:root "$BinDir" &&
    47    chmod -R 777 "$BinDir" &&
    48    echo "" &&
    49    echo "ls -la $BinDir:" &&
    50    ls -la "$BinDir" &&
    51    echo "" &&
    52    echo "EnvPath" &&
    53    export PATH=$PATH:"$BinDir" &&
    54    echo "" &&
    55    echo $PATH &&
    56    echo "" &&
    57    echo "$\"Path\":" &&
    58    echo "export PATH=\$PATH:\"$BinDir\"" &&
    59    echo "running : ${BinDir}/cli-linux-amd64" &&
    60    "$BinDir"/cli-linux-amd64 &&
    61    echo "" &&
    62    echo " ---- [End] deploy for all platforms ($Platforms [$Architectures]) [end]-----" &&
    63    echo ""