Skip to content

Commit

Permalink
Ensure binding is always 0.0.0.0.
Browse files Browse the repository at this point in the history
Binds the server to all IP addresses of the container, so it can be accessed from outside the container.
  • Loading branch information
viktorianer committed Jan 15, 2025
1 parent 8c7e394 commit 51dc39f
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# Make sure RUBY_VERSION matches the Ruby version in .ruby-version
ARG RUBY_VERSION=<%= Gem.ruby_version %>
FROM ghcr.io/rails/devcontainer/images/ruby:$RUBY_VERSION

# Ensure binding is always 0.0.0.0
# Binds the server to all IP addresses of the container, so it can be accessed from outside the container.
ENV BINDING="0.0.0.0"
1 change: 1 addition & 0 deletions railties/test/generators/app_generator_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1320,6 +1320,7 @@ def test_devcontainer
end
assert_file(".devcontainer/Dockerfile") do |content|
assert_match(/ARG RUBY_VERSION=#{RUBY_VERSION}/, content)
assert_match(/ENV BINDING="0.0.0.0"/, content)
end
assert_file("test/application_system_test_case.rb") do |content|
assert_match(/^ served_by host: "rails-app", port: ENV\["CAPYBARA_SERVER_PORT"\]/, content)
Expand Down
1 change: 1 addition & 0 deletions railties/test/generators/devcontainer_generator_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,7 @@ def test_system_test_option_skip
def test_common_config
assert_file(".devcontainer/Dockerfile") do |dockerfile|
assert_match(/ARG RUBY_VERSION=#{RUBY_VERSION}/, dockerfile)
assert_match(/ENV BINDING="0.0.0.0"/, dockerfile)
end

assert_devcontainer_json_file do |devcontainer_json|
Expand Down

0 comments on commit 51dc39f

Please sign in to comment.