Build script improvements

Small improvements to the build script:
- Refactor the local build to improve clarity of build output
- Improve error handling
- Detect the geard source path within GOPATH
- Portability fixes
- Fix Docker build