GzRelease

TODO: Write a gem description

Installation

Add this line to your application's Gemfile:

gem 'gz_release'

And then execute:

$ bundle

Or install it yourself as:

$ gem install gz_release

Usage

Rakefile

Add the following to your Rakefile:

require 'gz_release'

GzRelease::Tasks.install(
  image_name: 'gazelle/<PROJECT_NAME>'
)

This gives you a bunch of rake tasks:

rake release:build           # Builds the docker image from generated Dockerfile
rake release:dump            # Dumps docker cache into ~/.docker/image.tar
rake release:load            # Loads ~/.docker/image.tar into docker cache
rake release:pull            # Pulls latest version of the image from dockerhub
rake release:push:branch     # Pushes docker image tagged as current git branch
rake release:push:latest     # Pushes docker image tagged as latest
rake release:push:release    # Pushes docker image tagged as release
rake release:push:timestamp  # Pushes docker image and git tag tagged by the timestamp
rake release:push:version    # Pushes docker image tagged as version specified in Rakefile
rake release:tag:branch      # Creates a tag for the branch for the docker image
rake release:tag:latest      # Creates latest tag for the docker image
rake release:tag:release     # Creates release tag for the docker image
rake release:tag:timestamp   # Creates timestamp tag for the docker image and git repo
rake release:tag:version     # Creates a tag for version specified in Rakefile for docker image

Environment variables

The following evironment variables are required for pushing to a docker repository: DOCKER_USER, DOCKER_EMAIL, DOCKER_PASSWORD. They are the same values you provide when doing docker login. It's best to use an organization account for these values on CircleCI.

Optionally, you can also set DOCKER_REPOSITORY (e.g. tutum.co), which will cause the image to be tagged for and pushed to that repository.

Building on CircleCI

Create the environment variables for your project listed above on CircleCI. You can then have CircleCI build the docker image by creating a circle.yml including the following:

machine:
  services:
    - docker
checkout:
  pre:
    - git config --global user.email "[email protected]"
    - git config --global user.name "Gazelle CircleCI Bot"
deployment:
  all:
    branch: /^(?!(master|dev)).*$/
    commands:
      - bundle exec rake release:build
      - bundle exec rake release:push:branch
  master:
    branch: master
    commands:
      - bundle exec rake release:build
      - bundle exec rake release:push:timestamp
      - bundle exec rake release:push:release
  dev:
    branch: dev
    commands:
      - bundle exec rake release:build
      - bundle exec rake release:push:latest

Contributing

  1. Fork it ( https://github.com/[my-github-username]/gz_release/fork )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request