Dockerizing a Ruby on Rails Application
semaphoreci.com
semaphoreci.com
COPY drkiq/Gemfile Gemfile
WORKDIR /opt/app/drkiq
RUN bundle install
This appears to be leaving out copying Gemfile.lock so you have no real idea what versions of dependencies are being installed here. This is not safe. Also it's installing a bunch of dependencies that are not needed in production, a better bundle command would be something like: `RUN bundle install --no-cache --jobs 4 --without development test` RUN rails webpacker:install
RUN rails assets:precompile
Why is `rails webpacker:install` being run here? This is very odd. As a general tip, I would also not compile assets as part of the docker build, but rather externally then only copy over the `public` directory afterward. This removes any need for `node` or any related development tools/packages in the production image.This also means the same exact environment is used to generate the production assets that was used to generate them for test.
As someone who's only touched Ruby for a few years (and not even Ruby on Rails): I wouldn't have even known to look for a Gemfile.lock.
Perhaps the author doesn't know either.
Well... Gemfile.lock has nothing to do with rails and all to do with Bundler, but if you've never used Bundler for dependency management it's possible that it's new to you.
But Bundler (and the Gemfile and Gemfile.lock) are one of the core components of rails, they even get mentioned in the getting started page (https://guides.rubyonrails.org/getting_started.html).
I only have a couple of years of experience with rails and haven't touched it in 6 years, but I'd be very sceptical of any article that tries to teach how to build projects in rails and doesn't even get those basics right.
gem 'byebug', '1.1.0'
I've been using Rails for years, I haven't yet experienced much pain by way of language/library versioning (etc). Python is a different story...
I've investigated it a few times for several Rails applications that I maintain, but I've never completed a rollout. Running Rails on Docker isn't a huge hurdle, but Capistrano's default git-based deploys are just so _easy and fast_ once the server is set up. I also have to balance deploying Docker with ops' expertise.
I do recommend getting a copy of _Docker for Rails Developers_ to avoid needing to read a bunch of disparate blogs, though it covers Docker Swarm instead of Kubernetes.
[1] https://www.amazon.com/Docker-Rails-Developers-Applications-...
I guess an obvious one is to use two running images, pull incoming requests from one of them, take it down, update, bring it up, start traffic flow again. Repeat for the other.
But is there any other method?
When it comes to deploy, just repoint your load balancer/proxy.