无法调试一个容器化的 Rails 应用程序。

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

Impossible to debug a docker containerized Rails app

问题

我在Rails 7.0.4.3、Ruby 3.2.2和tailwindcss-rails 2.0的docker容器中有一个应用程序。

我的docker-compose.yml:

services:
  changes-log:
    image: changes-log
    build: .
    ports:
      - "3000:3000"
    stdin_open: true
    tty: true

镜像 "changes-log" 包含 CMD "/bin/bash"

在控制台窗口中,我运行 "docker-compose up"。接下来在另一个窗口中,我运行 "docker attach containerName"。

要启动应用程序,我运行 bin/dev。

Prifile.dev

web: bin/rails server -p 3000 -b 0.0.0.0
css: bin/rails tailwindcss:watch[poll]

在控制器的索引操作方法中,我有一个用于调试应用程序的调试器断点,但尽管应用程序流程在指定的行上停止,但它不会显示输入调试命令的指示符(rdbg)。我必须中断应用程序以停止它。

我已经搜索了关于这个问题的信息,但我找到的所有内容都说它应该可以工作。

请帮助,谢谢!!

英文:

I have an app in Rails 7.0.4.3, Ruby 3.2.2 and tailwindcss-rails 2.0 in a docker container.

My docker-compose.yml:

services:
  changes-log:
    image: changes-log
    build: .
    ports:
      - "3000:3000"
    stdin_open: true
    tty: true

Image "changes-log" contains CMD "/bin/bash".

In a console window, I run "docker-compose up". Next in another one, I run "docker attach containerName".

For starting the app I run bin/dev.

Prifile.dev

web: bin/rails server -p 3000 -b 0.0.0.0
css: bin/rails tailwindcss:watch[poll]

In index action method of the controller, I have a debugger breakpoint for debuging the app in this point, but, although the app flow is stopped in the indicated line, it doesn't show the indicator (rdbg) for inputing commands for debug. I have to break the app for stop it.

I have searched for information about it, but all I have found say It should work.

I need help, please.

Thanks !!

答案1

得分: 1

以下是翻译好的部分:

有一百万种可能的解决方案,取决于一百万种不同的情况。但这里有一个简单的建议:

不要运行 docker compose up

而是运行:
docker run --rm -it container_name bash

然后在容器内运行:
bin/rails tailwindcss:watch[poll] &
然后运行:
bin/rails server -p 3000 -b 0.0.0.0

你的应用程序应该正常工作。

一旦这样可以正常工作,你可以尝试使用集成开发环境和类似工具。

英文:

There are a million possible solutions depending on a million different things. But here's the easy advice:

Don't do docker compose up.

Instead:
docker run --rm -it container_name bash

And inside the container do bin/rails tailwindcss:watch[poll] &
And then bin/rails server -p 3000 -b 0.0.0.0

Your app should break normally.

And once that works you can try to get fancy with IDEs and the like.

huangapple
  • 本文由 发表于 2023年6月6日 05:51:17
  • 转载请务必保留本文链接:https://go.coder-hub.com/76410224.html
匿名

发表评论

匿名网友

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

确定