Skip to content

Docker Console and Debugger #31

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 10 commits into from
Jun 26, 2024
3 changes: 3 additions & 0 deletions app-rails/config/environments/development.rb
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,9 @@
# Suppress logger output for asset requests.
config.assets.quiet = true

# Allow web_console to render when triggered from the rails app running locally in a docker container.
config.web_console.permissions = ["192.168.0.0/16", "172.16.0.0/16", "10.0.0.0/8"]

# Raises error for missing translations.
# config.i18n.raise_on_missing_translations = true

Expand Down
6 changes: 4 additions & 2 deletions docs/app-rails/technical-foundation.md
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,9 @@ Rails has some useful [built-in debugging tools](https://guides.rubyonrails.org/

- Start the rails console: `make rails-console`
- Run a console in the browser:
- Add a `console` line and an interactive console, similar to the rails console, will appear in the bottom half of your browser window
- Add a `console` with `<% console %>` line to an `.erb` file and an interactive console, similar to the rails console, will appear in the bottom half of your browser window
- Note: If the console doesn't appear when running in a docker container, check to see if your IP address is added to the permissions list in [development.rb](app-rails/config/environments/development.rb) in `config.web_console.permissions`. The list is currently set to allow most internal IPs. You would also see an error in your terminal that looks something like: `Cannot render console from <your.IP.address.here>! Allowed networks: 127.0.0.0/127.255.255.255, ::1`
- Run the debugger:
- Add a `debugger` line and the rails server will pause and start the debugger
- Note: this is not yet configured for this application when doing local development in a container
- Note: If you're running the app with `make start-native` you'll have to connect to the debugger from another winder because of our [Procfile.dev](app-rails/Procfile.dev) configuration. From another terminal tab, run `rdbg -An`. If you have multiple Rails applications with debuggers running, you'll have to specify the port to attach the debugger to. Check out [Rails debug gem docks](https://github.com/ruby/debug?tab=readme-ov-file#remote-debugging) for more info.
- Note: If you're running the app in a docker container with `make start-container` `rdbg` from your terminal will not be able to see the port in the container to connect to the debugger. You'll have to `exec` into the docker container and run the command from there. First, run `docker ps` and grab the `CONTAINER ID` for the container running your rails app. Then run this command to show the debugger: `docker exec -i <CONTAINER ID> rdbg -An`.
Loading