navapbc / template-application-rails

Ruby on Rails with USWDS template, including CI/CD, for teams building web applications
Apache License 2.0
2 stars 1 forks source link

Docker Console and Debugger #31

Closed SammySteiner closed 4 months ago

SammySteiner commented 5 months ago

Ticket

Changes

Questions for reviewers

  1. In the technical-foundation doc, it says to run the app with make rails-console though I think elsewhere it says to use make init-native/container and make start-native/container for local native and local docker development. Should we change it here to be consistent?
  2. We're pulling the ruby:3.3.1-slim image from dockerhub which comes with the debug gem version 1.19.1. However, in our local gemfile.lock we have debug version 1.19.2 installed. Using debug in docker breaks when there is a version mismatch between the server and the client. This will be fixed whenever dockerhub updates their ruby:3.3.1-slim image, but I was only able to get it running locally by locking my debug version in the gemfile to 1.9.1. Is there a best practice to address this?
  3. When setting the IP addresses for permissions, there are some programmatic ways of getting locaL IP addresses, but it seems like those require additional libraries (socket, ipaddr). Is that preferred to the current method or should we go even further by allowing 0.0.0.0?

Testing

rocketnova commented 5 months ago
  1. In the technical-foundation doc, it says to run the app with make rails-console though I think elsewhere it says to use make init-native/container and make start-native/container for local native and local docker development. Should we change it here to be consistent?

I addressed this in my inline comments. make init-container and make start-container initialize and start the container. They do not create an interactive rails console. make rails-console does.

  1. We're pulling the ruby:3.3.1-slim image from dockerhub which comes with the debug gem version 1.19.1. However, in our local gemfile.lock we have debug version 1.19.2 installed. Using debug in docker breaks when there is a version mismatch between the server and the client. This will be fixed whenever dockerhub updates their ruby:3.3.1-slim image, but I was only able to get it running locally by locking my debug version in the gemfile to 1.9.1. Is there a best practice to address this?

Can you link me to where the upstream ruby docker hub image includes the debug gem? I'm not seeing that. You said "I was only able to get it running locally". What were you trying to run that was failing with this?

  1. When setting the IP addresses for permissions, there are some programmatic ways of getting locaL IP addresses, but it seems like those require additional libraries (socket, ipaddr). Is that preferred to the current method or should we go even further by allowing 0.0.0.0?

Can you explain what wasn't working before you added this? I'm not sure I'm following.

SammySteiner commented 5 months ago
  1. In the technical-foundation doc, it says to run the app with make rails-console though I think elsewhere it says to use make init-native/container and make start-native/container for local native and local docker development. Should we change it here to be consistent?

I addressed this in my inline comments. make init-container and make start-container initialize and start the container. They do not create an interactive rails console. make rails-console does.

Sounds good. Thanks for clarifying.

  1. We're pulling the ruby:3.3.1-slim image from dockerhub which comes with the debug gem version 1.19.1. However, in our local gemfile.lock we have debug version 1.19.2 installed. Using debug in docker breaks when there is a version mismatch between the server and the client. This will be fixed whenever dockerhub updates their ruby:3.3.1-slim image, but I was only able to get it running locally by locking my debug version in the gemfile to 1.9.1. Is there a best practice to address this?

Can you link me to where the upstream ruby docker hub image includes the debug gem? I'm not seeing that. You said "I was only able to get it running locally". What were you trying to run that was failing with this?

The debug gem in the docker ruby 3.3.1-slim image is listed as version 1.9.1, which I was able to confirm on the dockerhub website: image The debug version getting installed in our project is listed as 1.9.2 in our gemfile.lock. When I try to attach a debugger to the docker container with docker exec -i <Container ID> rdbg -An I get the error in my terminal:

app-rails-1  | 14:42:38 web.1  | DEBUGGER: wait for debugger connection...
app-rails-1  | 14:43:25 web.1  | DEBUGGER: Connected.
app-rails-1  | 14:43:25 web.1  | DEBUGGER: GreetingError: out DEBUGGER: Incompatible version (server:1.9.2 and client:1.9.1)
app-rails-1  | 14:43:25 web.1  | DEBUGGER: Disconnected.

However, if I lock my debug gem to version 1.9.1, and re-bundle and create a new containerized app, it works as expected.

I described how I'm running my docker container in the inline comment here, are you doing it differently?

  1. When setting the IP addresses for permissions, there are some programmatic ways of getting locaL IP addresses, but it seems like those require additional libraries (socket, ipaddr). Is that preferred to the current method or should we go even further by allowing 0.0.0.0?

Can you explain what wasn't working before you added this? I'm not sure I'm following.

Responded to your inline comment.

rocketnova commented 5 months ago

However, if I lock my debug gem to version 1.9.1, and re-bundle and create a new containerized app, it works as expected.

I described how I'm running my docker container in the inline comment here, are you doing it differently?

Got it! Thanks. I think what we should do is explicitly install a global version of the debug gem inside the docker image that is used for development, by adding this to line 57 of the Dockerfile:

# Install system-wide gems for development
# This version must match Gemfile.lock. Otherwise, `rdbg` will fail.
RUN gem install debug -v 1.9.2
  1. When setting the IP addresses for permissions, there are some programmatic ways of getting locaL IP addresses, but it seems like those require additional libraries (socket, ipaddr). Is that preferred to the current method or should we go even further by allowing 0.0.0.0?

Can you explain what wasn't working before you added this? I'm not sure I'm following.

Responded to your inline comment.

I think your change is good and that we don't need to expand out to 0.0.0.0.