This article was originally posted on Jul 8th 2016 at: https://nickjanetakis.com/blog/dockerize-a-rails-5-postgres-redis-sidekiq-action-cable-app-w...
For further actions, you may consider blocking this person and/or reporting abuse
All my projects are docker based. As much as I love using it, i hate the extra commands you need to run for trivial stuffs like starting a rails server, console or migrations.
I usually keep those scripts in
bin/
folder and simply execute the file. This way its much more straightforward and can be documented in README file for new devs.How do you feel about this approach?
Hi,
In that case I would ditch the scripts and just set up a few aliases at the Bash level. This way you can shorten up the command to almost what it would be without Docker, and you don't need to lug around scripts to each project.
I have some made to where I just type
dew rails c
and it opens a console by runningdocker-compose exec web rails c
under the hood.I agree but that still does not help much when you have some inexperienced developers in team.
Then make them experienced. :D
I agree with you.
Aliases are ok but I would prefer something that doesn't leak outside of the project.
So bin/ folder is better option IMHO.
I'm hoping to be completely reliant on docker as my sole development environment across my machines but I feel it's much slower than running ruby/rails natively. Did I make a mistake or is this slower performance expected?
Hi. What OS / version are you using and how exactly did you install Docker? On my 4 year old i5 3.2ghz Windows 10 box with an SSD a 10,000+ line Dockerized Rails project with 50+ top level gems detects and reloads code changes in under 100ms (faster than I can manually dart my eyes over to my browser and reload). Assets are a little bit slower to compile but it's definitely not disruptive.
There is nothing special about my set up. It's just stock Windows 10 pro (Fall 2017 update) using WSL (Ubuntu) and Docker for Windows (18.03).
MacOS High Sierra 10.13.4. I installed Docker via Docker CE 18.03.0. If I start up a server with docker, initial loading of localhost:300 takes 92 seconds!
My native rails/postgre initial load takes 21 seconds.
Just
WORKDIR /app
, since 2015WORKDIR
directive creates a dir if it does not existCMD uses
execvpe
sys-call so it's better to pass arguments as a listThanks. I meant to change that so long ago (removing mkdir). Old habits die hard!
In the next orats release I'll update the Dockerfile and this post to reflect both changes.
You rock! Thanks for this tutorial !
Nice thorough post Nick. @maestromac might be a good read.
I can see!
Phew, that's a thorough tutorial! Nice article!