rumrunner 0.3.4 → 0.4.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/README.md +110 -93
- data/lib/rumrunner/docker.rb +7 -0
- data/lib/rumrunner/manifest.rb +8 -3
- data/lib/rumrunner/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7dd5856ce9705196280daf49018154662a937c97f6920401d880828744f1d042
|
4
|
+
data.tar.gz: 28b6ba6f5162b0446e0f36273627b6b5fdf766f95d9d949bf7a210ff3bbee5f9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7ff1900f6e1287812077722c9ffeac04916591011eecc0d1b44145aed0274861beb04d8715b35d0f026fae8046b26757cc00fddad7f7e461ab729b590ac65419
|
7
|
+
data.tar.gz: 8e829a928fa46f634a0d80fae78e787dd7c9342559a0a0f6b5e79aea4f68865ad23f2276403b419d957dd3947838e0e280c198cf35d8a2b3384ee6ad071a19a9
|
data/README.md
CHANGED
@@ -92,83 +92,89 @@ rum shell:test[shell] # Shell into `test` stage
|
|
92
92
|
rum test # Build `test` stage
|
93
93
|
```
|
94
94
|
|
95
|
-
##
|
95
|
+
## Customize Shells
|
96
96
|
|
97
|
-
|
97
|
+
By default, all stages have a `:shell` task that can be invoked to build and shell into a container for a stage. By default the container is run as an ephemeral container (`--rm`) in interactive with TTY allocated and a bash shell open.
|
98
98
|
|
99
|
-
|
99
|
+
Customize the shell for a stage with the `shell` method:
|
100
100
|
|
101
|
-
```
|
102
|
-
|
103
|
-
|
101
|
+
```ruby
|
102
|
+
rum :image_name do
|
103
|
+
stage :dev
|
104
|
+
|
105
|
+
shell :dev do
|
106
|
+
entrypoint "/bin/zsh"
|
107
|
+
rm false
|
108
|
+
volume "#{Dir.pwd}:/var/task/"
|
109
|
+
end
|
110
|
+
|
111
|
+
# rum dev => docker run --entrypoint /bin/zsh --volume $PWD:/var/task/ ...
|
112
|
+
end
|
104
113
|
```
|
105
114
|
|
106
|
-
##
|
115
|
+
## Customize Stages
|
107
116
|
|
108
|
-
|
117
|
+
Stages can be customized with blocks:
|
109
118
|
|
110
|
-
|
119
|
+
```ruby
|
120
|
+
rum :image_name do
|
121
|
+
tag "1.2.3"
|
111
122
|
|
112
|
-
|
113
|
-
- `image_name:1.2.3-test`
|
114
|
-
- `image_name:1.2.3-deploy`
|
123
|
+
stage :build
|
115
124
|
|
116
|
-
|
125
|
+
stage :test => :build
|
117
126
|
|
118
|
-
|
119
|
-
|
120
|
-
|
127
|
+
stage :deploy => :test do
|
128
|
+
build_arg :AWS_ACCESS_KEY_ID
|
129
|
+
build_arg :AWS_SECRET_ACCESS_KEY
|
130
|
+
build_arg :AWS_DEFAULT_REGION => "us-east-1"
|
131
|
+
label :Fizz
|
132
|
+
end
|
121
133
|
end
|
122
134
|
```
|
123
135
|
|
124
|
-
|
136
|
+
Methods invoked inside the stage block are interpreted as options for the eventual `docker build` command.
|
125
137
|
|
126
|
-
|
138
|
+
## Export Artifacts
|
127
139
|
|
128
|
-
|
140
|
+
Use the `artifact` method to specify an artifact to be exported from the image.
|
129
141
|
|
130
142
|
```ruby
|
131
|
-
rum :image_name
|
132
|
-
|
143
|
+
rum :image_name do
|
144
|
+
stage :build
|
145
|
+
|
146
|
+
artifact "package.zip" => :build
|
133
147
|
end
|
134
148
|
```
|
135
149
|
|
136
|
-
|
137
|
-
|
138
|
-
At the core, every directive within the `rum` block will eventually be interpreted as either a `docker build` or a `docker run` command. The type of directive is simply a way of specifying defaults for the command.
|
139
|
-
|
140
|
-
If you simply wish to define a named task that executes a build or a run, you can use the `build` or `run` directives:
|
150
|
+
By default the container simply `cat`s the file from the container to the local file system, but more complex exports can be defined:
|
141
151
|
|
142
152
|
```ruby
|
143
153
|
rum :image_name do
|
144
|
-
|
145
|
-
tag "image_name"
|
146
|
-
path "."
|
147
|
-
end
|
154
|
+
stage :build
|
148
155
|
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
cmd %w{echo hello}
|
156
|
+
artifact "package.zip" => :build do
|
157
|
+
workdir "/var/task/"
|
158
|
+
cmd %w[zip -r - .]
|
153
159
|
end
|
154
|
-
|
155
|
-
# rum fizz => docker build --tag image_name .
|
156
|
-
# rum buzz => docker run --rm image_name echo hello
|
157
160
|
end
|
158
161
|
```
|
159
162
|
|
160
|
-
|
161
|
-
|
162
|
-
The methods inside blocks for `build`, `run`, `stage`, `artifact`, and `shell` tasks are dynamically handled. Any option you might pass to the `docker run` or `docker build` command can be used.
|
163
|
+
Methods invoked inside the artifact block are interpreted as options for the eventual `docker run` command.
|
163
164
|
|
164
|
-
|
165
|
+
## Default Task
|
165
166
|
|
166
|
-
|
167
|
+
Use the `default` method to set a default task when running the bare `rum` executable:
|
167
168
|
|
168
|
-
|
169
|
+
```ruby
|
170
|
+
rum :image_name do
|
171
|
+
stage :build
|
169
172
|
|
170
|
-
|
173
|
+
artifact "package.zip" => :build
|
171
174
|
|
175
|
+
default "package.zip"
|
176
|
+
end
|
177
|
+
```
|
172
178
|
## Shared ENV variables
|
173
179
|
|
174
180
|
The `env` method can be invoked in the `rum` block to declare a value that will be passed to all stages/artifacts/shells. For stages, the value will be passed using the `--build-arg` option; for artifacts and shells, the `--env` option.
|
@@ -179,10 +185,7 @@ rum :image_name do
|
|
179
185
|
|
180
186
|
stage :build
|
181
187
|
|
182
|
-
|
183
|
-
|
184
|
-
# rum build => docker build --build-arg FIZZ=BUZZ ...
|
185
|
-
# rum pkg.zip => docker run --env FIZZ=BUZZ ...
|
188
|
+
# rum build => docker build --build-arg FIZZ=BUZZ ...
|
186
189
|
end
|
187
190
|
```
|
188
191
|
|
@@ -194,87 +197,101 @@ Run with the `:shell` suffix to build the image and then shell into an instance
|
|
194
197
|
|
195
198
|
The default shell is `/bin/sh`, but this can be overridden at runtime with the task arg, eg. `rum build:shell[/bin/bash]`
|
196
199
|
|
197
|
-
##
|
200
|
+
## Build vs. Run
|
198
201
|
|
199
|
-
|
202
|
+
At the core, every directive within the `rum` block will eventually be interpreted as either a `docker build` or a `docker run` command. The type of directive is simply a way of specifying defaults for the command.
|
200
203
|
|
201
|
-
|
204
|
+
If you simply wish to define a named task that executes a build or a run, you can use the `build` or `run` directives:
|
202
205
|
|
203
206
|
```ruby
|
204
207
|
rum :image_name do
|
205
|
-
|
208
|
+
env :JAZZ => "fuzz"
|
206
209
|
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
volume "#{Dir.pwd}:/var/task/"
|
210
|
+
build :fizz do
|
211
|
+
tag "image_name"
|
212
|
+
path "."
|
211
213
|
end
|
212
214
|
|
213
|
-
|
215
|
+
run :buzz do
|
216
|
+
rm true
|
217
|
+
image "image_name"
|
218
|
+
cmd %w{echo hello}
|
219
|
+
end
|
220
|
+
|
221
|
+
# rum fizz => docker build --build-arg JAZZ=fuzz --tag image_name .
|
222
|
+
# rum buzz => docker run --rm --env JAZZ=fuzz image_name echo hello
|
214
223
|
end
|
215
224
|
```
|
216
225
|
|
217
|
-
|
226
|
+
Note that the build/run commands will still import any shared ENV values defined above.
|
218
227
|
|
219
|
-
|
228
|
+
If this is undesirable, use the `clear_options` method inside your block to clear ALL the default options:
|
220
229
|
|
221
230
|
```ruby
|
222
231
|
rum :image_name do
|
223
|
-
tag "1.2.3"
|
224
232
|
|
225
|
-
|
233
|
+
env :JAZZ => "fuzz"
|
226
234
|
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
build_arg :AWS_SECRET_ACCESS_KEY
|
232
|
-
build_arg :AWS_DEFAULT_REGION => "us-east-1"
|
233
|
-
label :Fizz
|
235
|
+
run :buzz do
|
236
|
+
clear_options
|
237
|
+
image "image_name"
|
238
|
+
cmd %w{echo hello}
|
234
239
|
end
|
240
|
+
|
241
|
+
# rum buzz => docker run image_name echo hello
|
235
242
|
end
|
236
243
|
```
|
237
244
|
|
238
|
-
|
245
|
+
## Blocks
|
239
246
|
|
240
|
-
|
247
|
+
The methods inside blocks for `build`, `run`, `stage`, `artifact`, and `shell` tasks are dynamically handled. Any option you might pass to the `docker run` or `docker build` command can be used.
|
241
248
|
|
242
|
-
|
249
|
+
Simply drop any leading `-`s from the option and convert to snake-case.
|
243
250
|
|
244
|
-
|
245
|
-
rum :image_name do
|
246
|
-
stage :build
|
251
|
+
Eg,
|
247
252
|
|
248
|
-
|
249
|
-
end
|
250
|
-
```
|
253
|
+
`--build-arg` becomes `build_arg`
|
251
254
|
|
252
|
-
|
255
|
+
`--env-file` becomes `env_file`.
|
253
256
|
|
254
|
-
|
255
|
-
rum :image_name do
|
256
|
-
stage :build
|
257
|
+
## Task Naming Convention
|
257
258
|
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
259
|
+
As of v0.3, rum runner uses a "verb-first" naming convention (eg. `clean:stage`) for tasks.
|
260
|
+
|
261
|
+
To revert to the previous convention of "stage-first" (eg. `stage:clean`) use the environmental variable `RUM_TASK_NAMES`:
|
262
|
+
|
263
|
+
```bash
|
264
|
+
export RUM_TASK_NAMES=STAGE_FIRST # => rum stage:clean
|
265
|
+
export RUM_TASK_NAMES=VERB_FIRST # => rum clean:stage (default)
|
263
266
|
```
|
264
267
|
|
265
|
-
|
268
|
+
## Image Naming Convention
|
266
269
|
|
267
|
-
|
270
|
+
The name of the images are taken from the first argument to the main block and appended with the name of the stage.
|
268
271
|
|
269
|
-
|
272
|
+
In the above example, built images would build be named:
|
273
|
+
|
274
|
+
- `image_name:1.2.3-build`
|
275
|
+
- `image_name:1.2.3-test`
|
276
|
+
- `image_name:1.2.3-deploy`
|
277
|
+
|
278
|
+
The first argument to the main block can be any Docker image reference:
|
270
279
|
|
271
280
|
```ruby
|
272
|
-
rum :
|
273
|
-
|
281
|
+
rum :"registry:5000/username/image" do
|
282
|
+
#...
|
283
|
+
end
|
284
|
+
```
|
274
285
|
|
275
|
-
|
286
|
+
## Digest Location
|
276
287
|
|
277
|
-
|
288
|
+
Images build with the `stage` task have their digests cached for easy lookup.
|
289
|
+
|
290
|
+
The default location for the digests is in `.docker`, but that can be modified:
|
291
|
+
|
292
|
+
```ruby
|
293
|
+
rum :image_name => "tmp" do
|
294
|
+
# ...
|
278
295
|
end
|
279
296
|
```
|
280
297
|
|
data/lib/rumrunner/docker.rb
CHANGED
data/lib/rumrunner/manifest.rb
CHANGED
@@ -60,7 +60,7 @@ module Rum
|
|
60
60
|
def build(*args, &block)
|
61
61
|
name, _, deps = Rake.application.resolve_args(args)
|
62
62
|
task name => deps do
|
63
|
-
sh Docker::Build.new(&block).to_s
|
63
|
+
sh Docker::Build.new(options: build_options, &block).to_s
|
64
64
|
end
|
65
65
|
end
|
66
66
|
|
@@ -73,8 +73,13 @@ module Rum
|
|
73
73
|
#
|
74
74
|
def run(*args, &block)
|
75
75
|
name, _, deps = Rake.application.resolve_args(args)
|
76
|
-
|
77
|
-
|
76
|
+
|
77
|
+
images = deps.map{|dep| Docker::Image.parse("#{@image}-#{dep}") }
|
78
|
+
iidfiles = images.map{|image| File.join(root, *image) }
|
79
|
+
|
80
|
+
task name => iidfiles do
|
81
|
+
image = iidfiles.empty? ? to_s : File.read(iidfiles.first)
|
82
|
+
sh Docker::Run.new(options: run_options, image: image, &block).to_s
|
78
83
|
end
|
79
84
|
end
|
80
85
|
|
data/lib/rumrunner/version.rb
CHANGED