GoogleCloudPlatform / google-cloud-gemserver

CLI to deploy a private gem server to Google App Engine Flex
Apache License 2.0
46 stars 14 forks source link
gcp gemserver ruby

Google::Cloud::Gemserver

Build Status

This gem is a tool that lets you manage, interact with, and deploy a private gem server to a Google Cloud Platform project. The gemserver acts as a private gem repository for your gems similar to how rubygems.org works with the exception that pushing and installing gems are protected operations.

Installation

Add this line to your application's Gemfile:

gem 'google-cloud-gemserver'

And then execute:

$ bundle

Or install it yourself as:

$ gem install google-cloud-gemserver

Usage

Basic Prerequisites

1) Create a Google Cloud Platform (GCP) project. 2) Install and setup the gcloud SDK. Currently, versions 161+ are supported. 3) Authenticate gcloud by using a service account or application default credentials. Using a service account is the recommended method for authentication; application default credentials should only be used for development purporses. Read this authentication guide for more information. 4) Running acceptance or performance tests requires you to have the Cloud SQL proxy running with your Cloud SQL instance. Visit this link to learn how to install and run it (steps 3 and 5 can be skipped).

Typical Workflow

1) Deploy a gemserver by running: google-cloud-gemserver create --use-proj YOUR_PROJECT_ID. This deploys the gemserver in a Google App Engine project as the default service. It also creates a new Cloud SQL instance with machine type db-f1-micro. Note that this machine type is only recommended for development / testing and is not under the Cloud SQL SLA coverage. 2) Generate a key (referred to as my-key) by running google-cloud-gemserver create-key --use-proj YOUR_PROJECT_ID for your gemserver. By default, this generates a key with both read and write permissions. For more information about keys, read this. 3) Add this key to your bundle config by running bundle config http://gemserver-url.com/private/ my-key where gemserver-url is the same as your project's url, e.g. http://my-project.appspot.com/private/. This is necessary to download gems. 4) Add this key to your gem credentials as my-key (in ~/.gem/credentials): :my-key: [KEY] This is necessary to push gems (if the key has write permission). 5) Push private gems to the gemserver as described below. 6) Download private gems by modifying your Gemfile as described below.

Pushing gems

Note: ensure my-key has the read permission and is added in your gem credentials file (~/.gem/credentials) gem push my-gem --key my-key --host http://my-gemserver.com/private/

Fetching gems

Note: ensure my-key has the read permission and is set in your bundle config by running bundle config http://my-gemserver.com/private/ my-key

1) Add source "http://my-gemserver.com" to the top of your Gemfile 2) Add the following to your Gemfile:

      source "http://my-gemserver.com/private" do
        gem "my-private-gem1"
        (other private gems here)
      end

3) Run bundle install

Yanking gems

Note: ensure my-key has the write permission and is added in your gem credentials file (~/.gem/credentials) gem push my-gem --key my-key --host http://my-gemserver.com/private/

1) Run gem yank --key my-key [GEM_NAME] --host http://my-gemserver.com/private

Gems can not be "unyanked" so once a gem has been yanked it cannot be pushed to the gemserver again with the same name and version. It can be pushed if the version number is changed, however.

Gemserver commands

More documentation can be found in the docs directory.

Contributing

Detailed information can be found in CONTRIBUTING.md.