Atoms

These are a collection of small thoughts or ideas that don't (yet) merit a larger post.

2024-12-30

  • Mount a gem into a docker container with path/on/disk/gemdir:/app/path/vendor/gems/my_gem and then set your Gemfile to gem "my_gem", path: "vendor/gems/my_gem".
  • Make this less irritating to manage when committing by adding a method for your Gemfile, e.g.:
def local_gem_exists?(name)
  File.directory?("vendor/gems/#{name}")
end

def maybe_local_gem(name, env: ENV.fetch("RACK_ENV", production), **opts)
  return gem name, **opts if env == "production" || !local_gem_exists?
  
  gem name, opts.merge(path: "vendor/gems/#{name}")
end

# and use like:

maybe_local_gem "my_gem" # if you've mounted the gem, loads from path, otherwise declares remote gem
  • You could also consider overriding gem().