docker-spoon 0.0.1 → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- spoon (0.0.1)
4
+ docker-spoon (0.1.0)
5
5
  docker-api (~> 1.11)
6
6
  methadone (~> 1.4.0)
7
7
 
@@ -50,6 +50,6 @@ PLATFORMS
50
50
  DEPENDENCIES
51
51
  aruba
52
52
  bundler (~> 1.6)
53
+ docker-spoon!
53
54
  rake (~> 0.9.2)
54
55
  rdoc
55
- spoon!
data/README.md CHANGED
@@ -1,17 +1,160 @@
1
- # Spoon
1
+ # docker-spoon
2
2
 
3
- Spoon with another developer using Docker & tmux. This is being ported
4
- from another project and is functionaly incomplete right now
3
+ ## Overview
4
+ Spoon creates on demand pairing environments using Docker.
5
+
6
+ We pair a lot using tmux & emacs / vim and wanted a way to create
7
+ pairing environments which met a few criteria:
8
+
9
+ - Would contain all the updates folks have contributed to the dev setup
10
+ - Can be created on-demand as needed instead of having dedicated pairing
11
+ environments and asking who's using what
12
+ - Are console based to enable low latency remote pairing
13
+
14
+ Spoon is intended to make this process as easy as possible.
15
+
16
+ #### Why Spoon?
17
+ [Learn more about spooning](https://www.youtube.com/watch?v=dYBjVTMUQY0)
18
+
19
+ In the mean time - [learn more about spooning](https://www.youtube.com/watch?v=dYBjVTMUQY0)
5
20
 
6
21
  ## Installation
7
22
 
8
23
  ```
9
- $ gem install spoon
24
+ $ gem install docker-spoon
10
25
  ```
11
26
 
27
+ ## Configuration
28
+
29
+ Spoon has a number of options which you probably do not want to have to
30
+ specify on the command line every time. The easiest way to set these for
31
+ your environment is to add them to `~/.spoonrc`. This file is just
32
+ parsed as ruby, so you can put all kinds of stuff in here, but the
33
+ basics should look something like this:
34
+
35
+ ```ruby
36
+ options[:url] = "tcp://192.168.1.3:4243"
37
+ options[:image] = 'spoon-pairing'
38
+ options["pre-build-commands"] = [
39
+ "cp -rp #{ENV['HOME']}/.chef #{options[:builddir]}/chef"
40
+ ]
41
+ ```
42
+
43
+ All of the `options[]` parameters should map directly to the long form
44
+ of options on the command line. They may be defined as either the
45
+ `:symbol` form or as a string. The limitation is that ruby doesn't
46
+ permit a dash in symbols, so when an option has a dash in it, it must be
47
+ specified as a string.
48
+
49
+ You may also specify a different config file with the `--config`
50
+ argument.
51
+
12
52
  ## Usage
13
53
 
14
- Coming soon
54
+ Spoon has 4 major operations it can perform:
55
+
56
+ - Connect/Create, Connect to an existing spoon container or create a new
57
+ container
58
+ - List, List existing containers
59
+ - Build, Build an image for use as a spoon container
60
+ - Destroy, Destroy an existing spoon container
61
+
62
+ ### Connect/Create
63
+
64
+ By default when you call spoon with no options it will try to connect to
65
+ the spoon container that you specify. If that container doesn't exist,
66
+ spoon will create it for you. Once spoon either creates a container or
67
+ determines that one already exists it will start an ssh connection to
68
+ the host. This will shell out to ssh and should honor your ssh
69
+ configuration locally.
70
+
71
+ Example (container doesn't exist):
72
+ ```shell
73
+ $ spoon fortesting
74
+ The `spoon-fortesting` container doesn't exist, creating...
75
+ Connecting to `spoon-fortesting`
76
+ pairing@dockerhost's password:
77
+ ```
78
+
79
+ Example (container exists):
80
+ ```shell
81
+ $ spoon fortesting
82
+ Connecting to `spoon-fortesting`
83
+ pairing@dockerhost's password:
84
+ ```
85
+
86
+ #### Options
87
+
88
+ - `--url`, The url of the Docker API endpoint. This is in the format
89
+ supported by the docker -H option. This will also read from the
90
+ environment variable `DOCKER_HOST` if this argument is not specified
91
+ and that env var exists.
92
+ - `--image`, The image name to use when starting a spoon container.
93
+ - `--prefix`, The prefix to use for creating, listing & destroying
94
+ containers.
95
+
96
+ ### List
97
+
98
+ The `--list` argument will list any containers on the destination Docker
99
+ host which have the same prefix as specified by `--prefix` (default
100
+ 'spoon-'). Images are listed without the prefix specified so that you
101
+ can see only the containers you are interested in.
102
+
103
+ ```shell
104
+ $ spoon -l
105
+ List of available spoon containers:
106
+ fortesting
107
+ ```
108
+
109
+ ### Destroy
110
+
111
+ The `--destroy NAME` option will destroy the specified spoon container.
112
+
113
+ ```shell
114
+ $ spoon -d fortesting
115
+ Destroying spoon-fortesting
116
+ Done!
117
+ ```
118
+
119
+ ### Build
120
+
121
+ The `--build` option will build a docker image from the build directory
122
+ specified by `--builddir` (default '.'). This has the same expectations
123
+ as the [docker
124
+ build](https://docs.docker.com/reference/commandline/cli/#build)
125
+ command.
126
+
127
+ #### Options
128
+
129
+ - `--builddir`, This is the directory where the build process will look
130
+ for a Dockerfile and any content added to the container using `ADD`.
131
+
132
+ - `--pre-build-commands`, This is a list of commands to run before
133
+ actually kicking off the build process (see below).
134
+
135
+ pre-build-commands:
136
+
137
+ Because docker-spoon is special, we also support running some
138
+ commands in advance of the build process. This allows for things like
139
+ copying stuff into the container which you don't want to have committed
140
+ to the repository. An example of this is that in our environment we need
141
+ chef credentials inside of our container & we use this mechanism to copy
142
+ those credentials into the builddir at build time without adding them to
143
+ our repository containing the Dockerfile.
144
+
145
+ Here's an example of how we copy our chef configuration into place:
146
+ ```ruby
147
+ options["pre-build-commands"] = [
148
+ "cp -rp #{ENV['HOME']}/.chef #{options[:builddir]}/chef"
149
+ ]
150
+ ```
151
+
152
+ #### Container expectations
153
+
154
+ When building a container for use with docker-spoon you must build a
155
+ container which runs an ssh daemon. An example of a Dockerfile which
156
+ creates a container which runs ssh is included in the `docker/`
157
+ directory inside this repository
15
158
 
16
159
  ## Contributing
17
160
 
@@ -20,3 +163,4 @@ Coming soon
20
163
  3. Commit your changes (`git commit -am 'Add some feature'`)
21
164
  4. Push to the branch (`git push origin my-new-feature`)
22
165
  5. Create a new Pull Request
166
+
data/lib/spoon.rb CHANGED
@@ -12,11 +12,11 @@ module Spoon
12
12
 
13
13
  main do |instance|
14
14
  parse_config(options[:config])
15
- pp options
15
+ D options.inspect
16
16
  if options[:list]
17
17
  instance_list
18
- elsif options["list-containers"]
19
- # container_list
18
+ elsif options["list-images"]
19
+ image_list
20
20
  elsif options[:build]
21
21
  image_build
22
22
  elsif options[:destroy]
@@ -37,10 +37,12 @@ module Spoon
37
37
  on("-b", "--build", "Build image from Dockerfile using name passed to --image")
38
38
 
39
39
  # Configurables
40
- on("--builddir", "Directory containing Dockerfile")
40
+ options[:builddir] = '.'
41
+ on("--builddir DIR", "Directory containing Dockerfile")
41
42
  on("--pre-build-commands", "List of commands to run locally before building image")
43
+ options[:url] = Docker.url
42
44
  on("-u", "--url URL", "Docker url to connect to")
43
- on("-L", "--list-containers", "List available spoon container images")
45
+ on("-L", "--list-images", "List available spoon images")
44
46
  options[:image] = "spoon-pairing"
45
47
  on("-i", "--image NAME", "Use image for spoon instance")
46
48
  options[:prefix] = 'spoon-'
@@ -77,12 +79,21 @@ module Spoon
77
79
  end
78
80
  D "pre-build commands complete, building Docker image"
79
81
 
82
+ docker_url
80
83
  build_opts = { 't' => options[:image], 'rm' => true }
81
- Docker::Image.build_from_dir(options[:build], build_opts) do |chunk|
84
+ Docker::Image.build_from_dir(options[:builddir], build_opts) do |chunk|
82
85
  print_docker_response(chunk)
83
86
  end
84
87
  end
85
88
 
89
+ def self.image_list
90
+ docker_url
91
+ Docker::Image.all.each do |image|
92
+ next if image.info["RepoTags"] == ["<none>:<none>"]
93
+ puts "Image: #{image.info["RepoTags"]}"
94
+ end
95
+ end
96
+
86
97
  def self.print_parsed_response(response)
87
98
  case response
88
99
  when Hash
@@ -130,7 +141,6 @@ module Spoon
130
141
 
131
142
  def self.instance_destroy(name)
132
143
  docker_url
133
- puts "destroy: #{name}"
134
144
  container = get_container(name)
135
145
 
136
146
  if container
data/lib/spoon/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Spoon
2
- VERSION = "0.0.1"
2
+ VERSION = "0.1.0"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: docker-spoon
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.1.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-06-23 00:00:00.000000000 Z
12
+ date: 2014-06-28 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler
@@ -136,7 +136,6 @@ files:
136
136
  - Gemfile.lock
137
137
  - LICENSE.txt
138
138
  - README.md
139
- - README.rdoc
140
139
  - Rakefile
141
140
  - bin/spoon
142
141
  - docker/Dockerfile
data/README.rdoc DELETED
@@ -1,19 +0,0 @@
1
- = spoon - DESCRIBE YOUR GEM
2
-
3
- Author:: YOUR NAME (YOUR EMAIL)
4
- Copyright:: Copyright (c) 2014 YOUR NAME
5
-
6
-
7
- DESCRIBE YOUR GEM HERE
8
-
9
- == Links
10
-
11
- * {Source on Github}[LINK TO GITHUB]
12
- * RDoc[LINK TO RDOC.INFO]
13
-
14
- == Install
15
-
16
- == Examples
17
-
18
- == Contributing
19
-