在 Docker 容器中运行 goconvey 的 HTTP 服务器。

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

Running goconvey http server from within a docker container

问题

我正在为一些使用Golang Web服务项目使用Docker容器,并且开发流程中的一部分是使用goconvey进行快速的TDD反馈。我想在Docker容器中启动它,并将端口暴露给主机,这样我就可以在Web浏览器中输入地址进行编码了。

我们已经编译了goconvey二进制文件,并将其放在了/usr/local/bin目录下。
问题是,每当我连接到暴露的Docker容器端口时,都只会出现"404 Page not found"错误。

我们对GOPATH进行了一些调整,特别是我将我的库放在了/vendor目录下,而代码开发则在/src目录中进行。

我可以在主机上很好地使用goconvey,但在Docker中却遇到了困难。
404错误表明我正在访问goconvey服务器,但它没有提供任何内容。

希望能得到帮助。

英文:

I'm using docker containers for some of my golang web service projects and part of the development workflow is using goconvey for some fast tdd feedback. I'd like to spin this up within a docker container and expose the port to the host machine so I can point my web browser to it and get coding.

We have compiled the goconvey binary and have popped it in /usr/local/bin
The problem is that whenever I connect to the port exposed form the docker container I only get "404 Page not found" errors.

There are a few tweaks we have with out GOPATH specifically I'm vendoring my libs eg GOPATH=/proj-dir/vendor and code dev is happening in /src

I can get goconvey working nicely on my host but in the docker i'm stumped.
The 404 suggest that I'm hitting the goconvey server but it does not serve up anything?

Any assistance appreciated.

答案1

得分: 2

goconvey服务器在找不到包含静态资源的目录时返回404错误。
该目录的位置取决于go get存储goconvey文件的位置,通常在

$GOPATH/src/github.com/smartystreets/goconvey

因此,在您的Docker容器中,请确保使用当前的$GOPATH值安装了goconvey,并验证/goconvey目录是否包含/web/client/...子目录,这是Web UI的HTML、CSS和JS文件所在的位置。

(为了测试这一点,我重命名了client目录,导致goconvey返回一个普通的404消息。)

英文:

The goconvey server returns 404 when it cannot find the directory that contains the static resources.
The location of this directory depends on where go get stored the goconvey files, usually in

$GOPATH/src/github.com/smartystreets/goconvey

So in your docker container, ensure that goconvey is installed using the current $GOPATH value, and also verify that the /goconvey dir contains /web/client/... subdirectories, which is where the html, css, and js files for the Web UI reside.

(To test this, I renamed the client dir, which caused goconvey to return a plain 404 message.)

huangapple
  • 本文由 发表于 2015年7月8日 14:51:46
  • 转载请务必保留本文链接:https://go.coder-hub.com/31285448.html
匿名

发表评论

匿名网友

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

确定