docker-spoon 0.8.0 → 1.0.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.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/.rspec +2 -0
- data/Gemfile.lock +5 -8
- data/README.md +112 -112
- data/README_config.md +248 -0
- data/Rakefile +7 -17
- data/bin/spoon +0 -2
- data/docker-spoon.gemspec +1 -2
- data/features/build.feature +49 -0
- data/features/create_list_destroy.feature +81 -0
- data/features/debug.feature +25 -0
- data/features/docker_host_env.feature +24 -0
- data/features/help.feature +67 -0
- data/features/list-images.feature +17 -0
- data/features/portforwards.feature +94 -0
- data/features/ports.feature +126 -0
- data/features/privileged_mode.feature +55 -0
- data/features/step_definitions/spoon_steps.rb +0 -1
- data/features/support/env.rb +24 -1
- data/lib/spoon.rb +461 -304
- data/lib/spoon/version.rb +1 -1
- data/spec/spec_helper.rb +17 -0
- data/spec/template_spec.rb +20 -0
- metadata +28 -22
- data/features/spoon.feature +0 -24
- data/test/tc_something.rb +0 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 033dbf20fbef7f0928d4ecf21632ec43ec3a5442
|
4
|
+
data.tar.gz: 6768b4fd3b7283562cb1b77be7a360459fb5fe8a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f9f30ba5548d9a2b09497028b6325f2ba863559f42fe2c01dc3ee2710e95e2ef33da7c13bcb0811d1a7fe8a1c431d579caa3f6a05e67a9dac2abfcc148a0ddae
|
7
|
+
data.tar.gz: 350108d5bb47fc7ebc6ae54855167117999ebee2d2972b5c601682213ba38f2e255480b468ae14d5b5066c129d81a7c2c795592d92af1cf3ef40636be92a93de
|
data/.gitignore
CHANGED
data/.rspec
ADDED
data/Gemfile.lock
CHANGED
@@ -1,9 +1,8 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
docker-spoon (0.
|
5
|
-
docker-api (~> 1.
|
6
|
-
methadone (~> 1.4.0)
|
4
|
+
docker-spoon (1.0.0)
|
5
|
+
docker-api (~> 1.17.0)
|
7
6
|
rainbow (~> 2.0)
|
8
7
|
|
9
8
|
GEM
|
@@ -24,22 +23,20 @@ GEM
|
|
24
23
|
multi_json (>= 1.7.5, < 2.0)
|
25
24
|
multi_test (>= 0.1.1)
|
26
25
|
diff-lcs (1.2.5)
|
27
|
-
docker-api (1.
|
26
|
+
docker-api (1.17.0)
|
28
27
|
archive-tar-minitar
|
29
28
|
excon (>= 0.38.0)
|
30
29
|
json
|
31
|
-
excon (0.
|
30
|
+
excon (0.42.1)
|
32
31
|
ffi (1.9.6)
|
33
32
|
gherkin (2.12.2)
|
34
33
|
multi_json (~> 1.3)
|
35
34
|
json (1.8.1)
|
36
|
-
methadone (1.4.0)
|
37
|
-
bundler
|
38
35
|
multi_json (1.10.1)
|
39
36
|
multi_test (0.1.1)
|
40
37
|
rainbow (2.0.0)
|
41
38
|
rake (0.9.6)
|
42
|
-
rdoc (4.
|
39
|
+
rdoc (4.2.0)
|
43
40
|
json (~> 1.4)
|
44
41
|
rspec-expectations (3.1.2)
|
45
42
|
diff-lcs (>= 1.2.0, < 2.0)
|
data/README.md
CHANGED
@@ -16,13 +16,19 @@ Spoon is intended to make this process as easy as possible.
|
|
16
16
|
#### Why Spoon?
|
17
17
|
[Learn more about spooning](https://www.youtube.com/watch?v=dYBjVTMUQY0)
|
18
18
|
|
19
|
-
|
19
|
+
|
20
|
+
## Getting Started
|
21
|
+
These are the basics of how to get started. When you want to get into
|
22
|
+
more detail see the [full usage](#full-usage) documentation.
|
23
|
+
|
24
|
+
### Installation
|
20
25
|
|
21
26
|
```
|
22
27
|
$ gem install docker-spoon
|
23
28
|
```
|
29
|
+
(NOTE: if installing on Ubuntu this requires the installation of ruby-dev)
|
24
30
|
|
25
|
-
|
31
|
+
### Configuration
|
26
32
|
|
27
33
|
Spoon has a number of options which you probably do not want to have to
|
28
34
|
specify on the command line every time. The easiest way to set these for
|
@@ -38,27 +44,41 @@ options["pre-build-commands"] = [
|
|
38
44
|
]
|
39
45
|
```
|
40
46
|
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
47
|
+
The spoon configuration is described in more detail in the [spoon config
|
48
|
+
page](README_config.md)
|
49
|
+
|
50
|
+
### Building a compatible image
|
51
|
+
|
52
|
+
The spoon repository contains a functional spoon image. To build that just follow these steps:
|
53
|
+
|
54
|
+
```
|
55
|
+
git clone git@github.com:adnichols/docker-spoon.git
|
56
|
+
cd docker-spoon/docker
|
57
|
+
spoon -b
|
58
|
+
```
|
59
|
+
|
60
|
+
This creates an image that matches the default image name for spoon. If
|
61
|
+
you specify a different image name in the configuration then that will
|
62
|
+
be used when spoon builds an image.
|
46
63
|
|
47
|
-
|
48
|
-
argument.
|
64
|
+
## Full Usage
|
49
65
|
|
50
|
-
|
66
|
+
Spoon has a number of operations it can perform:
|
51
67
|
|
52
|
-
|
68
|
+
- [Create and Connect](#create-and-connect) to containers
|
69
|
+
- [List](#list) existing containers
|
70
|
+
- [List Images](#list-images) on the Docker host
|
71
|
+
- [Network](#network) to show a containers network configuration
|
72
|
+
- [Destroy](#destroy) a container
|
73
|
+
- [Kill](#kill) containers
|
74
|
+
- [Restart](#restart) containers
|
75
|
+
- [Build](#build) an image from a Dockerfile for use with spoon
|
53
76
|
|
54
|
-
|
55
|
-
|
56
|
-
-
|
57
|
-
- Network, Show ports forwarded to existing containers
|
58
|
-
- Build, Build an image for use as a spoon container
|
59
|
-
- Destroy, Destroy an existing spoon container
|
77
|
+
In addition to these operations there are configuration values which are
|
78
|
+
supported on the command line or in the configuration file. See [Command
|
79
|
+
Line Options](#command-line-options) for a list of tunables
|
60
80
|
|
61
|
-
### Connect
|
81
|
+
### Create and Connect
|
62
82
|
|
63
83
|
By default when you call spoon with no options it will try to connect to
|
64
84
|
the spoon container that you specify. If that container doesn't exist,
|
@@ -68,7 +88,7 @@ the host. This will shell out to ssh and should honor your ssh
|
|
68
88
|
configuration locally.
|
69
89
|
|
70
90
|
Example (container doesn't exist):
|
71
|
-
```
|
91
|
+
```
|
72
92
|
$ spoon fortesting
|
73
93
|
The `spoon-fortesting` container doesn't exist, creating...
|
74
94
|
Connecting to `spoon-fortesting`
|
@@ -76,30 +96,14 @@ pairing@dockerhost's password:
|
|
76
96
|
```
|
77
97
|
|
78
98
|
Example (container exists):
|
79
|
-
```
|
99
|
+
```
|
80
100
|
$ spoon fortesting
|
81
101
|
Connecting to `spoon-fortesting`
|
82
102
|
pairing@dockerhost's password:
|
83
103
|
```
|
84
104
|
|
85
|
-
NOTE: If a container has been stopped
|
86
|
-
|
87
|
-
in.
|
88
|
-
|
89
|
-
#### Options
|
90
|
-
|
91
|
-
- `--url`, The url of the Docker API endpoint. This is in the format
|
92
|
-
supported by the docker -H option. This will also read from the
|
93
|
-
environment variable `DOCKER_HOST` if this argument is not specified
|
94
|
-
and that env var exists.
|
95
|
-
- `--image`, The image name to use when starting a spoon container.
|
96
|
-
- `--prefix`, The prefix to use for creating, listing & destroying
|
97
|
-
containers.
|
98
|
-
- `--portforwards`, This is a space separated list of ports to forward
|
99
|
-
over ssh. The format is either `sourceport:destport` or just `sourceport`
|
100
|
-
in which case the same port will be used for source & destination.
|
101
|
-
Multiple port forwards may be separated by spaces, for exampe
|
102
|
-
`--portforwards '8080 8081:9090'`
|
105
|
+
NOTE: If a container has been stopped or killed, spoon will issue a
|
106
|
+
start to the container & then attempt to ssh in.
|
103
107
|
|
104
108
|
### List
|
105
109
|
|
@@ -119,21 +123,18 @@ List of available spoon containers:
|
|
119
123
|
You can connect to Stopped containers in the same way as Running
|
120
124
|
containers, spoon will re-start them as necessary.
|
121
125
|
|
122
|
-
###
|
126
|
+
### List Images
|
123
127
|
|
124
|
-
The `--
|
128
|
+
The `--list-images` argument is conventient for listing the images available
|
129
|
+
on the server. The image names should be exactly what you would use in the
|
130
|
+
`options[:image]` configuration value.
|
125
131
|
|
126
|
-
```
|
127
|
-
$ spoon -
|
128
|
-
|
129
|
-
Destroying spoon-fortesting
|
130
|
-
Done!
|
132
|
+
```
|
133
|
+
$ spoon --list-images
|
134
|
+
Image: ["spoon_test:latest"]
|
131
135
|
```
|
132
136
|
|
133
|
-
To
|
134
|
-
|
135
|
-
* add `-f` or `--force` to the command-line
|
136
|
-
* add `options[:force] = true` to your `.spoonrc`.
|
137
|
+
To use this image you would set `options[:image] = 'spoon_test'`
|
137
138
|
|
138
139
|
### Network
|
139
140
|
|
@@ -148,79 +149,77 @@ $ spoon -n jake
|
|
148
149
|
22 -> 49213
|
149
150
|
```
|
150
151
|
|
151
|
-
###
|
152
|
+
### Destroy
|
152
153
|
|
153
|
-
The `--
|
154
|
-
specified by `--builddir` (default '.'). This has the same expectations
|
155
|
-
as the [docker
|
156
|
-
build](https://docs.docker.com/reference/commandline/cli/#build)
|
157
|
-
command.
|
154
|
+
The `--destroy NAME` option will destroy the specified spoon container.
|
158
155
|
|
159
|
-
|
156
|
+
```shell
|
157
|
+
$ spoon -d fortesting
|
158
|
+
Are you sure you want to destroy spoon-fortesting? (y/n) y
|
159
|
+
Destroying spoon-fortesting
|
160
|
+
Done!
|
161
|
+
```
|
160
162
|
|
161
|
-
|
162
|
-
for a Dockerfile and any content added to the container using `ADD`.
|
163
|
+
To skip any confirmations:
|
163
164
|
|
164
|
-
|
165
|
-
|
165
|
+
* add `--force` to the command-line
|
166
|
+
* add `options[:force] = true` to your `.spoonrc`.
|
166
167
|
|
167
|
-
|
168
|
+
### Kill
|
168
169
|
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
to
|
173
|
-
chef credentials inside of our container & we use this mechanism to copy
|
174
|
-
those credentials into the builddir at build time without adding them to
|
175
|
-
our repository containing the Dockerfile.
|
170
|
+
The `--kill NAME` option will kill a spoon container without destroying
|
171
|
+
it. This is useful if you want to leave a container around but not in
|
172
|
+
use for a period of time. Containers may be started again simply by
|
173
|
+
connecting to them.
|
176
174
|
|
177
|
-
|
178
|
-
```ruby
|
179
|
-
options["pre-build-commands"] = [
|
180
|
-
"cp -rp #{ENV['HOME']}/.chef #{options[:builddir]}/chef"
|
181
|
-
]
|
182
|
-
```
|
175
|
+
### Restart
|
183
176
|
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
useful if you want to copy in place configs that you keep on your
|
188
|
-
workstation but don't want them as part of the image.
|
177
|
+
The `--restart NAME` option will kill and then start a container. This
|
178
|
+
is useful if you have a container which has gotten into a bad state or
|
179
|
+
where you've started processes you simply want to easily kill off.
|
189
180
|
|
190
|
-
|
191
|
-
```
|
192
|
-
options[:copy_on_create] = [
|
193
|
-
".gitconfig",
|
194
|
-
".ssh",
|
195
|
-
".ssh/config"
|
196
|
-
]
|
197
|
-
```
|
198
|
-
NOTE: this does not create any required parent directories on the
|
199
|
-
destination system unless they are copied into place, for example like
|
200
|
-
the .ssh directory in the example above.
|
181
|
+
### Build
|
201
182
|
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
183
|
+
The `--build` option will build a docker image from the build directory
|
184
|
+
specified by `--builddir` (default '.'). This has the same expectations
|
185
|
+
as the [docker
|
186
|
+
build](https://docs.docker.com/reference/commandline/cli/#build)
|
187
|
+
command.
|
206
188
|
|
207
|
-
|
208
|
-
```
|
209
|
-
options[:add_authorized_keys] = "id_rsa.pub"
|
210
|
-
```
|
189
|
+
## Command Line Options
|
211
190
|
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
which aren't baked into the Docker image. This is a config-only
|
216
|
-
option, there is no command line for this. Commands are run one at a
|
217
|
-
time over ssh - enabling :add_authorized_keys makes this option more
|
218
|
-
tolerable.
|
191
|
+
The following options may be specified either on the command line or in
|
192
|
+
the spoon [configuration file](README_config.md). Note that command line
|
193
|
+
options take precedence over options in the configuration file.
|
219
194
|
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
195
|
+
- `--builddir`, This is the directory where the build process will look
|
196
|
+
for a Dockerfile and any content added to the container using `ADD`.
|
197
|
+
- `--config`, configuration file to read, defaults to `~/.spoonrc`
|
198
|
+
- `--image`, The image name to use when starting a spoon container.
|
199
|
+
- `--portforwards`, This is a comma separated list of ports to forward
|
200
|
+
over ssh. The format is either `sourceport:destport` or just
|
201
|
+
`sourceport` in which case the same port will be used for source &
|
202
|
+
destination. This may be used after container creation to add ports
|
203
|
+
ad-hoc
|
204
|
+
- `--ports`, Comma separated list of ports to expose upon container
|
205
|
+
creation by Docker. Unlike `--portforwards` this is only available at
|
206
|
+
container creation
|
207
|
+
- `--prefix`, The prefix to use for creating, listing & destroying
|
208
|
+
containers.
|
209
|
+
- `--privileged`, Starts a new container in with Privileged mode true,
|
210
|
+
only applicable on container creation.
|
211
|
+
- `--url`, The url of the Docker API endpoint. This is in the format
|
212
|
+
supported by the docker -H option. This will also read from the
|
213
|
+
environment variable `DOCKER_HOST` if this argument is not specified and
|
214
|
+
that env var exists.
|
215
|
+
- `--nologin`, This option is used for testing. It performs all actions
|
216
|
+
up to the point of executing an ssh connection and then returns.
|
217
|
+
- `--debug`, Enables some debugging
|
218
|
+
- `--debugssh`, Enables SSH debugging
|
219
|
+
- `--version`, Shows the version
|
220
|
+
|
221
|
+
These options and others are described in greater detail in the [configuration
|
222
|
+
file](README_config.md) documentation.
|
224
223
|
|
225
224
|
#### Container expectations
|
226
225
|
|
@@ -233,7 +232,8 @@ directory inside this repository
|
|
233
232
|
|
234
233
|
1. Fork it ( https://github.com/adnichols/docker-spoon/fork )
|
235
234
|
2. Create your feature branch (`git checkout -b my-new-feature`)
|
236
|
-
3.
|
237
|
-
4.
|
238
|
-
5.
|
235
|
+
3. Make your changes, add tests and make sure all tests pass (`rake`)
|
236
|
+
4. Commit your changes (`git commit -am 'Add some feature'`)
|
237
|
+
5. Push to the branch (`git push origin my-new-feature`)
|
238
|
+
6. Create a new Pull Request
|
239
239
|
|
data/README_config.md
ADDED
@@ -0,0 +1,248 @@
|
|
1
|
+
# docker-spoon
|
2
|
+
|
3
|
+
## Configuration
|
4
|
+
|
5
|
+
All spoon options available on the command line may be specified in the
|
6
|
+
configuration file as well. For action type options it doesn't make much
|
7
|
+
sense to place them in the config file, but for many other options it
|
8
|
+
does. Further, there are some configurations which are only available as
|
9
|
+
configuration file options to keep the cli options cleaner.
|
10
|
+
|
11
|
+
The spoon configuration file is evaled as ruby so you can do all the
|
12
|
+
things you could normally do in a ruby program. Abuse with caution.
|
13
|
+
|
14
|
+
The precedence of options, from most to least preferred are:
|
15
|
+
- Command line options
|
16
|
+
- Configuration file options
|
17
|
+
- Default options
|
18
|
+
|
19
|
+
The exception to this is the `--config` option, which is completely
|
20
|
+
ignored inside the configuration file.
|
21
|
+
|
22
|
+
Here is an example of a simple .spoonrc:
|
23
|
+
```ruby
|
24
|
+
options[:url] = "tcp://192.168.1.3:4243"
|
25
|
+
options[:image] = 'spoon-pairing'
|
26
|
+
```
|
27
|
+
|
28
|
+
All of the `options[]` parameters should map directly to the long form
|
29
|
+
of options on the command line. They are all expected to be presented as
|
30
|
+
symbols. The limitation is that ruby doesn't permit a dash in symbols,
|
31
|
+
so when an option has a dash in it, it must be specified as a string.
|
32
|
+
|
33
|
+
You may also specify a different config file with the `--config`
|
34
|
+
argument.
|
35
|
+
|
36
|
+
### Options
|
37
|
+
|
38
|
+
#### cpu
|
39
|
+
Forms:
|
40
|
+
- `options[:cpu] = 1`
|
41
|
+
|
42
|
+
Default: 0
|
43
|
+
|
44
|
+
Configures priority of [CPU
|
45
|
+
shares](https://docs.docker.com/reference/run/#runtime-constraints-on-cpu-and-memory).
|
46
|
+
|
47
|
+
#### memory
|
48
|
+
Forms:
|
49
|
+
- `options[:memory] = "50m"`
|
50
|
+
|
51
|
+
Default: unlimited
|
52
|
+
|
53
|
+
Configures [memory
|
54
|
+
constraints](https://docs.docker.com/reference/run/#runtime-constraints-on-cpu-and-memory).
|
55
|
+
|
56
|
+
#### dns
|
57
|
+
Forms:
|
58
|
+
- `options[:dns] = [ "8.8.8.8", "8.8.4.4" ]`
|
59
|
+
|
60
|
+
Default: (Docker default)
|
61
|
+
|
62
|
+
Configures DNS servers for the container to use.
|
63
|
+
|
64
|
+
#### volume
|
65
|
+
Forms:
|
66
|
+
- `options[:volume] = [ '/vol1', '/hostdir:/vol2' ]`
|
67
|
+
|
68
|
+
Default: none
|
69
|
+
|
70
|
+
This creates a volume mapping in the container to a directory on the
|
71
|
+
Docker host. This should work much like the `-v` argument in the docker
|
72
|
+
cli
|
73
|
+
|
74
|
+
#### url
|
75
|
+
Forms:
|
76
|
+
- `--url URL`
|
77
|
+
- `options[:url] = "tcp://127.0.0.1:2375"`
|
78
|
+
|
79
|
+
Default: `ENV['DOCKER_HOST']`
|
80
|
+
|
81
|
+
The url of the Docker API endpoint. This is in the format supported by
|
82
|
+
the docker -H option. If this option is not specified in either the
|
83
|
+
config or the command line then spoon will rely upon the value of
|
84
|
+
`DOCKER_HOST`.
|
85
|
+
|
86
|
+
#### image
|
87
|
+
Forms:
|
88
|
+
- `--image IMAGE`
|
89
|
+
- `options[:image] = "image"`
|
90
|
+
|
91
|
+
Default: `spoon-pairing`
|
92
|
+
|
93
|
+
The image name to use when starting a new spoon container. Note that
|
94
|
+
despite both default `--prefix` and `--image` beginning with `spoon-`
|
95
|
+
the two options are unrelated.
|
96
|
+
|
97
|
+
#### prefix
|
98
|
+
Forms:
|
99
|
+
- `--prefix PREFIX`
|
100
|
+
- `options[:prefix] = "prefix"`
|
101
|
+
|
102
|
+
Default: `spoon-`
|
103
|
+
|
104
|
+
The prefix to use for naming containers. Container names are central to
|
105
|
+
the way spoon works so that developers may choose simple names that are
|
106
|
+
easy to remember for their containers. The prefix allows different
|
107
|
+
groups to use different prefixes to lower the risk of name collisions.
|
108
|
+
|
109
|
+
#### portforwards
|
110
|
+
Forms:
|
111
|
+
- `--portforwards PORT[:PORT][,PORT]`
|
112
|
+
- `options[:portforwards] = [ "1234", "1234:4321" ]`
|
113
|
+
|
114
|
+
Default: none
|
115
|
+
|
116
|
+
Sometimes you are developing in a spoon container and need to expose a
|
117
|
+
new port without destroying the container & starting over. This option
|
118
|
+
enables this by using ssh port forwarding.
|
119
|
+
|
120
|
+
This is a comma separated list of ports to forward over ssh. The format
|
121
|
+
is either `sourceport:destport` or just `sourceport` in which case the
|
122
|
+
same port will be used for source & destination. Multiple port forwards
|
123
|
+
may be separated by commas, for exampe `--portforwards '8080,8081:9090'`
|
124
|
+
|
125
|
+
#### ports
|
126
|
+
Forms:
|
127
|
+
- `--ports PORT[:PORT][,PORT]`
|
128
|
+
- `options[:ports] = [ "1234", "1234:4321" ] `
|
129
|
+
|
130
|
+
Default: none
|
131
|
+
|
132
|
+
This option exposes additional ports using Docker when the container is
|
133
|
+
created. By default any ports defined by `EXPOSE` in the Dockerfile are
|
134
|
+
exposed to the container. This options allows you to both expose
|
135
|
+
additional ports via Docker, or map those exposed ports to specific
|
136
|
+
ports instead of using the dynamic Docker assigned ports.
|
137
|
+
|
138
|
+
Default: none
|
139
|
+
|
140
|
+
#### privileged
|
141
|
+
Forms:
|
142
|
+
- `--privileged`
|
143
|
+
- `options[:privileged] = true`
|
144
|
+
|
145
|
+
Default: false
|
146
|
+
|
147
|
+
This is a boolean which enables
|
148
|
+
[Privileged](https://docs.docker.com/reference/run/#runtime-privilege-linux-capabilities-and-lxc-configuration)
|
149
|
+
mode on container creation. This may be necessary for some operations
|
150
|
+
to succeed inside the container.
|
151
|
+
|
152
|
+
#### builddir
|
153
|
+
Forms:
|
154
|
+
- `--builddir DIRECTORY`
|
155
|
+
- `options[:builddir] = "directory"`
|
156
|
+
|
157
|
+
Default: `.`
|
158
|
+
|
159
|
+
This is the directory where the build process will look for a Dockerfile
|
160
|
+
and any content added to the container using `ADD`. The directory name
|
161
|
+
is relative to the directory from which spoon is being called - not the
|
162
|
+
directory in which the spoon executable resides.
|
163
|
+
|
164
|
+
#### pre-build-commands
|
165
|
+
Forms:
|
166
|
+
- `options["pre-build-commands"] = [ 'cmd1', 'cmd2' ]`
|
167
|
+
|
168
|
+
Default: none
|
169
|
+
|
170
|
+
This is a list of commands to run before actually kicking off the build
|
171
|
+
process.
|
172
|
+
|
173
|
+
Because docker-spoon is special, we also support running some
|
174
|
+
commands in advance of the build process. This allows for things like
|
175
|
+
copying stuff into the container which you don't want to have committed
|
176
|
+
to the repository. An example of this is that in our environment we need
|
177
|
+
chef credentials inside of our container & we use this mechanism to copy
|
178
|
+
those credentials into the builddir at build time without adding them to
|
179
|
+
our repository containing the Dockerfile.
|
180
|
+
|
181
|
+
Here's an example of how we copy our chef configuration into place:
|
182
|
+
```ruby
|
183
|
+
options["pre-build-commands"] = [
|
184
|
+
"cp -rp #{ENV['HOME']}/.chef #{options[:builddir]}/chef"
|
185
|
+
]
|
186
|
+
```
|
187
|
+
|
188
|
+
NOTE: This option is NOT in symbol form like all others - a legacy issue
|
189
|
+
I need to get around to fixing and deprecating this format.
|
190
|
+
|
191
|
+
#### copy_on_create
|
192
|
+
Forms:
|
193
|
+
- `options[:copy_on_create] = [ 'somefile', 'otherfile' ]`
|
194
|
+
|
195
|
+
Default: none
|
196
|
+
|
197
|
+
This command will copy the list of specified files into the destionation
|
198
|
+
container upon container creation. These will be copied from the source
|
199
|
+
system relative to your home directory and placed in the destination
|
200
|
+
container at the same location (relative to your home directory).
|
201
|
+
|
202
|
+
This is handy for adding any custom configurations you require which you
|
203
|
+
may not want to bake into your Docker image.
|
204
|
+
|
205
|
+
Example:
|
206
|
+
```
|
207
|
+
options[:copy_on_create] = [
|
208
|
+
".gitconfig",
|
209
|
+
".ssh/config"
|
210
|
+
]
|
211
|
+
```
|
212
|
+
|
213
|
+
NOTE: this does not create any required parent directories on the
|
214
|
+
destination system unless they are copied into place, for example the
|
215
|
+
.ssh directory in the example above.
|
216
|
+
|
217
|
+
#### add_authorized_keys
|
218
|
+
Forms:
|
219
|
+
- `options[:add_authorized_keys] = "id_rsa.pub"`
|
220
|
+
|
221
|
+
Default: none
|
222
|
+
|
223
|
+
This allows you to specify an ssh public key that should reside in your
|
224
|
+
own `~/.ssh` directory to be placed in authorized_keys on the
|
225
|
+
destination system upon container creation. It copies the filename
|
226
|
+
specified out of your local `~/.ssh` directory into
|
227
|
+
`~/.ssh/authorized_keys` on the spoon container so that public key auth
|
228
|
+
works.
|
229
|
+
|
230
|
+
NOTE: This option WILL create a `~/.ssh` directory on the spoon
|
231
|
+
container if it doesn't already exist.
|
232
|
+
|
233
|
+
#### run_on_create
|
234
|
+
Forms:
|
235
|
+
- `options[:run_on_create] = [ 'cmd1', 'cmd2' ]`
|
236
|
+
|
237
|
+
Default: none
|
238
|
+
|
239
|
+
This is a list of commands to run on a spoon container once it has been
|
240
|
+
started. This allows you to quickly and automatically modify a spoon
|
241
|
+
environment upon creation to meet any needs you have which aren't baked
|
242
|
+
into the Docker image. Commands are run one at a time over ssh - enabling
|
243
|
+
:add_authorized_keys makes this option more tolerable.
|
244
|
+
|
245
|
+
Example:
|
246
|
+
```
|
247
|
+
options[:run_on_create] = [ "sudo apt-get -y install emacs" ]
|
248
|
+
```
|