Open gravitystorm opened 1 week ago
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.
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:
Link: https://gist.github.com/mmd-osm/a3a0b5a8799a333e7fae578038aa7a93
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: