New Discussion

Notifications

You’re not receiving notifications from this thread.

How to use Dev Containers with Rails Discussion

21
General

Pretty excited about this because it makes Rails development so much easier to start for beginners or for teams using various operating systems.

I also forgot to mention, there is a devcontainer CLI that you can use outside of VS Code, so you could use Vim or other editors inside the devcontainer. https://github.com/devcontainers/cli

What do you think? Will you use Dev Containers?

How do you use devcontainer with Nova?

how do i run devcontainer cli in vim pleas help!

that's great Level Devil

Are these ok to use day to day for development? Ie, can I switch my app to work in a devcontainer and just use that from here on out?

That's exactly what it's for. 👍

Amazing! Will give it a shot!

This looks great. Is the only reason VScode is required due to the devcontainer plugin? I ask because for the past year or so I've gone full neovim. It looks like there are some attempts at a devcontainer plugin there as well.

Would you happen to have tried the neovim devcontainer plugin(s)? If so, how well did it work?

Dang it. Missed your comment about the devcontainer CLI so using vim / neovim etc will work. Just not as seamless as VScode.

You can install vim / neovim / etc inside the container. Here's a blog post about it: https://cadu.dev/running-neovim-on-devcontainers/

This has been on my radar for a while! I have my own Docker development setup that I optimized the last few years, but will almost certainly switch to the Rails implementation. I know that devcontainers is a stand-alone spec; it would be great to have a follow-up video that dives into more complex pieces like:

  • Adding a custom devcontainer feature to an app; a real use-case is stubbing out some external system that I need to interact with as another container that I throw into my compose.yml or features file, so that my dev team can do 100% offline development. This is something I face right now; my team just "assumes" certain external systems will work when we move to deploying it, but we often find that it didn't integrate with the live system as well as we thought, b/c we don't have a "running version" in our development environment we can test against. Building out another container that we can make external API calls to and get responses back would be very useful, and then we could store that as an image that other teams could benefit from (so we aren't all re-inventing the wheel).
  • How would you manage multiple Ruby versions at once to test an upgrade (I currently use asdf for Ruby/Node version management)
  • Any other "real world" development items that I'm not thinking of yet :)

Definitely interested in diving deeper into devcontainers and how we can make development better!

Just thinking out loud, but I'm wondering if there is a way to make this work with Podman (like by changing the Docker Path to podman in devcontainer settings). I should probably give it a try.

That would be great to know. Had the same question about OrbStack. 🧐

Very informative lesson, really excited to try this out!

VS Code is not the only option, RubyMine has integration with devcontainers too

Amazing, thanks for sharing!

Good Lesson

At 13:11 we see the devcontainer being viewed in a browser on port 3001, at 13:37 we see the app is listening on port 3000. Is that how the ports map between the laptop and the container?

I have an old rails app that need to update, Rails 4 , ruby 2.2.5, where can I get an image for ruby 2.2.5 or how can I build one?, thanks

You probably have to build it yourself, but the Rails devcontainer repo will let you specify the Ruby version with an env var: https://github.com/rails/devcontainer/blob/main/images/ruby/.devcontainer/devcontainer.json#L19

See also the Devcontainer docs: https://code.visualstudio.com/docs/devcontainers/containers

Join the discussion
Create an account Log in

Want to stay up-to-date with Ruby on Rails?

Join 88,834+ developers who get early access to new tutorials, screencasts, articles, and more.

    We care about the protection of your data. Read our Privacy Policy.