Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
516 views
in Technique[技术] by (71.8m points)

ruby on rails - How to build a rubygems mirror server?

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?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...