nickjj / docker-rails-example

A production ready example Rails app that's using Docker and Docker Compose.
MIT License
941 stars 185 forks source link

Failed to open TCP connection on 9090 port with motor-admin-rails gem #79

Closed bpezet closed 1 month ago

bpezet commented 1 month ago

Hi @nickjj !

Thanks for all your work! I already use your repository for some of my personal projects. Recently, I wanted to create a project to use the motor-admin-rails gem.

I followed their doc and yours to install the gem:

  1. add to Gemfile
  2. ./run rails g motor:install
  3. ./run rails db:setup

On startup I get this log from the web service which confirms the installation of the gem:

web-1 | ⚡ Motor::Admin is starting under /motor_admin (the gem has been installed)

But when I want to access the page linked to the gem, I get this error:

web-1 | I, [2024-05-29T15:56:05.269178 #15] INFO -- : Started GET “/motor_admin/assets/main-3b866105d1b5846018e0.css” for 192.168.65.1 at 2024-05-29 15:56:05 +0000
web-1 | E, [2024-05-29T15:56:05.285530 #15] ERROR -- :   
web-1 | Errno::EADDRNOTAVAIL (Failed to open TCP connection to localhost:9090 (Cannot assign requested address - connect(2) for “localhost” port 9090)):

I've already tested these modifications but nothing changes: Dockerfile:78 EXPOSE 9090 docker-compose.yml:89 - "9090:9090"

Do you know how to allow a connection to port 9090 (for the motor-admin-rails gem) while keeping the connection to port 8000 for the standard rails application?

nickjj commented 1 month ago

Hi,

I haven't used that gem but their docs mention you can add mount Motor::Admin => '/admin' to your routes. This project does something similar with Sidekiq in the sense I'm guessing you'd be able to access http://localhost:8000/admin then.

I looked at motor admin's README and there's no reference to 9090 anywhere. Is it expected that you run a dedicated process? If so then you can make a separate Docker Compose service for that using the same Docker image as Puma and Sidekiq.

docker-compose.yml:89 - "9090:9090"

That would make it available but only if there's a running process using port 9090 in the container. That wouldn't be the case here since this project runs Puma on port 8000 by default unless you changed the Dockerfile to use a process manager and are running both Puma plus whatever motor's process is.

bpezet commented 1 month ago

Thank you for your fast response! I hadn't modified the basic Dockerfile...

In the end, the solution proposed by motor-admin doesn't really fit my needs.

All the best and thanks again for your work!

nickjj commented 1 month ago

No problem, good luck. Did you end up not using the project or did the route mount not work?

bpezet commented 1 month ago

Both 😅 I had the error by mounting and trying to access the route. I gave up on the gem.