我有一个使用 revel 容器化在 docker 映像中构建的简单站点。我正在尝试在 Cloud Run 中运行此映像。不幸的是,当我转到该站点的 URL 时,我在浏览器中看到 502 和这条日志行
2020/10/30 17:27:07 http: proxy error: dial tcp 0.0.0.0:16166: connect: connection refused
我认为它与端口有关,但我尝试将端口最初映射到 9898,但我仍然在日志行中看到一个随机端口号。${PORT}目前,我已按照 GCP 文档的建议将我的 revel 应用程序中的端口设置为。
我应该提到我可以毫无问题地在本地部署容器。
Dockerfile:
FROM golang:1.15 AS build
ENV CGO_ENABLED 0
ADD . /go/src/app
# Install revel framework
RUN go get -u github.com/revel/revel
RUN go get -u github.com/revel/cmd/revel
# Run revel app
EXPOSE ${PORT}
ENTRYPOINT revel run -a /go/src/app -p ${PORT} -m dev
狂欢 app.conf 片段:
# The IP address on which to listen.
http.addr = 0.0.0.0
# The port on which to listen.
http.port = ${PORT}
更新:建议使用硬编码的 8080 端口,看看是否可行。我仍然看到 502。我尝试再次在本地运行它,看起来 revel 试图在一个端口上设置,然后在另一个端口上作为反向代理进行侦听。因此,除非我认为这可能是一个狂欢问题,而不是 Cloud Run 问题
docker run --publish 8080:8080 app
Revel executing: run a Revel application
Changed detected, recompiling
Parsing packages, (may require download if not cached)... Completed
INFO 02:34:24 app run.go:34: Running revel server
INFO 02:34:24 app plugin.go:9: Go to /@tests to run the tests.
Revel engine is listening on.. 0.0.0.0:44795
Time to recompile 8.0340966s
Revel proxy is listening, point your browser to : 8080
注意最后一行Revel proxy is listening, point your browser to : 8080,但也Revel engine is listening on.. 0.0.0.0:44795
湖上湖
相关分类