Skip to content

Commit 869cfe7

Browse files
committed
Fix CI system test networking via host.docker.internal
1 parent 77fa0bf commit 869cfe7

2 files changed

Lines changed: 8 additions & 4 deletions

File tree

.github/workflows/ci.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@ jobs:
2828
image: selenium/standalone-chrome:latest
2929
ports:
3030
- 4444:4444
31+
options: >-
32+
--add-host=host.docker.internal:host-gateway
33+
--shm-size=2g
3134
3235
env:
3336
RAILS_ENV: test

test/application_system_test_case.rb

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,12 @@ class ApplicationSystemTestCase < ActionDispatch::SystemTestCase
2121

2222
setup do
2323
if ENV["GITHUB_ACTIONS"] == "true"
24-
# CI: Rails runs on the runner, so point Chrome at localhost
25-
Capybara.server_host = "127.0.0.1"
26-
Capybara.app_host = "http://127.0.0.1:#{Capybara.server_port}"
24+
# CI: Rails runs on the runner, Chrome runs in a container.
25+
# Bind Rails to all interfaces, and have Chrome reach the runner via host gateway.
26+
Capybara.server_host = "0.0.0.0"
27+
Capybara.app_host = "http://host.docker.internal:#{Capybara.server_port}"
2728
else
28-
# Docker Compose: expose the server and use the service name on the docker network
29+
# Docker Compose: both services on the same docker network
2930
Capybara.server_host = "0.0.0.0"
3031
Capybara.app_host = "http://web:#{Capybara.server_port}"
3132
end

0 commit comments

Comments
 (0)