英文:
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的建议,将依赖项进行本地化处理,以下是我所做的步骤:
- 在本地设置环境变量
GO15VENDOREXPERIMENT=1
- 安装
godep
=>go get github.com/tools/godep
- 确保你的应用程序通过了
go build
和go test
- 运行
godep save
,这将把所有依赖项复制到 ./vendor 目录下 - 在我的 Azure Web 应用中,我还设置了环境变量
GO15VENDOREXPERIMENT=1
- 提交 git 并完成。
起初,我没有在 Azure 应用中设置环境变量,所以依赖项解析器没有在 ./vendor 目录中查找,将其设置为 1 后问题得到解决。
英文:
As @Not_a_Golfer and @Xiaomin said, vendoring the dependencies worked, here's what I did:
- Turned the env variable on locally
GO15VENDOREXPERIMENT=1
- Installed
godep
=>go get github.com/tools/godep
- Making sure your app is passing a
go build
&go test
- Ran
godep save
this copied all dependencies to ./vendor - On my Azure web app, I also set the environment variable
GO15VENDOREXPERIMENT=1
- 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.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论