如何通过git push部署一个使用私有仓库作为依赖项的Azure Go Web应用程序?

huangapple go评论126阅读模式
英文:

How to deploy an Azure Go web app via git push with private repositories as dependencies?

问题

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

解析依赖项
# cd .; git clone https://github.com/my/privaterepo
  D:\local\Tempd315fa89272e69\gopath\src\github.com\my\privaterepo
正在克隆到 'D:\local\Tempd315fa89272e69\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)

构建Go应用程序以生成exe文件
azureapp\file.go:8:2: cannot find package "github.com/my/privaterepo/pkg1" 
in any of:
	D:\Program Files\Go.5.1\src\github.com\my/privaterepo/pkg1 (from $GOROOT)

我之前是通过FTP部署的,使用web.config的HttpPlatformHandler条目。但是对于非Windows团队成员来说,使用git push更快捷。

谢谢

英文:

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\Tempd315fa89272e69\gopath\src\github.com\my\privaterepo
Cloning into 'D:\local\Tempd315fa89272e69\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.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

答案1

得分: 1

根据@Not_a_Golfer和@Xiaomin的建议,将依赖项进行本地化处理,以下是我所做的步骤:

  1. 在本地设置环境变量 GO15VENDOREXPERIMENT=1
  2. 安装 godep => go get github.com/tools/godep
  3. 确保你的应用程序通过了 go buildgo test
  4. 运行 godep save,这将把所有依赖项复制到 ./vendor 目录下
  5. 在我的 Azure Web 应用中,我还设置了环境变量 GO15VENDOREXPERIMENT=1
  6. 提交 git 并完成。

起初,我没有在 Azure 应用中设置环境变量,所以依赖项解析器没有在 ./vendor 目录中查找,将其设置为 1 后问题得到解决。

英文:

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.

huangapple
  • 本文由 发表于 2016年1月6日 02:53:40
  • 转载请务必保留本文链接:https://go.coder-hub.com/34619209.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定