Edgars Jekabsons
Edgars Jekabsons

Reputation: 2853

Docker as the effective Rails development environment

[UPDATE]

Unfortunately, dear colleagues, I gave up on docker for now. Main factors:

Also we hired two DevOps guys, who have quite a bit of docker experience, if they will come up, how to (painlessly!) introduce docker in our company for both hosting and development, I will be happy to revise this topic.


[OLD POST]

As a new version utilising native OSX hypervisor is now available, I've decided to try pushing all my Ruby/Rails/JS development to the docker containers. I've played quite a bit on a fresh El Capitan installation, by trying to dockerize a few private gems we have and our monolith Rails application.

There are a few questions, I was hoping our community may help to solve.

The goal - everything works and host has only iTerm, git, Sublime, SourceTree and Docker installed (nothing is carved in stone, if some additional dependency(-ies) may improve/make the workflow significantly easier, I will be happy to review the options)

Requirements

Questions

Other thoughts

I am also fine trying out commercial or none-commercial tool, that wraps/bundles the described tooling. So far I've found a thing called http://wercker.com), the thing I don't like about it, it seems like it requires you to setup dev env anyways, which kill the purpose of the whole endeavour.

Feel free to down vote this question if it was posted before and answered clearly. On the other hand I would be happy if this thread will produce guides, links, suggestions to get it done smoothly, I am pretty sure this interests quite a few devs these days.

Upvotes: 17

Views: 642

Answers (2)

davetapley
davetapley

Reputation: 17908

Consider orats (opinionated rails application templates):

The goal is to provide you an excellent base application that you can use on your next Rails project.

And:

It also happens to use Docker so that your app can be ran on any major platform -- even without needing Ruby installed.


To some of your other requirements:

  • my keys ... I should be able to reuse the ones that are on my host machine

    Specify keys in your docker-compose.yml but omit the value.

  • putting breakpoints and interacting with debugger

    When starting a service, instead of docker-compose up, use docker-compose run --service-ports. This will allow e.g. binding.pry to work.

  • When executing Cucumber/Selenium tests I should be able to see what's happening in the browsers.

    This is tricky. For a workaround consider using save_screenshot, and (the important part) save it to a directory which is mounted to a volume on the Docker host. Open that directory on the host and you'll be able to see an updating screenshot.

Upvotes: 3

gayavat
gayavat

Reputation: 19398

some notes about usage docker for development:

  • run bash command inside docker and to work as in VM, link
  • map port of container with host machine and use browser link
  • map files link
  • .env technique of setting variables allows usage of docker in any environment including CI link
  • bash scripts and container naming can help to automate tasks link

Upvotes: 0

Related Questions