如何通过git push以私有存储库作为依赖项部署Azure Go Web应用程序?

问题描述:

What would be the proper way to deploy a Go app to Azure that have private GitHub repositories as dependencies? Here's the current error from Kudu:

Resolving dependencies
# cd .; git clone https://github.com/my/privaterepo
  D:\local\Temp\8d315fa89272e69\gopath\src\github.com\my\privaterepo
Cloning into 'D:\local\Temp\8d315fa89272e69\gopath\src\github.com\my\privaterepo'...
fatal: could not read Username for 'https://github.com': Bad file descriptor
package github.com/my/privaterepo/pkg1: exit status 128
package github.com/my/privaterepo/pkg2: cannot find package $GOROOT)

Building Go app to produce exe file
azureapp\file.go:8:2: cannot find package "github.com/my/privaterepo/pkg1" 
in any of:
    D:\Program Files\Go\1.5.1\src\github.com\my\privaterepo\pkg1 (from $GOROOT)

I was previously deploying via FTP with web.config's HttpPlatformHandler entry. But using git push is quicker especially for non-Windows team members.

Thanks

将具有私有GitHub存储库作为依赖项的Go应用程序部署到Azure的正确方法是什么? 这是来自Kudu的当前错误: p>

 解析依赖项
#cd。  git clone https://github.com/my/privaterepo
 D:\ local \ Temp \ 8d315fa89272e69 \ gopath \ src \ github.com \ my \ privaterepo 
克隆到'D:\ local \ Temp \ 8d315fa89272e69 \ gopath \  src \ github.com \ my \ privaterepo'... 
fatal:无法读取“ https://github.com”的用户名:错误的文件描述符
package github.com/my/privaterepo/pkg1:退出状态128 \  npackage github.com/my/privaterepo/pkg2:找不到软件包$ GOROOT)
 
正在构建Go应用以生成exe文件
azureapp \ file.go:8:2:找不到软件包“ github.com/my/privaterepo/  pkg1“ 
中的任何一个:
 D:\ Program Files \ Go \ 1.5.1 \ src \ github.com \ my \ privaterepo \ pkg1(来自$ GOROOT)
  code>  pre> 
 \  n 

我以前曾通过FTP使用 web.config code>的HttpPlatformHandler条目进行部署。 但是使用git push更快,特别是对于非Windows团队成员。 p>

谢谢 p> div>

As @Not_a_Golfer and @Xiaomin said, vendoring the dependencies worked, here's what I did:

  1. Turned the env variable on locally GO15VENDOREXPERIMENT=1
  2. Installed godep => go get github.com/tools/godep
  3. Making sure your app is passing a go build & go test
  4. Ran godep save this copied all dependencies to ./vendor
  5. On my Azure web app, I also set the environment variable GO15VENDOREXPERIMENT=1
  6. git pushed and voila.

At first I did not set the environment variable on my Azure app, so the dependency resolver was not looking in ./vendor, turning it to 1 fixed everything.