Fixes https://github.com/openstreetmap/openstreetmap-website/issues/5264

Based on the conversation at 
https://github.com/openstreetmap/openstreetmap-website/issues/2344 (re: what to 
do with Vagrant and Docker), I have been playing with devcontainer a bit. This 
is not trivial stuff and requires a lot of trial&error (or perhaps I'm 
a dinosaur unable to understand these newfangled doohickeys), so for now 
I'm going to publish this draft for others to see and gather opinions and 
expertise.

To the extent I have been able to, I have followed "the Rails way". 
Parting from `bin/rails devcontainer` and iterating from there. This sort of 
works now: the dev server works and most test pass (need to look into the last 
few). There's a few caveats though that still need to be looked into:

- I can't copy files or run user commands (rails, bundler, yarn) in the 
Dockerfile, so these don't get committed in the image. I have to do it in 
`bin/setup` instead. As a result:
        - It installs Bundler dependencies every time I start the devcontainer.
                - Perhaps this can be avoided by installing gems to `.vendor` 
within the project (and gitignore'ing it)?
        - It copies config files such as `database.yml` or `settings.local.yml` 
both inside and outside the container. Therefore you can only configure the 
project to run with or without devcontainer, but not both.
- No idea what's different between the local and the remote ways to run 
Selenium (perhaps just a version number), but it appears that Selenium 
doesn't like posting forms where something has a value `"test"`. 
As a result I had to change all instances of `:password => "test"` 
to something else.
- So far I have tried only with VSCode. I need to test this with something else.
- I had to disable parallel test as they don't play well with this remote 
Selenium setup.
        - Perhaps if I was able to run a few Selenium containers in 
parallel...? No idea of what is feasible.
- The DB seed script doesn't quite work: users get the annoying error about 
scopes after log in. I took it from mmd's at 
https://gist.github.com/mmd-osm/a3a0b5a8799a333e7fae578038aa7a93. I need to 
look a bit more into it.

Good news:
- This appears to be running well on CI (still need to look into those failing 
tests).
- The number of required apt packages has been reduced to 3.

I'm sure I'm leaving something out... Will update. In the meantime: 
thoughts?
You can view, comment on, or merge this pull request online at:

  https://github.com/openstreetmap/openstreetmap-website/pull/6424

-- Commit Summary --

  * $ ./bin/rails devcontainer # DB config written as 
config/devcontainer.database.yml
  * Fix system tests config, broken by devcontainer generator
  * Figuring out devcontainer config
  * Selenium/WebDriver thinks that `test` signals a fake file upload
  * Using Firefox for Selenium/WebDriver
  * Tell WebMock to allow inter-container requests
  * Parallelisation not working in the devcontainer
  * Remove unnecessary dependencies
  * WIP: Use Rails devcontainer image
  * Consistent use of Yarn and Bundler
  * We need the `file` utility
  * mmd's seed code
  * CI action for devcontainer. Drop Docker action
  * Don't prompt about trusting mise
  * Remove Dockerfile

-- File Changes --

    A .devcontainer/Dockerfile (53)
    A .devcontainer/compose.yaml (40)
    A .devcontainer/devcontainer.json (35)
    A .devcontainer/start (7)
    A .github/workflows/devcontainer.yml (17)
    D .github/workflows/docker.yml (42)
    D Dockerfile (50)
    M bin/setup (1)
    A config/devcontainer.database.yml (103)
    M db/seeds.rb (72)
    M test/application_system_test_case.rb (24)
    M test/controllers/sessions_controller_test.rb (12)
    M test/factories/user.rb (2)
    M test/integration/login_test.rb (64)
    M test/integration/oauth2_test.rb (2)
    M test/integration/page_locale_test.rb (4)
    M test/integration/user_blocks_test.rb (2)
    M test/integration/user_diaries_test.rb (2)
    M test/integration/user_terms_seen_test.rb (4)
    M test/system/user_login_test.rb (2)
    M test/test_helper.rb (27)

-- Patch Links --

https://github.com/openstreetmap/openstreetmap-website/pull/6424.patch
https://github.com/openstreetmap/openstreetmap-website/pull/6424.diff

-- 
Reply to this email directly or view it on GitHub:
https://github.com/openstreetmap/openstreetmap-website/pull/6424
You are receiving this because you are subscribed to this thread.

Message ID: <openstreetmap/openstreetmap-website/pull/[email protected]>
_______________________________________________
rails-dev mailing list
[email protected]
https://lists.openstreetmap.org/listinfo/rails-dev

Reply via email to