简体   繁体   English

如何在本地 docker 环境中使用 puma-dev?

[英]How can I use puma-dev in a local docker environment?

I'm working with a legacy Rails application that requires the puma-dev tool in order to develop locally.我正在使用一个旧的 Rails 应用程序,它需要puma-dev工具才能在本地开发。 The app needs to be able to resolve domains like client-a.myapp.test to localhost:3000.该应用程序需要能够将client-a.myapp.test等域client-a.myapp.test为 localhost:3000。

The problem is this app is so old that me and my team need to docker-ize it in order to have any hope of standing it up locally, due to various outdated components.问题是这个应用程序太旧了,由于各种过时的组件,我和我的团队需要对其进行 docker-ize 以便有希望在本地站起来。

The problem, continued, is that I can't just plop puma-dev into my docker container because Linux support for the tool is extremely lacking and highly unclear how to translate the instructions to a docker environment.问题是,我不能只是将 puma-dev 放入我的 docker 容器中,因为 Linux 对该工具的支持非常缺乏,并且非常不清楚如何将指令转换为 docker 环境。 After struggling with that route for quite a while I decided to take another approach.在这条路线上挣扎了很长一段时间后,我决定采取另一种方法。

Right now I've created a separate docker image just for puma-dev from a golang image on dockerhub.现在我已经从 dockerhub 上的 golang 镜像为 puma-dev 创建了一个单独的 docker 镜像。 I decided to try and run it in parallel with my other docker container, containing the ruby app, in hopes that they can work together (the ruby app serving on port 3000, with puma-dev listening), or with me ultimately listing it as a dependency in docker-compose for the ruby app and bundling them together.我决定尝试将它与包含 ruby​​ 应用程序的其他 docker 容器并行运行,希望它们可以一起工作(在端口 3000 上服务的 ruby​​ 应用程序,使用 puma-dev 侦听),或者与我最终将其列为ruby 应用程序的 docker-compose 依赖项并将它们捆绑在一起。 However, I'm not sure if that makes any sense at all to do, or if it's at all a logically sound approach.但是,我不确定这样做是否有意义,或者它是否完全符合逻辑。

I guess my question is, is it possible for me to do it this way?我想我的问题是,我可以这样做吗? Or, better yet, how can I get puma-dev working with Docker?或者,更好的是,我怎样才能让 puma-dev 与 Docker 一起工作?

You can use puma-dev proxy feature https://github.com/puma/puma-dev#proxy-support您可以使用 puma-dev 代理功能https://github.com/puma/puma-dev#proxy-support

Run rails server in the rails docker image and expose the port 3000, then in your host machine set a proxy for localhost:3000 with this command:在 rails docker 映像中运行 rails server 并公开端口 3000,然后在您的主机中使用以下命令为 localhost:3000 设置代理:

echo '3000' > ~/.puma-dev/myapp

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM