rumrunner 0.4.1 → 0.4.2

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: ead63f96d28a203a6138bad38b5d2a03287807e5d155036493c43e6d3d939333
4
- data.tar.gz: a785198de4a88a50d0aa33d05b5fd0a45dfd8aed6c5451d95b4ce021c4993a61
3
+ metadata.gz: f5b49cf24f5e8eec6a07671a76471effb1cdaa8d81cce8dfc620a1f1c6944417
4
+ data.tar.gz: 788ce31f54f4d12d03f426ef9533a500d3835e21679782254b3f3ddbb4b8e2cb
5
5
  SHA512:
6
- metadata.gz: 7ec0fca40235a7b3c6c412d50a86c53f7b3c696de800a899edca238ec4ad769aa4466e1457a60216616ce8cbdc5cf5f9e325981332f0d3a895ddcb056d2134a5
7
- data.tar.gz: 9f8a97f043c8b9defd0d97ed3600887901ef80338c51dc2c3b80066b888eafc1a01e24757562a07e4b2c85bd03762530fd99fc556ca8934954c1db6db62749d4
6
+ metadata.gz: a3a48aee02ab98cfcfe482ee499feaab801e8d63031a27cb67924ffe6336228601e0b7a9959ff318aff48f0659c86b6fd2c1935acb4b22f5db9344a286c6b8fa
7
+ data.tar.gz: e5fd024b58c08d18f4077e5e43d922f26a46b3fca2822598ee9f1e73ee73675f5dd608cfc898855ec7e8fbb92d0ec2cf26e181292bc9dc5dd4e44a41d252d7e2
@@ -31,10 +31,14 @@ module Rum
31
31
  super "rum", argv
32
32
  end
33
33
 
34
+ ##
35
+ # Return true if any of the default Rumfiles exist
34
36
  def rumfile?
35
37
  DEFAULT_RAKEFILES.map{|x| File.size? x }.any?
36
38
  end
37
39
 
40
+ ##
41
+ # Run application
38
42
  def run(argv = ARGV)
39
43
  if argv.first == "init" && !rumfile?
40
44
  Rum.init
@@ -269,8 +269,8 @@ module Rum
269
269
  desc "Build `#{name}`"
270
270
  file name => deps do
271
271
  digest = File.read(iidfile)
272
- run = Docker::Run.new(options: run_options, image: digest, cmd: ["cat", name], &block)
273
- run.with_defaults(rm: true)
272
+ run = Docker::Run.new(options: run_options, image: digest, cmd: [name], &block)
273
+ run.with_defaults(rm: true, entrypoint: "cat")
274
274
  sh "#{run} > #{name}"
275
275
  end
276
276
  end
@@ -1,5 +1,5 @@
1
1
  module Rum
2
2
  ##
3
3
  # Rum Runner gem version.
4
- VERSION = "0.4.1"
4
+ VERSION = "0.4.2"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rumrunner
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.1
4
+ version: 0.4.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alexander Mancevice
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-08-13 00:00:00.000000000 Z
11
+ date: 2019-09-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -118,8 +118,6 @@ executables:
118
118
  extensions: []
119
119
  extra_rdoc_files: []
120
120
  files:
121
- - LICENSE
122
- - README.md
123
121
  - bin/rum
124
122
  - lib/rumrunner.rb
125
123
  - lib/rumrunner/application.rb
@@ -147,8 +145,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
147
145
  - !ruby/object:Gem::Version
148
146
  version: '0'
149
147
  requirements: []
150
- rubyforge_project:
151
- rubygems_version: 2.7.7
148
+ rubygems_version: 3.0.3
152
149
  signing_key:
153
150
  specification_version: 4
154
151
  summary: Rum Runner is a Rake-based utility for building projects with multi-stage
data/LICENSE DELETED
@@ -1,21 +0,0 @@
1
- MIT License
2
-
3
- Copyright (c) 2019 Alexander Mancevice
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
data/README.md DELETED
@@ -1,320 +0,0 @@
1
- [![Rum Runner](https://github.com/amancevice/rumrunner/blob/master/rum-runner.png?raw=true)](https://github.com/amancevice/rumrunner)
2
- [![Build Status](https://travis-ci.com/amancevice/rumrunner.svg?branch=master)](https://travis-ci.com/amancevice/rumrunner)
3
- [![Gem Version](https://badge.fury.io/rb/rumrunner.svg)](https://badge.fury.io/rb/rumrunner)
4
- [![Test Coverage](https://api.codeclimate.com/v1/badges/4b56853acc5cbb254125/test_coverage)](https://codeclimate.com/github/amancevice/rumrunner/test_coverage)
5
- [![Maintainability](https://api.codeclimate.com/v1/badges/4b56853acc5cbb254125/maintainability)](https://codeclimate.com/github/amancevice/rumrunner/maintainability)
6
-
7
- <sub>logo by [seenamavaddat.com](http://seenamavaddat.com/)</sub>
8
-
9
- Rum Runner is a Rake-based utility for building multi-stage Dockerfiles.
10
-
11
- Users can pair a multi-stage Dockerfile with a Rumfile that uses a Rake-like DSL to customize each stage's build options and dependencies.
12
-
13
- The `rum` executable allows users to easily invoke builds, shell-into specific stages for debugging, and export artifacts from built containers.
14
-
15
- Rum Runner has the following features:
16
- * Fully compatible with Rake
17
- * Rake-like DSL/CLI that enable simple annotation and execution of builds
18
- * Rumfiles are completely defined in standard Ruby syntax, like Rakefiles
19
- * Users can chain Docker build stages with prerequisites
20
- * Artifacts can be exported from stages
21
- * Shell tasks are automatically provided for every stage
22
- * Stage, artifact, and shell, steps can be customized
23
-
24
- **Origins**
25
-
26
- This project was born from using Makefiles to drive multi-stage builds. For the most part this worked really well, but it became a bit of an ordeal to write for more complex projects. This tool is an attempt to recreate that general technique with minimal annotation and limited assumptions.
27
-
28
- View the docs on [rubydoc.info](https://www.rubydoc.info/github/amancevice/rumrunner)
29
-
30
- ## Installation
31
-
32
- ```bash
33
- gem install rumrunner
34
- ```
35
-
36
- ## Quickstart
37
-
38
- If you have a multi-stage Dockerfile in your project and are unsure where to begin, use the `rum init` helper to create a template Rumfile for your project:
39
-
40
- ```bash
41
- gem install rumrunner
42
- rum init > Rumfile
43
- rum --tasks
44
- ```
45
-
46
- The `init` command will parse a Dockerfile in the current directory and output a simple Rumfile with each stage and its dependencies declared.
47
-
48
- ## Example
49
-
50
- Imagine a simple multi-stage Dockerfile:
51
-
52
- ```Dockerfile
53
- FROM ruby AS build
54
- # Run build steps here...
55
-
56
- FROM ruby AS test
57
- # Run test steps here...
58
-
59
- FROM ruby AS deploy
60
- # Run deploy steps here...
61
- ```
62
-
63
- Create `Rumfile` and describe your build:
64
-
65
- ```ruby
66
- rum :image_name do
67
- tag "1.2.3"
68
-
69
- stage :build
70
- stage :test => :build
71
- stage :deploy => :test
72
-
73
- # rum build => docker build --target build --tag image_name:1.2.3-build .
74
- # rum test => docker build --target test --tag image_name:1.2.3-test .
75
- # rum deploy => docker build --target deploy --tag image_name:1.2.3-deploy .
76
- end
77
- ```
78
-
79
- Run `rum --tasks` to view the installed tasks:
80
-
81
- ```bash
82
- rum build # Build `build` stage
83
- rum clean # Remove any temporary images and products
84
- rum clean:build # Remove any temporary images and products through `build` stage
85
- rum clean:deploy # Remove any temporary images and products through `deploy` stage
86
- rum clean:test # Remove any temporary images and products through `test` stage
87
- rum clobber # Remove any generated files
88
- rum deploy # Build `deploy` stage
89
- rum shell:build[shell] # Shell into `build` stage
90
- rum shell:deploy[shell] # Shell into `deploy` stage
91
- rum shell:test[shell] # Shell into `test` stage
92
- rum test # Build `test` stage
93
- ```
94
-
95
- ## Customize Shells
96
-
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
-
99
- Customize the shell for a stage with the `shell` method:
100
-
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
113
- ```
114
-
115
- ## Customize Stages
116
-
117
- Stages can be customized with blocks:
118
-
119
- ```ruby
120
- rum :image_name do
121
- tag "1.2.3"
122
-
123
- stage :build
124
-
125
- stage :test => :build
126
-
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
133
- end
134
- ```
135
-
136
- Methods invoked inside the stage block are interpreted as options for the eventual `docker build` command.
137
-
138
- ## Export Artifacts
139
-
140
- Use the `artifact` method to specify an artifact to be exported from the image.
141
-
142
- ```ruby
143
- rum :image_name do
144
- stage :build
145
-
146
- artifact "package.zip" => :build
147
- end
148
- ```
149
-
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:
151
-
152
- ```ruby
153
- rum :image_name do
154
- stage :build
155
-
156
- artifact "package.zip" => :build do
157
- workdir "/var/task/"
158
- cmd %w[zip -r - .]
159
- end
160
- end
161
- ```
162
-
163
- Methods invoked inside the artifact block are interpreted as options for the eventual `docker run` command.
164
-
165
- ## Default Task
166
-
167
- Use the `default` method to set a default task when running the bare `rum` executable:
168
-
169
- ```ruby
170
- rum :image_name do
171
- stage :build
172
-
173
- artifact "package.zip" => :build
174
-
175
- default "package.zip"
176
- end
177
- ```
178
- ## Shared ENV variables
179
-
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.
181
-
182
- ```ruby
183
- rum :image_name do
184
- env :FIZZ => :BUZZ
185
-
186
- stage :build
187
-
188
- # rum build => docker build --build-arg FIZZ=BUZZ ...
189
- end
190
- ```
191
-
192
- ## Shells
193
-
194
- Run a stage task to build the image up to that stage and cache the image digest.
195
-
196
- Run with the `:shell` suffix to build the image and then shell into an instance of the image running as a temporary container.
197
-
198
- The default shell is `/bin/sh`, but this can be overridden at runtime with the task arg, eg. `rum build:shell[/bin/bash]`
199
-
200
- ## Build vs. Run
201
-
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.
203
-
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:
205
-
206
- ```ruby
207
- rum :image_name do
208
- env :JAZZ => "fuzz"
209
-
210
- build :fizz do
211
- tag "image_name"
212
- path "."
213
- end
214
-
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
223
- end
224
- ```
225
-
226
- Note that the build/run commands will still import any shared ENV values defined above.
227
-
228
- If this is undesirable, use the `clear_options` method inside your block to clear ALL the default options:
229
-
230
- ```ruby
231
- rum :image_name do
232
-
233
- env :JAZZ => "fuzz"
234
-
235
- run :buzz do
236
- clear_options
237
- image "image_name"
238
- cmd %w{echo hello}
239
- end
240
-
241
- # rum buzz => docker run image_name echo hello
242
- end
243
- ```
244
-
245
- ## Blocks
246
-
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.
248
-
249
- Simply drop any leading `-`s from the option and convert to snake-case.
250
-
251
- Eg,
252
-
253
- `--build-arg` becomes `build_arg`
254
-
255
- `--env-file` becomes `env_file`.
256
-
257
- ## Task Naming Convention
258
-
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)
266
- ```
267
-
268
- ## Image Naming Convention
269
-
270
- The name of the images are taken from the first argument to the main block and appended with the name of the stage.
271
-
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:
279
-
280
- ```ruby
281
- rum :"registry:5000/username/image" do
282
- #...
283
- end
284
- ```
285
-
286
- ## Digest Location
287
-
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
- # ...
295
- end
296
- ```
297
-
298
- ## Integrate with Rake
299
-
300
- It isn't strictly necessary to include a `Rumfile` in your project. Rum Runner can be included in any `Rakefile` and run with the `rake` command:
301
-
302
- ```ruby
303
- # ./Rakefile
304
-
305
- require "rumrunner"
306
-
307
- namespace :rum do
308
- rum :image_name do
309
- stage :build
310
- stage :test => :build
311
- end
312
- end
313
- ```
314
-
315
- ```bash
316
- $ rake --tasks
317
-
318
- rake rum:build # ...
319
- rake rum:test # ...
320
- ```