go-kratos / gateway

A high-performance API Gateway with middlewares, supporting HTTP and gRPC protocols.
MIT License
686 stars 134 forks source link

Dockerfile 问题 #219

Closed kvii closed 5 months ago

kvii commented 8 months ago

gateway 工程的 go.mod 是 1.19,但 Dockerfile 里用到的基础镜像是 golang:1.17。

https://github.com/go-kratos/gateway/blob/abf713bc415f6f2fd68e933c479f0dbe7a1fd12b/Dockerfile#L1

另外 gateway 工程的命令行参数 conf 期望传具体配置的路径,如 "/data/conf/config.yaml",而 Dockerfile 的默认配置指定的是目录名。

https://github.com/go-kratos/gateway/blob/abf713bc415f6f2fd68e933c479f0dbe7a1fd12b/Dockerfile#L25

现在 gateway 工程有打好的镜像吗?比如 "ghcr.io/go-kratos/gateway" 这样的。

dosubot[bot] commented 8 months ago

🤖

Hello @kvii! 👋

I'm Dosu, an AI here to assist you with your issues and questions about the gateway repository until a human maintainer can respond. I'm here to make your contribution process smoother and quicker. So, don't hesitate to ask anything! 😊

是的,gateway 项目有预构建的 Docker 镜像。上下文中提供的 Dockerfile 显示了构建 Docker 镜像的步骤。

使用的基础镜像是 golang:1.17,用于构建应用程序。除非应用程序依赖于 Go 1.19 的特定功能,否则 go.mod 版本(1.19)和 Dockerfile 中的基础镜像(golang:1.17)之间的差异不应该是问题。如果是这种情况,你应该将基础镜像更新为 golang:1.19

Dockerfile 还显示,预期构建的应用程序将使用命令行参数进行配置(-conf)。Dockerfile 在 CMD 指令中指定了这一点:CMD ["./gateway", "-conf", "/data/conf"]。这意味着当 Docker 容器运行时,它将执行 ./gateway 二进制文件,并带有 -conf 标志,配置文件应位于容器内的 /data/conf

如果你想构建并运行 Docker 镜像,可以使用以下命令:

构建镜像:

docker build -t gateway .

运行镜像:

docker run -p 8080:8080 -p 7070:7070 -v /path/to/your/conf:/data/conf gateway

/path/to/your/conf 替换为你主机上配置文件的路径。

关于 gateway 项目是否使用了仅在 Go 1.19 中可用而在 Go 1.17 中不可用的特定功能,我在仓库中没有找到答案,但答案可能在其他地方,或者我可能错过了。如果你有更多信息,我会很乐意帮助你进一步解决这个问题。

来源:

Sources


This response is meant to be useful and save you time. It is not meant to be a precise solution, but rather a starting point for your own research.

Help me be more useful! Please leave a 👍 if this is helpful and 👎 if it is irrelevant.

If you want to continue the conversation, start your reply with @dosu-bot.