docker-shaball 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +15 -0
- data/Gemfile +4 -0
- data/README.md +19 -0
- data/Rakefile +2 -0
- data/bin/docker-shaball +55 -0
- data/docker-shaball.gemspec +23 -0
- metadata +95 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 817611bc9747f865a69fbc22223f9e13e23a4610
|
4
|
+
data.tar.gz: ec21c7c41e8d09f4542935af256edda0c409ae65
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: fb41f0da700abc36f78640936ab89f6a3cede281236921893ed0798087ea0c3b659ea01ad7c039657ac9783280b84d0ad74febc14fe4b226f94bd7dd5762f6d5
|
7
|
+
data.tar.gz: 89b08918652b51a2f5ef5b2a5148bc044a079c10de7ace5b524236bc48be943db930a0d694b5db72478239c5ad98a2096b48f00b66ad0142014db06cff940d89
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/README.md
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
# docker-shaball
|
2
|
+
|
3
|
+
This little script helps you bundle up a bunch of Docker images for
|
4
|
+
distribution e.g. to S3.
|
5
|
+
|
6
|
+
Sample usage:
|
7
|
+
|
8
|
+
```shell
|
9
|
+
$ docker-shaball nginx:1.9 ruby:2.2
|
10
|
+
f5fe78d69d93b719109341295a024b62c84ebc28.tar.gz
|
11
|
+
```
|
12
|
+
|
13
|
+
The named images are exported from your local Docker daemon using `docker save`, and saved as a `CHECKSUM.tar.gz` archive. The archive file-name includes a checksum of a "manifest" formed using the named Docker images and the corresponding IDs. Specify the `--manifest` flag to see the manifest:
|
14
|
+
|
15
|
+
```shell
|
16
|
+
$ docker-shaball --manifest nginx:1.9 ruby:2.2
|
17
|
+
nginx:1.9 72d73c46937aaf8ca1efe566cac0564a05a0f1aeaef770658c8201726cfff50b
|
18
|
+
ruby:2.2 9372b27f3abf65e96955894809adf406afad67f1208eaa7600b9bf2898c09c51
|
19
|
+
```
|
data/Rakefile
ADDED
data/bin/docker-shaball
ADDED
@@ -0,0 +1,55 @@
|
|
1
|
+
#! /usr/bin/env ruby
|
2
|
+
|
3
|
+
require "clamp"
|
4
|
+
require "digest/sha1"
|
5
|
+
|
6
|
+
Clamp do
|
7
|
+
|
8
|
+
self.description = "Bundle docker images into a tar-ball, with a unique name based on content"
|
9
|
+
|
10
|
+
option "--pull", :flag, "pull the named images first"
|
11
|
+
|
12
|
+
option "--manifest", :flag, "just print the image manifest"
|
13
|
+
|
14
|
+
parameter "IMAGE ...", "image name"
|
15
|
+
|
16
|
+
def execute
|
17
|
+
if pull?
|
18
|
+
image_names.each do |name|
|
19
|
+
system("docker pull #{name}")
|
20
|
+
signal_error("docker pull failed") unless $?.success?
|
21
|
+
end
|
22
|
+
end
|
23
|
+
if manifest?
|
24
|
+
puts image_manifest
|
25
|
+
return
|
26
|
+
end
|
27
|
+
manifest_checksum = Digest::SHA1.hexdigest(image_manifest)
|
28
|
+
output_file_name = "#{manifest_checksum}.tar.gz"
|
29
|
+
system("set -o pipefail; docker save #{image_names.join(' ')} | gzip > #{output_file_name}")
|
30
|
+
if $?.success?
|
31
|
+
puts output_file_name
|
32
|
+
else
|
33
|
+
signal_error("docker save failed")
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
private
|
38
|
+
|
39
|
+
def image_names
|
40
|
+
image_list.map do |name|
|
41
|
+
name += ":latest" unless name.index(":")
|
42
|
+
name
|
43
|
+
end.uniq.sort
|
44
|
+
end
|
45
|
+
|
46
|
+
def image_manifest
|
47
|
+
inspect_output = `docker inspect -f '{{ .Config.Image }}' #{image_names.join(' ')}`
|
48
|
+
signal_error("docker inspect returned error") unless $?.success?
|
49
|
+
image_ids = inspect_output.lines.map(&:strip)
|
50
|
+
image_names.zip(image_ids).map do |image_name_and_id|
|
51
|
+
image_name_and_id.join(" ") + "\n"
|
52
|
+
end.join
|
53
|
+
end
|
54
|
+
|
55
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
|
7
|
+
spec.name = "docker-shaball"
|
8
|
+
spec.version = "0.1.0"
|
9
|
+
spec.authors = ["Mike Williams", "Luke Carter-Key"]
|
10
|
+
spec.email = ["mdub@dogbiscuit.org", "luke.carterkey@gmail.com"]
|
11
|
+
spec.summary = %q{Create a tar-ball containing some Docker images}
|
12
|
+
spec.homepage = "https://github.com/mdub/docker-shaball"
|
13
|
+
spec.license = "MIT"
|
14
|
+
|
15
|
+
spec.files = `git ls-files -z`.split("\x0")
|
16
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
17
|
+
|
18
|
+
spec.add_runtime_dependency "clamp", "~> 0.6.4"
|
19
|
+
|
20
|
+
spec.add_development_dependency "bundler", "~> 1.10"
|
21
|
+
spec.add_development_dependency "rake", "~> 10.4"
|
22
|
+
|
23
|
+
end
|
metadata
ADDED
@@ -0,0 +1,95 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: docker-shaball
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Mike Williams
|
8
|
+
- Luke Carter-Key
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2015-06-02 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: clamp
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
requirements:
|
18
|
+
- - "~>"
|
19
|
+
- !ruby/object:Gem::Version
|
20
|
+
version: 0.6.4
|
21
|
+
type: :runtime
|
22
|
+
prerelease: false
|
23
|
+
version_requirements: !ruby/object:Gem::Requirement
|
24
|
+
requirements:
|
25
|
+
- - "~>"
|
26
|
+
- !ruby/object:Gem::Version
|
27
|
+
version: 0.6.4
|
28
|
+
- !ruby/object:Gem::Dependency
|
29
|
+
name: bundler
|
30
|
+
requirement: !ruby/object:Gem::Requirement
|
31
|
+
requirements:
|
32
|
+
- - "~>"
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: '1.10'
|
35
|
+
type: :development
|
36
|
+
prerelease: false
|
37
|
+
version_requirements: !ruby/object:Gem::Requirement
|
38
|
+
requirements:
|
39
|
+
- - "~>"
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
version: '1.10'
|
42
|
+
- !ruby/object:Gem::Dependency
|
43
|
+
name: rake
|
44
|
+
requirement: !ruby/object:Gem::Requirement
|
45
|
+
requirements:
|
46
|
+
- - "~>"
|
47
|
+
- !ruby/object:Gem::Version
|
48
|
+
version: '10.4'
|
49
|
+
type: :development
|
50
|
+
prerelease: false
|
51
|
+
version_requirements: !ruby/object:Gem::Requirement
|
52
|
+
requirements:
|
53
|
+
- - "~>"
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: '10.4'
|
56
|
+
description:
|
57
|
+
email:
|
58
|
+
- mdub@dogbiscuit.org
|
59
|
+
- luke.carterkey@gmail.com
|
60
|
+
executables:
|
61
|
+
- docker-shaball
|
62
|
+
extensions: []
|
63
|
+
extra_rdoc_files: []
|
64
|
+
files:
|
65
|
+
- ".gitignore"
|
66
|
+
- Gemfile
|
67
|
+
- README.md
|
68
|
+
- Rakefile
|
69
|
+
- bin/docker-shaball
|
70
|
+
- docker-shaball.gemspec
|
71
|
+
homepage: https://github.com/mdub/docker-shaball
|
72
|
+
licenses:
|
73
|
+
- MIT
|
74
|
+
metadata: {}
|
75
|
+
post_install_message:
|
76
|
+
rdoc_options: []
|
77
|
+
require_paths:
|
78
|
+
- lib
|
79
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
80
|
+
requirements:
|
81
|
+
- - ">="
|
82
|
+
- !ruby/object:Gem::Version
|
83
|
+
version: '0'
|
84
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
85
|
+
requirements:
|
86
|
+
- - ">="
|
87
|
+
- !ruby/object:Gem::Version
|
88
|
+
version: '0'
|
89
|
+
requirements: []
|
90
|
+
rubyforge_project:
|
91
|
+
rubygems_version: 2.4.5
|
92
|
+
signing_key:
|
93
|
+
specification_version: 4
|
94
|
+
summary: Create a tar-ball containing some Docker images
|
95
|
+
test_files: []
|