From cd61c0b2c1fcb5091f93faf6b241c56a6c1b9609 Mon Sep 17 00:00:00 2001 From: Takashi SAKAGUCHI Date: Mon, 15 Sep 2025 15:41:14 +0900 Subject: [PATCH] buildin chrome on devcontainer --- .devcontainer/Dockerfile | 5 +++++ .devcontainer/compose.yaml | 7 ------- .devcontainer/devcontainer.json | 5 ----- test/application_system_test_case.rb | 11 +---------- 4 files changed, 6 insertions(+), 22 deletions(-) diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index 426e001..6d31f0d 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -1,3 +1,8 @@ # Make sure RUBY_VERSION matches the Ruby version in .ruby-version ARG RUBY_VERSION=3.4.3 FROM ghcr.io/rails/devcontainer/images/ruby:$RUBY_VERSION + +RUN wget -q -O - https://dl.google.com/linux/linux_signing_key.pub | sudo apt-key add - && \ + sudo sh -c 'echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" > /etc/apt/sources.list.d/google-chrome.list' && \ + sudo apt-get update && \ + sudo apt-get install -y google-chrome-stable diff --git a/.devcontainer/compose.yaml b/.devcontainer/compose.yaml index bedf182..89156e6 100644 --- a/.devcontainer/compose.yaml +++ b/.devcontainer/compose.yaml @@ -17,11 +17,4 @@ services: # Use "forwardPorts" in **devcontainer.json** to forward an app port locally. # (Adding the "ports" property to this file will not forward from a Codespace.) - depends_on: - - selenium - - selenium: - image: selenium/standalone-chromium - restart: unless-stopped - diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index f7b57cd..84c8f07 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -12,11 +12,6 @@ "ghcr.io/rails/devcontainer/features/sqlite3": {} }, - "containerEnv": { - "CAPYBARA_SERVER_PORT": "45678", - "SELENIUM_HOST": "selenium" - }, - // A known problem is that this port forwarding configuration is not working properly right after codespace is started. // PORTS > Visibility, change the setting that is currently /set to Private to Public, and immediately change it back to Private. // This behavior seems to be a bug and is reported below. diff --git a/test/application_system_test_case.rb b/test/application_system_test_case.rb index 6e09319..cee29fd 100644 --- a/test/application_system_test_case.rb +++ b/test/application_system_test_case.rb @@ -1,14 +1,5 @@ require "test_helper" class ApplicationSystemTestCase < ActionDispatch::SystemTestCase - if ENV["CAPYBARA_SERVER_PORT"] - served_by host: "rails-app", port: ENV["CAPYBARA_SERVER_PORT"] - - driven_by :selenium, using: :headless_chrome, screen_size: [ 1400, 1400 ], options: { - browser: :remote, - url: "http://#{ENV["SELENIUM_HOST"]}:4444" - } - else - driven_by :selenium, using: :headless_chrome, screen_size: [ 1400, 1400 ] - end + driven_by :selenium, using: :headless_chrome, screen_size: [ 1400, 1400 ] end