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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: da4a1989a2252315eba1d4bcd4d921b25ee90c53fd77b2ce6e720dad5a07b807
4
- data.tar.gz: ed649270e0622f1aabc134ce1529403dc534b040b6857c5a7fd0db4c4daedbd6
3
+ metadata.gz: 7dd5856ce9705196280daf49018154662a937c97f6920401d880828744f1d042
4
+ data.tar.gz: 28b6ba6f5162b0446e0f36273627b6b5fdf766f95d9d949bf7a210ff3bbee5f9
5
5
  SHA512:
6
- metadata.gz: 61514ca3d73be5d90755d2a82af2abee79c38ce673ec310e77e96f7f18ea924a03f0bba8a8821745eb9ff3ce27a5f3dd03470a956e2554610670a5677fe2bb1f
7
- data.tar.gz: 59c77172cef86582a1973b761a1e2b9d7475db4d1d477f7f721379777e5f0bb6a448eea8aba4ae673de281f961dad73de549a14bb0300d76c55977ce5ea27941
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
- ## Task Naming Convention
95
+ ## Customize Shells
96
96
 
97
- As of v0.3, rum runner uses a "verb-first" naming convention (eg. `clean:stage`) for tasks.
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
- To revert to the previous convention of "stage-first" (eg. `stage:clean`) use the environmental variable `RUM_TASK_NAMES`:
99
+ Customize the shell for a stage with the `shell` method:
100
100
 
101
- ```bash
102
- export RUM_TASK_NAMES=STAGE_FIRST # => rum stage:clean
103
- export RUM_TASK_NAMES=VERB_FIRST # => rum clean:stage (default)
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
- ## Image Naming Convention
115
+ ## Customize Stages
107
116
 
108
- The name of the images are taken from the first argument to the main block and appended with the name of the stage.
117
+ Stages can be customized with blocks:
109
118
 
110
- In the above example, built images would build be named:
119
+ ```ruby
120
+ rum :image_name do
121
+ tag "1.2.3"
111
122
 
112
- - `image_name:1.2.3-build`
113
- - `image_name:1.2.3-test`
114
- - `image_name:1.2.3-deploy`
123
+ stage :build
115
124
 
116
- The first argument to the main block can be any Docker image reference:
125
+ stage :test => :build
117
126
 
118
- ```ruby
119
- rum :"registry:5000/username/image" do
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
- ## Digest Location
136
+ Methods invoked inside the stage block are interpreted as options for the eventual `docker build` command.
125
137
 
126
- Images build with the `stage` task have their digests cached for easy lookup.
138
+ ## Export Artifacts
127
139
 
128
- The default location for the digests is in `.docker`, but that can be modified:
140
+ Use the `artifact` method to specify an artifact to be exported from the image.
129
141
 
130
142
  ```ruby
131
- rum :image_name => "tmp" do
132
- # ...
143
+ rum :image_name do
144
+ stage :build
145
+
146
+ artifact "package.zip" => :build
133
147
  end
134
148
  ```
135
149
 
136
- ## Build vs. Run
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
- build :fizz do
145
- tag "image_name"
146
- path "."
147
- end
154
+ stage :build
148
155
 
149
- run :buzz do
150
- rm true
151
- image "image_name"
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
- ## Blocks
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
- Simply drop any leading `-`s from the option and convert to snake-case.
165
+ ## Default Task
165
166
 
166
- Eg,
167
+ Use the `default` method to set a default task when running the bare `rum` executable:
167
168
 
168
- `--build-arg` becomes `build_arg`
169
+ ```ruby
170
+ rum :image_name do
171
+ stage :build
169
172
 
170
- `--env-file` becomes `env_file`.
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
- artifact "pkg.zip" => :build
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
- ## Customize Shells
200
+ ## Build vs. Run
198
201
 
199
- 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.
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
- Customize the shell for a stage with the `shell` method:
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
- stage :dev
208
+ env :JAZZ => "fuzz"
206
209
 
207
- shell :dev do
208
- entrypoint "/bin/zsh"
209
- rm false
210
- volume "#{Dir.pwd}:/var/task/"
210
+ build :fizz do
211
+ tag "image_name"
212
+ path "."
211
213
  end
212
214
 
213
- # rum dev => docker run --entrypoint /bin/zsh --volume $PWD:/var/task/ ...
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
- ## Customize Stages
226
+ Note that the build/run commands will still import any shared ENV values defined above.
218
227
 
219
- Stages can be customized with blocks:
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
- stage :build
233
+ env :JAZZ => "fuzz"
226
234
 
227
- stage :test => :build
228
-
229
- stage :deploy => :test do
230
- build_arg :AWS_ACCESS_KEY_ID
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
- Methods invoked inside the stage block are interpreted as options for the eventual `docker build` command.
245
+ ## Blocks
239
246
 
240
- ## Export Artifacts
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
- Use the `artifact` method to specify an artifact to be exported from the image.
249
+ Simply drop any leading `-`s from the option and convert to snake-case.
243
250
 
244
- ```ruby
245
- rum :image_name do
246
- stage :build
251
+ Eg,
247
252
 
248
- artifact "package.zip" => :build
249
- end
250
- ```
253
+ `--build-arg` becomes `build_arg`
251
254
 
252
- By default the container simply `cat`s the file from the container to the local file system, but more complex exports can be defined:
255
+ `--env-file` becomes `env_file`.
253
256
 
254
- ```ruby
255
- rum :image_name do
256
- stage :build
257
+ ## Task Naming Convention
257
258
 
258
- artifact "package.zip" => :build do
259
- workdir "/var/task/"
260
- cmd %w[zip -r - .]
261
- end
262
- end
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
- Methods invoked inside the artifact block are interpreted as options for the eventual `docker run` command.
268
+ ## Image Naming Convention
266
269
 
267
- ## Default Task
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
- Use the `default` method to set a default task when running the bare `rum` executable:
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 :image_name do
273
- stage :build
281
+ rum :"registry:5000/username/image" do
282
+ #...
283
+ end
284
+ ```
274
285
 
275
- artifact "package.zip" => :build
286
+ ## Digest Location
276
287
 
277
- default "package.zip"
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
 
@@ -72,6 +72,13 @@ module Rum
72
72
  args.empty? ? @options[m] : self
73
73
  end
74
74
 
75
+ ##
76
+ # Clear all @options
77
+ def clear_options
78
+ @options = Options.new
79
+ self
80
+ end
81
+
75
82
  ##
76
83
  # Convert Docker command to string.
77
84
  def to_s
@@ -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
- task name => deps do
77
- sh Docker::Run.new(image: to_s, &block).to_s
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
 
@@ -1,5 +1,5 @@
1
1
  module Rum
2
2
  ##
3
3
  # Rum Runner gem version.
4
- VERSION = "0.3.4"
4
+ VERSION = "0.4.0"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rumrunner
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.4
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alexander Mancevice