Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add devcontainer configuration #5264

Open
gravitystorm opened this issue Oct 16, 2024 · 1 comment
Open

Add devcontainer configuration #5264

gravitystorm opened this issue Oct 16, 2024 · 1 comment
Labels
dx Developer Experience

Comments

@gravitystorm
Copy link
Collaborator

We added support for Docker-based development in 2021 (based on a PR started in 2019). At this time there were no clear conventions for setting up docker-based development environments, so we did our own thing.

Nowadays, a number of tools support the "Development Container" specification. This provides a few additional benefits, for example tighter integration between code editors and the containers (e.g. running the rubocop process within the container, but seeing the syntax highlighting in your editor UI). Dev containers are supported by vscode and intellij code editors, and are also a part of Github Codespaces. Codespaces allow developers to make code changes, run tests and make PRs, all without installing anything locally. So it would be nice to fully support that too.

It's also notable that rails 7.2 added built-in support for devcontainers configuration, so running bundle exec rails devcontainer gets us started on the setup and generating the configuration files.

I therefore propose:

  • We set up the devcontainer configuration and make sure it works.
  • We move the docker part of CI to use the devcontainer configuration.
  • We remove the original Docker configuration and update the documentation.
  • We also consider removing the vagrant configuration.
@gravitystorm gravitystorm added the dx Developer Experience label Oct 16, 2024
@mmd-osm
Copy link
Contributor

mmd-osm commented Oct 19, 2024

Thanks, this looks like a great suggestion. I gave it a try, created a new clone of the repo, then added a new devcontainer using bundle exec rails container.

Initially I was a bit struggling with (Debian, Rails, npm) packages on generated devcontainer. I believe we can probably reuse a lot of the existing Dockerfile and copy it over to .devcontainer/Dockerfile, thereby hopefully addressing these issues. There's a bit of overlap between the "postCreateCommand" in devcontainer.json and the existing Dockerfile, which would need to be resolved.

Then I added memcached and mailpit to compose.yaml and adjusted settings.local.yml accordingly. Both were fairly trivial to get up and running. They allow me to run more production-like scenarios without much hassle. Also, unit tests are passing successfully.

Overall I see a much improved DX compared to the old Dockerfile.

Sample screenshot

image

I've uploaded the config files supporting this little experiment to: https://gist.github.com/mmd-osm/7f3c871a17d496475e7c10e054ba921c

In addition, I highly recommend to include a set up script for the dev container, which:

  • Creates admin + testuser
  • Registers OAuth applications for iD, JOSM and website
  • Creates a private doorkeeper signing key
  • Generates output for copy+pasting into settings.local.yml

Link: https://gist.github.com/mmd-osm/a3a0b5a8799a333e7fae578038aa7a93

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dx Developer Experience
Projects
None yet
Development

No branches or pull requests

2 participants