From af35910179aa4d480296bb81daa7cca31d823d35 Mon Sep 17 00:00:00 2001 From: Sammy Steiner Date: Fri, 14 Jun 2024 18:53:32 -0400 Subject: [PATCH 1/7] console permissions and update docs --- app-rails/config/environments/development.rb | 3 +++ docs/app-rails/technical-foundation.md | 6 ++++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/app-rails/config/environments/development.rb b/app-rails/config/environments/development.rb index abaf811..4c91f5c 100644 --- a/app-rails/config/environments/development.rb +++ b/app-rails/config/environments/development.rb @@ -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 diff --git a/docs/app-rails/technical-foundation.md b/docs/app-rails/technical-foundation.md index 8198d83..97742ec 100644 --- a/docs/app-rails/technical-foundation.md +++ b/docs/app-rails/technical-foundation.md @@ -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 ! 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 rdbg -An`. From 6a909736db59a5a4ce38fc06d3f5b7e38a91724d Mon Sep 17 00:00:00 2001 From: Sammy Date: Tue, 18 Jun 2024 09:24:04 -0400 Subject: [PATCH 2/7] Update docs/app-rails/technical-foundation.md Co-authored-by: Rocket --- docs/app-rails/technical-foundation.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/app-rails/technical-foundation.md b/docs/app-rails/technical-foundation.md index 97742ec..c5c6c34 100644 --- a/docs/app-rails/technical-foundation.md +++ b/docs/app-rails/technical-foundation.md @@ -129,7 +129,7 @@ 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` 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 + - Add `<% console %>` 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 ! 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 From ccfc86b45a1e6807b3ccd99d4463f8c12e0cf687 Mon Sep 17 00:00:00 2001 From: Sammy Date: Tue, 18 Jun 2024 09:24:11 -0400 Subject: [PATCH 3/7] Update docs/app-rails/technical-foundation.md Co-authored-by: Rocket --- docs/app-rails/technical-foundation.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/app-rails/technical-foundation.md b/docs/app-rails/technical-foundation.md index c5c6c34..ccfe64d 100644 --- a/docs/app-rails/technical-foundation.md +++ b/docs/app-rails/technical-foundation.md @@ -127,7 +127,7 @@ make rails-generate GENERATE_COMMAND="model Foo --primary-key-type=uuid" Rails has some useful [built-in debugging tools](https://guides.rubyonrails.org/debugging_rails_applications.html). -- Start the rails console: `make rails-console` +- Start the [rails console](https://guides.rubyonrails.org/command_line.html#bin-rails-console): `make rails-console` - Run a console in the browser: - Add `<% console %>` 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 ! Allowed networks: 127.0.0.0/127.255.255.255, ::1` From b7f399439942c872c749d0c8b33b655076a9da99 Mon Sep 17 00:00:00 2001 From: Sammy Date: Tue, 18 Jun 2024 09:24:31 -0400 Subject: [PATCH 4/7] Update docs/app-rails/technical-foundation.md Co-authored-by: Rocket --- docs/app-rails/technical-foundation.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/docs/app-rails/technical-foundation.md b/docs/app-rails/technical-foundation.md index ccfe64d..55b30ad 100644 --- a/docs/app-rails/technical-foundation.md +++ b/docs/app-rails/technical-foundation.md @@ -133,5 +133,8 @@ Rails has some useful [built-in debugging tools](https://guides.rubyonrails.org/ - 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 ! 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: 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. + - If you're running the app natively, such as with `make start-native`: + - You must connect to the debugger from another terminal session 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. For more information, see the [Rails debug gem documentation](https://github.com/ruby/debug?tab=readme-ov-file#remote-debugging). - 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 rdbg -An`. From 8677912df656347b1bb6515ebfbc043babc0cc47 Mon Sep 17 00:00:00 2001 From: Sammy Date: Tue, 18 Jun 2024 09:24:36 -0400 Subject: [PATCH 5/7] Update docs/app-rails/technical-foundation.md Co-authored-by: Rocket --- docs/app-rails/technical-foundation.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/docs/app-rails/technical-foundation.md b/docs/app-rails/technical-foundation.md index 55b30ad..92f8c2b 100644 --- a/docs/app-rails/technical-foundation.md +++ b/docs/app-rails/technical-foundation.md @@ -137,4 +137,6 @@ Rails has some useful [built-in debugging tools](https://guides.rubyonrails.org/ - You must connect to the debugger from another terminal session 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. For more information, see the [Rails debug gem documentation](https://github.com/ruby/debug?tab=readme-ov-file#remote-debugging). - - 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 rdbg -An`. + - If you're running the app in a container, such as with `make start-container`: + - `rdbg` in the terminal on your host machine will not be able to see the port in the container to connect to the debugger. + - Instead, run `rdbg` inside the container: `docker compose exec app-rails rdbg -An` From cd110c0eb628facb94e5f1e8a4d382c8e3de2078 Mon Sep 17 00:00:00 2001 From: Sammy Steiner Date: Tue, 18 Jun 2024 10:25:44 -0400 Subject: [PATCH 6/7] here are options --- docs/app-rails/technical-foundation.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/app-rails/technical-foundation.md b/docs/app-rails/technical-foundation.md index 92f8c2b..30cf2be 100644 --- a/docs/app-rails/technical-foundation.md +++ b/docs/app-rails/technical-foundation.md @@ -125,7 +125,7 @@ make rails-generate GENERATE_COMMAND="model Foo --primary-key-type=uuid" ### 🐛 Debugging -Rails has some useful [built-in debugging tools](https://guides.rubyonrails.org/debugging_rails_applications.html). +Rails has some useful [built-in debugging tools](https://guides.rubyonrails.org/debugging_rails_applications.html). Here are a few different options: - Start the [rails console](https://guides.rubyonrails.org/command_line.html#bin-rails-console): `make rails-console` - Run a console in the browser: From 63c1bc859be4315f7114a33bedb340533b9d737b Mon Sep 17 00:00:00 2001 From: Sammy Steiner Date: Wed, 26 Jun 2024 14:40:50 -0400 Subject: [PATCH 7/7] lock debug gem version, small readme update. --- app-rails/Dockerfile | 4 ++++ docs/app-rails/technical-foundation.md | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/app-rails/Dockerfile b/app-rails/Dockerfile index 3470c5c..df9ba24 100644 --- a/app-rails/Dockerfile +++ b/app-rails/Dockerfile @@ -55,6 +55,10 @@ RUN bundle config set --local without production && \ bundle install && \ rm -rf ~/.bundle/ "${BUNDLE_PATH}"/ruby/*/cache "${BUNDLE_PATH}"/ruby/*/bundler/gems/*/.git +# Install system-wide gems for development +# This version must match Gemfile.lock. Otherwise, `rdbg` will fail. +RUN gem install debug -v 1.9.2 + # Copy application code COPY . . diff --git a/docs/app-rails/technical-foundation.md b/docs/app-rails/technical-foundation.md index 30cf2be..9428e52 100644 --- a/docs/app-rails/technical-foundation.md +++ b/docs/app-rails/technical-foundation.md @@ -135,8 +135,8 @@ Rails has some useful [built-in debugging tools](https://guides.rubyonrails.org/ - Add a `debugger` line and the rails server will pause and start the debugger - If you're running the app natively, such as with `make start-native`: - You must connect to the debugger from another terminal session because of our [Procfile.dev](app-rails/Procfile.dev) configuration. - - From another terminal tab, run `rdbg -An`. + - From another terminal tab, run `rdbg -A`. - If you have multiple Rails applications with debuggers running, you'll have to specify the port to attach the debugger to. For more information, see the [Rails debug gem documentation](https://github.com/ruby/debug?tab=readme-ov-file#remote-debugging). - If you're running the app in a container, such as with `make start-container`: - `rdbg` in the terminal on your host machine will not be able to see the port in the container to connect to the debugger. - - Instead, run `rdbg` inside the container: `docker compose exec app-rails rdbg -An` + - Instead, run `rdbg` inside the container: `docker compose exec app-rails rdbg -A`, where `app-rails` is the name of the service in `docker compose`