mongo.sh 696 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. #!/bin/bash
  2. cd $(dirname $0)
  3. # source functions
  4. source ../../../common/echo.sh
  5. console_tip "mongo test"
  6. # build goctl
  7. console_step "goctl building"
  8. buildFile=goctl
  9. CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o $buildFile ../../../../goctl.go
  10. image=goctl-mongo:latest
  11. # docker build
  12. console_step "docker building"
  13. docker build -t $image .
  14. if [ $? -ne 0 ]; then
  15. rm -f $buildFile
  16. console_red "docker build failed"
  17. exit 1
  18. fi
  19. # run docker image
  20. console_step "docker running"
  21. docker run $image
  22. if [ $? -ne 0 ]; then
  23. rm -f $buildFile
  24. console_red "docker run failed"
  25. docker image rm -f $image
  26. exit 1
  27. fi
  28. rm -f $buildFile
  29. console_green "PASS"
  30. docker image rm -f $image > /dev/null 2>&1