[英]Why does AWS elastic beanstalk fail to build my app?
I have an app written in Go, which I attempted to deploy to EB. 我有一个用Go编写的应用程序,尝试将其部署到EB。 When trying to access it, I get an Error 502 from nginx, presumably because the app is not running.
尝试访问它时,我从nginx收到错误502,大概是因为该应用程序未运行。
Looking at logs, I get a lot of errors like 查看日志,我发现很多错误,例如
14:01:29 build.1 | application.go:10:2: cannot find package "github.com/aws/aws-sdk-go/aws" in any of:
14:01:29 build.1 | /opt/elasticbeanstalk/lib/go/src/github.com/aws/aws-sdk-go/aws (from $GOROOT)
14:01:29 build.1 | /var/app/current/src/github.com/aws/aws-sdk-go/aws (from $GOPATH)
Despite the fact, that I have all of my dependencies included in the application bundle under a vendor
subdirectory. 尽管事实如此,但我的所有依赖关系都包含在
vendor
子目录下的应用程序捆绑中。 How come EB does not use vendoring? EB为什么不使用供应商? According to the dashboard, it is running Go 1.9, so vendoring should be supported.
根据仪表板,它正在运行1.9,因此应支持供应商。
You need to set your GOPATH
in your EBS to the root of your project directory, assuming there is a src
directory where your vendor
directory is located. 您需要将EBS中的
GOPATH
设置为项目目录的根目录,并假定您的vendor
目录位于一个src
目录中。
For instance, pretend this is your project structure: 例如,假设这是您的项目结构:
app/
src/
vendor/
And pretend that project is located in ~/home
, which makes its location ~/home/app
. 并假装该项目位于
~/home
,从而使其位置为~/home/app
。
Then your GOPATH
should be set to ~/home/app
. 然后,您的
GOPATH
应该设置为~/home/app
。 Go will attempt to access the dependencies through $GOPATH/src/vendor
. Go将尝试通过
$GOPATH/src/vendor
访问依赖项。
But if this were the kind of structure you were using before, then you would need to have your GOPATH updated during local development as well, so if you aren't already doing that then I imagine you're using a different kind of setup... this solution, however, will work as long as your project is structured as I described above. 但是,如果这是您以前使用的那种结构,那么您还需要在本地开发期间更新GOPATH,因此,如果您尚未这样做,那么我想您正在使用另一种设置。 ..但是,只要您的项目的结构如上所述,该解决方案就可以使用。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.