server_build.sh 770 B

12345678910111213141516171819202122232425
  1. #!/usr/bin/env bash
  2. registry_host="ccr.ccs.tencentyun.com/wanpinghui"
  3. project_name="go-example-server"
  4. exec_name="go-example"
  5. rm -rf ./bin
  6. mkdir -p ./bin
  7. GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -ldflags "-s" -v -o ./bin/$exec_name ../server/load_balancing1.go
  8. for item in $(docker images | grep -E "$registry_host/$project_name\s+\S*" -o);
  9. do
  10. if [[ $item != "$registry_host/$project_name" ]];
  11. then
  12. echo "remove $registry_host/$project_name:$item"
  13. docker rmi "$registry_host/$project_name:$item"
  14. fi
  15. done
  16. tag=$(date +%s)
  17. docker login -u=100010573203 ccr.ccs.tencentyun.com -p=wanpinghui151217
  18. docker build --no-cache --disable-content-trust=true -t $registry_host/$project_name:$tag .
  19. docker push $registry_host/$project_name:$tag