Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to build a rubygems mirror server?

Tags:

My workplace has banned us from internet access so we can't connect to rubygems.org to install gems remotely.

I can access rubygems.org at home. Is there a simple way to enable me download and update the gems we need at home ,then sync them(by a portable hard disk or somthing) to a local gems mirror server at my workplace so that other colleagues can install gems from that mirror server?

like image 470
TomCaps Avatar asked Dec 07 '11 06:12

TomCaps


People also ask

Where are RubyGems hosted?

Our infrastructure is currently hosted on AWS. Some insights into the technical aspects of the site: It's 100% Ruby. The main site is a Rails application. Gems are hosted on Amazon S3, served by Fastly, and the time between publishing a new gem and having it ready for installation is usually just a few seconds.

What is a gem server?

RubyGems is a package manager for the Ruby programming language that provides a standard format for distributing Ruby programs and libraries (in a self-contained format called a "gem"), a tool designed to easily manage the installation of gems, and a server for distributing them.

Does RubyGems come with Ruby?

Ruby comes with RubyGems by default since version 1.9, previous Ruby versions require RubyGems to be installed by hand.

How do I publish a gem to RubyGems?

Publishing to RubyGems.orgVisit the sign up page and supply an email address that you control, a handle (username) and a password. After creating the account, use your email and password when pushing the gem. (RubyGems saves the credentials in ~/. gem/credentials for you so you only need to log in once.)


1 Answers

You can use rubygems-mirror to mirror the gems and Gem in a box to host them.

Install rubygems-mirror:

$ gem install rubygems-mirror 

Edit ~/.gem/.mirrorrc:

--- - from: http://rubygems.org   to: ~/.gem/mirror 

Create mirror dir:

$ mkdir ~/.gem/mirror 

Start mirroring:

$ gem mirror 

Once mirroring finishes edit ~/.gem/mirror/config.ru:

require "rubygems" require "geminabox"  Geminabox.data = "./" run Geminabox 

Install Gem in a box:

$ gem install geminabox 

Start gem server:

$ cd ~/.gem/mirror $ rackup 

Edit your application's Gemfile to use your gem server:

source "http://your.servers.ip:9292" . 

Or add it as a local mirror for rubygems.org, so you don't have to change your Gemfile:

$ bundle config mirror.https://rubygems.org https://localgems.lan $ bundle config mirror.http://rubygems.org http://localgems.lan 

From time to time reindex your mirror:

$ gem generate_index --directory ~/.gem/mirror 
like image 196
panupan Avatar answered Nov 12 '22 11:11

panupan