Scripts to create a Private Ruby Gem Server using AWS S3
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.

S3-based Gem Server

This script and Docker imager uploads gems to S3 and creates files which make it usable as Gem Server.

Docker Automated build

How to use in a CI/CD pipeline

1. Test your gem

(out of scope here)

2. Package your gem

(out of scope here)

3. Upload your gem

$ docker run --rm -v $(pwd):/workdir -e "AWS_ACCESS_KEY_ID=$AWS_ACCESS_KEY_ID" -e "AWS_SECRET_ACCESS_KEY=$AWS_SECRET_ACCESS_KEY" -e "AWS_BUCKET=$AWS_BUCKET" tmaier/s3-gemserver upload

4. Update index of Gem Server

$ docker run --rm -e "AWS_ACCESS_KEY_ID=$AWS_ACCESS_KEY_ID" -e "AWS_SECRET_ACCESS_KEY=$AWS_SECRET_ACCESS_KEY" -e "AWS_BUCKET=$AWS_BUCKET" tmaier/s3-gemserver update_index

5. Use with Bundler (aka "the vision")

This is the general idea. Rubygems supports S3, but Bundler is not there yet. See for details.

Set source to S3 bucket in Gemfile.

source 's3://my_bucket'

gem 'my_secret_gem'

Set access key and secret key using Bundler.

$ bundle config my_bucket $AWS_ACCESS_KEY_ID:$AWS_SECRET_ACCESS_KEY

6. Interim solution

  • Create a secret directory on your bucket
  • Set the path at $AWS_DIRECTORY and upload the gems to that folder
  • Set the source URL and path in the Gemfile

Environment variables



Following blog posts influenced this script and Dockerfile.


Tobias L. Maier for BauCloud GmbH