gcs-cacher

command module
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 28, 2020 License: Apache-2.0 Imports: 6 Imported by: 0

README

GCS Cacher

GoDoc GitHub Actions

GCS Cacher is a small CLI and Docker container that saves and restores caches on Google Cloud Storage. It is intended to be used in CI/CD systems like Cloud Build, but may have applications elsewhere.

Usage

  1. Create a cache:

    gcs-cacher -bucket "my-bucket" -cache "go-mod" -dir "$GOPATH/pkg/mod"
    

    This will compress and upload the contents at pkg/mod to Google Cloud Storage at the key "go-mod".

  2. Restore a cache:

    gcs-cacher -bucket "my-bucket" -restore "go-mod" -dir "$GOPATH/pkg/mod"
    

    This will download the Google Cloud Storage object named "go-mod" and decompress it to pkg/mod.

Installation

Choose from one of the following:

  • Download the latest version from the releases.

  • Use a pre-built Docker container:

    us-docker.pkg.dev/vargolabs/gcs-cacher/gcs-cacher
    docker.pkg.github.com/sethvargo/gcs-cacher/gcs-cacher
    

Implementation

When saving the cache, the provided directory is made into a tarball, then gzipped, then uploaded to Google Cloud Storage. When restoring the cache, the reverse happens.

It's strongly recommend that you use a cache key based on your dependency file, and restore up the chain. For example:

gcs-cacher \
  -bucket "my-bucket" \
  -cache "ruby-$(gcs-cacher -hash Gemfile.lock)"
gcs-cacher \
  -bucket "my-bucket" \
  -restore "ruby-$(gcs-cacher -hash Gemfile.lock)"
  -restore "ruby-"

This will maximize cache hits.

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis
Package cacher defines utilities for saving and restoring caches from Google Cloud storage.
Package cacher defines utilities for saving and restoring caches from Google Cloud storage.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL