# Lux [![Gem Version](http://img.shields.io/gem/v/lux.svg)][gem] [gem]: https://rubygems.org/gems/lux Shining some light on setting up and running various Docker things. Lux is both a command line tool (based on Thor) and a library of useful routines that can be included in Rake tasks. ## Installation Add this line to your application's Gemfile: ```ruby gem 'lux' ``` And then execute: $ bundle Or install it yourself as: $ gem install lux ## Usage ### Command Line Tool The `lux` command simplifies a number of Docker command line operations and provides unix-style commands for listing and removing images, as well as rake-like tasks for cleaning, tidying and clobbering containers and their images. Type: `lux help` to get started ### Rake Tasks When trying to write Rakefiles that start Docker containers it is useful to have a Rake task that represents a container image. Then you can make other tasks depend on them. If the task (when invoked) checks the local Docker server for the image, and only executes the task body if the image is not found, then you can build Docker dependencies elegantly into the Rakefile. The boilerplate to do this is included in Lux as a Rake Task Generator. Here are some examples: ```ruby require 'lux/dockertasks' # Define a simple task. # The tag will default to 'latest' and the name of the task is 'busybox' DockerImageTask.new('busybox') # Define a task with a tag. # The name of the task is 'ubuntu', the tag is 'trusty' DockerImageTask.new('ubuntu:trusty') # Define a task with a tag and a name. # The name of the task is 'reedy', the image is 'ubuntu' and the tag 'reedy' DockerImageTask.new('ubuntu:reedy', :reedy) # Define a task with a fully qualified image and a block. # The block will be executed if the image is not found locally. # The task object yielded has the image and tag attributes # as well as the usual name and description. DockerImageTask.new('quay.io/rasputin/tools:1.0') do |t| puts "You want me to build the image #{t.image}:#{t.tag}?" fail "Not from here I can't..." end desc "Run Busybox" task :runb => 'busybox' do sh "docker run -it busybox" end desc "Run Ubuntu Trusty" task :runu => :ubuntu do sh "docker run -it ubuntu:trusty /bin/bash" end desc "Run Ubuntu Reedy" task :runr => :reedy do sh "docker run -it ubuntu:reedy /bin/bash" end # Note how the task name does not include the tag desc "Run Tools" task :runt => 'quay.io/rasputin/tools' do sh "docker run -it quay.io/turnitin/seu-tools:1.0 /bin/bash" end ``` ## Development To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release` to create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org). ## Contributing 1. Fork it ( https://github.com/townsen/lux/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