build.sh 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. #!/bin/bash
  2. #
  3. # This script is executed from within the container.
  4. #
  5. set -e
  6. EXTRA_OPTS="$@"
  7. CCARMV7=arm-linux-gnueabihf-gcc
  8. CCARM64=aarch64-linux-gnu-gcc
  9. CCX64=/tmp/x86_64-centos6-linux-gnu/bin/x86_64-centos6-linux-gnu-gcc
  10. GOPATH=/go
  11. REPO_PATH=$GOPATH/src/github.com/grafana/grafana
  12. cd /go/src/github.com/grafana/grafana
  13. echo "current dir: $(pwd)"
  14. if [ "$CIRCLE_TAG" != "" ]; then
  15. echo "Building releases from tag $CIRCLE_TAG"
  16. OPT="-includeBuildId=false ${EXTRA_OPTS}"
  17. else
  18. echo "Building incremental build for $CIRCLE_BRANCH"
  19. OPT="-buildId=${CIRCLE_WORKFLOW_ID} ${EXTRA_OPTS}"
  20. fi
  21. echo "Build arguments: $OPT"
  22. go run build.go -goarch armv7 -cc ${CCARMV7} ${OPT} build
  23. go run build.go -goarch arm64 -cc ${CCARM64} ${OPT} build
  24. CC=${CCX64} go run build.go ${OPT} build
  25. yarn install --pure-lockfile --no-progress
  26. echo "current dir: $(pwd)"
  27. if [ -d "dist" ]; then
  28. rm -rf dist
  29. fi
  30. echo "Building frontend"
  31. go run build.go ${OPT} build-frontend
  32. # Load ruby, needed for packing with fpm
  33. source /etc/profile.d/rvm.sh
  34. echo "Packaging"
  35. go run build.go -goos linux -pkg-arch amd64 ${OPT} package-only
  36. go run build.go -goos linux -pkg-arch armv7 ${OPT} package-only
  37. go run build.go -goos linux -pkg-arch arm64 ${OPT} package-only
  38. go run build.go latest