docker-template 0.2.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +30 -4
- data/LICENSE +1 -1
- data/README.md +79 -14
- data/Rakefile +115 -38
- data/bin/docker-template +24 -10
- data/comp/bin +9 -0
- data/comp/list +83 -0
- data/comp/list.pak +0 -0
- data/lib/docker/template.rb +47 -61
- data/lib/docker/template/builder.rb +302 -0
- data/lib/docker/template/cache.rb +71 -0
- data/lib/docker/template/cli.rb +125 -0
- data/lib/docker/template/error.rb +120 -11
- data/lib/docker/template/logger.rb +128 -0
- data/lib/docker/template/metadata.rb +566 -103
- data/lib/docker/template/normal.rb +46 -0
- data/lib/docker/template/notify.rb +44 -0
- data/lib/docker/template/parser.rb +48 -38
- data/lib/docker/template/repo.rb +131 -97
- data/lib/docker/template/rootfs.rb +51 -41
- data/lib/docker/template/scratch.rb +96 -66
- data/lib/docker/template/version.rb +4 -2
- data/lib/erb/context.rb +29 -0
- data/shas.yml +11 -0
- data/templates/rootfs.erb +5 -0
- data/templates/rootfs/alpine.erb +71 -0
- data/templates/rootfs/ubuntu.erb +76 -0
- data/{lib/docker/template/templates → templates}/scratch.erb +0 -1
- metadata +64 -50
- data/lib/docker/template/alias.rb +0 -28
- data/lib/docker/template/ansi.rb +0 -85
- data/lib/docker/template/auth.rb +0 -25
- data/lib/docker/template/common.rb +0 -130
- data/lib/docker/template/config.rb +0 -80
- data/lib/docker/template/error/bad_exit_status.rb +0 -17
- data/lib/docker/template/error/bad_repo_name.rb +0 -15
- data/lib/docker/template/error/invalid_repo_type.rb +0 -16
- data/lib/docker/template/error/invalid_targz_file.rb +0 -15
- data/lib/docker/template/error/no_rootfs_copy_dir.rb +0 -15
- data/lib/docker/template/error/no_rootfs_mkimg.rb +0 -15
- data/lib/docker/template/error/no_setup_context_found.rb +0 -15
- data/lib/docker/template/error/not_implemented.rb +0 -15
- data/lib/docker/template/error/repo_not_found.rb +0 -16
- data/lib/docker/template/interface.rb +0 -118
- data/lib/docker/template/patches.rb +0 -9
- data/lib/docker/template/patches/array.rb +0 -11
- data/lib/docker/template/patches/hash.rb +0 -71
- data/lib/docker/template/patches/object.rb +0 -9
- data/lib/docker/template/patches/pathname.rb +0 -46
- data/lib/docker/template/patches/string.rb +0 -9
- data/lib/docker/template/routable.rb +0 -28
- data/lib/docker/template/simple.rb +0 -49
- data/lib/docker/template/stream.rb +0 -63
- data/lib/docker/template/templates/rootfs.erb +0 -8
- data/lib/docker/template/util.rb +0 -54
- data/lib/docker/template/util/copy.rb +0 -77
- data/lib/docker/template/util/data.rb +0 -26
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b98454a6b84d7f5e7b2e63e11270b21b92576e41
|
4
|
+
data.tar.gz: 02fd327a52266fdba7d9f8e69b5eb26ab982ac24
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f4d9b67269a7e314c2f3ffb39b5af079289489af980b9006eeebd4289071eb0ff533ed26ce98d7c773e5e402987ebfd2a53632edb91c9931a1ede2abc4b5190b
|
7
|
+
data.tar.gz: 27559d9dcaf2a2bdf488b506f4991f6d9273cd428237f293551b57115299724f6885778d92ea8093700ab2de5d37746dea640f60d3b801f3b2a4b6cad4e559ee
|
data/Gemfile
CHANGED
@@ -1,13 +1,39 @@
|
|
1
|
+
# ----------------------------------------------------------------------------
|
1
2
|
# Frozen-string-literal: true
|
2
|
-
# Copyright: 2015 Jordon Bedwell - Apache v2.0 License
|
3
|
+
# Copyright: 2015 - 2016 Jordon Bedwell - Apache v2.0 License
|
3
4
|
# Encoding: utf-8
|
5
|
+
# ----------------------------------------------------------------------------
|
4
6
|
|
5
7
|
source "https://rubygems.org"
|
6
8
|
gem "rake", :require => false
|
7
9
|
gemspec
|
8
10
|
|
9
|
-
group :
|
10
|
-
gem "
|
11
|
+
group :test do
|
12
|
+
gem "rspec", :require => false
|
13
|
+
gem "memory_profiler", :require => false
|
14
|
+
gem "luna-rspec-formatters", :require => false
|
15
|
+
gem "codeclimate-test-reporter", :require => false
|
16
|
+
gem "rubocop", :github => "bbatsov/rubocop", :branch => :master, :require => false
|
17
|
+
gem "luna-rubocop-formatters", :require => false
|
11
18
|
gem "benchmark-ips", :require => false
|
12
|
-
gem "
|
19
|
+
gem "rspec-helpers", :require => false
|
20
|
+
gem "cucumber", :require => false
|
21
|
+
end
|
22
|
+
|
23
|
+
group :development do
|
24
|
+
unless ENV["CI"]
|
25
|
+
gem "pry", :require => false
|
26
|
+
gem "msgpack", {
|
27
|
+
:require => false
|
28
|
+
}
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
group :travis, :optional => true do
|
33
|
+
gem "travis"
|
34
|
+
end
|
35
|
+
|
36
|
+
group :site, :optional => true do
|
37
|
+
gem "jekyll-assets", :github => "jekyll/jekyll-assets"
|
38
|
+
gem "jekyll", :github => "jekyll/jekyll"
|
13
39
|
end
|
data/LICENSE
CHANGED
data/README.md
CHANGED
@@ -1,20 +1,85 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
[![
|
1
|
+
# Docker Template
|
2
|
+
|
3
|
+
[![Build](https://travis-ci.org/envygeeks/docker-template.svg?branch=master)][travis]
|
4
|
+
[![Test](https://codeclimate.com/github/envygeeks/docker-template/badges/coverage.svg)][coverage]
|
5
|
+
[![Code](https://codeclimate.com/github/envygeeks/docker-template/badges/gpa.svg)][codeclimate]
|
6
|
+
[![Dependency](https://gemnasium.com/envygeeks/docker-template.svg)][gemnasium]
|
4
7
|
|
8
|
+
[gemnasium]: https://gemnasium.com/envygeeks/docker-template
|
5
9
|
[codeclimate]: https://codeclimate.com/github/envygeeks/docker-template
|
6
|
-
[
|
10
|
+
[coverage]: https://codeclimate.com/github/envygeeks/docker-template/coverage
|
7
11
|
[travis]: https://travis-ci.org/envygeeks/docker-template
|
8
12
|
|
9
|
-
|
13
|
+
Docker Template is an organization and templating system for Docker images. A way to make your life easier and more organized by having repositories within repositories that share data among multiple sets of images. It is currently used to build all the images for Jekyll and EnvyGeeks. To see the full docs instead of synapsis and snippets please visit https://github.com/envygeeks/docker-template/tree/master/docs
|
14
|
+
|
15
|
+
<!-- TOC depthFrom:1 depthTo:6 withLinks:1 updateOnSave:1 orderedList:0 -->
|
16
|
+
|
17
|
+
- [Docker Template](#docker-template)
|
18
|
+
- [Installation](#installation)
|
19
|
+
- [[Organization](https://github.com/envygeeks/docker-template/tree/master/docs/organization.md)](#organizationhttpsgithubcomenvygeeksdocker-templatetreemasterdocsorganizationmd)
|
20
|
+
- [[Metadata](https://github.com/envygeeks/docker-template/tree/master/docs/metadata.md)](#metadatahttpsgithubcomenvygeeksdocker-templatetreemasterdocsmetadatamd)
|
21
|
+
- [[Normal](https://github.com/envygeeks/docker-template/tree/master/docs/templates/normal.md)](#normalhttpsgithubcomenvygeeksdocker-templatetreemasterdocstemplatesnormalmd)
|
22
|
+
- [[Scratch](https://github.com/envygeeks/docker-template/tree/master/docs/templates/scratch.md)](#scratchhttpsgithubcomenvygeeksdocker-templatetreemasterdocstemplatesscratchmd)
|
23
|
+
- [[Copy/](https://github.com/envygeeks/docker-template/tree/master/docs/copy.md)](#copyhttpsgithubcomenvygeeksdocker-templatetreemasterdocscopymd)
|
24
|
+
- [Commands](#commands)
|
25
|
+
- [Build](#build)
|
26
|
+
- [List](#list)
|
27
|
+
|
28
|
+
<!-- /TOC -->
|
29
|
+
|
30
|
+
## Installation
|
31
|
+
|
32
|
+
```bash
|
33
|
+
sudo gem install docker-template
|
34
|
+
```
|
35
|
+
|
36
|
+
From Gemfile
|
37
|
+
|
38
|
+
```ruby
|
39
|
+
gem "docker-template", {
|
40
|
+
:github => "envygeeks/docker-template"
|
41
|
+
}
|
42
|
+
```
|
43
|
+
|
44
|
+
<!--
|
45
|
+
## [Organization](https://github.com/envygeeks/docker-template/tree/master/docs/organization.md)
|
46
|
+
## [Metadata](https://github.com/envygeeks/docker-template/tree/master/docs/metadata.md)
|
47
|
+
## [Normal](https://github.com/envygeeks/docker-template/tree/master/docs/templates/normal.md)
|
48
|
+
## [Scratch](https://github.com/envygeeks/docker-template/tree/master/docs/templates/scratch.md)
|
49
|
+
## [Copy/](https://github.com/envygeeks/docker-template/tree/master/docs/copy.md)
|
50
|
+
-->
|
51
|
+
|
52
|
+
## Commands
|
53
|
+
|
54
|
+
### Build
|
55
|
+
|
56
|
+
You can build a template by sending either `image`, `user/image`, `image:tag` or `user/image:tag`: `docker-template build image`. Build supports the following arguments:
|
57
|
+
|
58
|
+
```
|
59
|
+
Usage:
|
60
|
+
docker-template build [REPOS [OPTS]]
|
61
|
+
|
62
|
+
Options:
|
63
|
+
[--cache-only], [--no-cache-only] # Only cache your repositories, don't build.
|
64
|
+
[--clean-only], [--no-clean-only] # Only clean your repositories, don't build.
|
65
|
+
[--push-only], [--no-push-only] # Only push your repositories, don't build.
|
66
|
+
[--profile], [--no-profile] # Profile Memory.
|
67
|
+
[--tty], [--no-tty] # Enable TTY Output.
|
68
|
+
[--push], [--no-push] # Push Repo After Building.
|
69
|
+
[--cache], [--no-cache] # Cache your repositories to cache.
|
70
|
+
[--mocking], [--no-mocking] # Disable Certain Actions.
|
71
|
+
[--clean], [--no-clean] # Cleanup your caches.
|
72
|
+
|
73
|
+
Build all (or some) of your repositories
|
74
|
+
```
|
75
|
+
|
76
|
+
***You can send as many repos/images as you like, or you can send none, the lack of any repos/images will result in all of the possible images being built from your repos/ folder. This is good for automated building. NOTE: When building images we sort them, in that scratch images are built first, normal images are built second and aliases are done last, so that if you have dependencies within your dependencies hopefully they will get built first, however this is not always likely if your images rely on another normal image. In that case you might want to send a manual list for us.***
|
77
|
+
|
78
|
+
### List
|
10
79
|
|
11
|
-
|
12
|
-
multiple templates for multiple tags but those templates aren't actually templates,
|
13
|
-
they are JSON or YAML files and copy folders with tons of shared or split data.
|
14
|
-
The idea is that you can have many tags for a single repo and that each tag
|
15
|
-
can have many different things going on.
|
80
|
+
You can get a list of the possible images that can be built, an example:
|
16
81
|
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
82
|
+
```
|
83
|
+
envygeeks/alpine:3.3
|
84
|
+
envygeeks/alpine:latest -> envygeeks/alpine:3.3
|
85
|
+
```
|
data/Rakefile
CHANGED
@@ -1,57 +1,134 @@
|
|
1
|
+
# ----------------------------------------------------------------------------
|
1
2
|
# Frozen-string-literal: true
|
2
|
-
# Copyright: 2015 Jordon Bedwell - Apache v2.0 License
|
3
|
+
# Copyright: 2015 - 2016 Jordon Bedwell - Apache v2.0 License
|
3
4
|
# Encoding: utf-8
|
5
|
+
# ----------------------------------------------------------------------------
|
4
6
|
|
5
|
-
$LOAD_PATH.unshift(File.expand_path(
|
6
|
-
|
7
|
+
$LOAD_PATH.unshift(File.expand_path(
|
8
|
+
"../lib", __FILE__
|
9
|
+
))
|
10
|
+
|
11
|
+
# ----------------------------------------------------------------------------
|
12
|
+
|
13
|
+
require "simple/ansi"
|
7
14
|
require "rspec/core/rake_task"
|
15
|
+
require "luna/rubocop/rake/task"
|
8
16
|
require "open3"
|
9
17
|
|
18
|
+
# ----------------------------------------------------------------------------
|
19
|
+
|
10
20
|
task :default => [:spec]
|
11
21
|
RSpec::Core::RakeTask.new :spec
|
12
22
|
task :test => :spec
|
13
23
|
|
14
|
-
|
15
|
-
exec "bundle", "exec", "bin/docker-template", *ARGV[
|
16
|
-
1..-1
|
17
|
-
]
|
18
|
-
end
|
24
|
+
# ----------------------------------------------------------------------------
|
19
25
|
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
26
|
+
module CompList
|
27
|
+
module_function
|
28
|
+
|
29
|
+
# --------------------------------------------------------------------------
|
30
|
+
# Update the pak file to have all the completions.
|
31
|
+
# --------------------------------------------------------------------------
|
32
|
+
|
33
|
+
def update(data = get_commands, msgp = data.to_msgpack)
|
34
|
+
pak_file.binwrite(
|
35
|
+
msgp
|
36
|
+
)
|
37
|
+
end
|
24
38
|
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
file = File.open(".analysis", "w+")
|
34
|
-
Open3.popen3(cmd.shelljoin) do |_, out, err, _|
|
35
|
-
while data = out.gets
|
36
|
-
file.write data
|
37
|
-
if data =~ /\A==/
|
38
|
-
$stdout.print ansi.yellow(data)
|
39
|
-
|
40
|
-
elsif data !~ %r!\A[0-9\-]+!
|
41
|
-
$stdout.puts data
|
42
|
-
|
43
|
-
else
|
44
|
-
h, d = data.split(":", 2)
|
45
|
-
$stdout.print ansi.cyan(h)
|
46
|
-
$stdout.print ":", d
|
39
|
+
# --------------------------------------------------------------------------
|
40
|
+
|
41
|
+
def normalize_command(command)
|
42
|
+
if command.is_a?(Array)
|
43
|
+
then command.map do |key|
|
44
|
+
key.gsub(
|
45
|
+
/_/, "-"
|
46
|
+
)
|
47
47
|
end
|
48
|
+
else
|
49
|
+
command.gsub(
|
50
|
+
/_/, "-"
|
51
|
+
)
|
48
52
|
end
|
53
|
+
end
|
54
|
+
|
55
|
+
# --------------------------------------------------------------------------
|
56
|
+
# Provides the base "_reply" for your auto-complete data output.
|
57
|
+
# --------------------------------------------------------------------------
|
58
|
+
|
59
|
+
def base(const, skip = %w(help))
|
60
|
+
keys = const.all_commands.keys
|
61
|
+
return "_reply" => normalize_command(keys), "help" => {
|
62
|
+
"_reply" => normalize_command(keys) - skip
|
63
|
+
}
|
64
|
+
end
|
65
|
+
|
66
|
+
# --------------------------------------------------------------------------
|
67
|
+
|
68
|
+
def add_opts(out, const)
|
69
|
+
const.all_commands.each do |key, val, command = normalize_command(key)|
|
70
|
+
val.options.map do |_, opt|
|
71
|
+
out[command] ||= { "_reply" => [] }
|
72
|
+
ary = out[command][
|
73
|
+
"_reply"
|
74
|
+
]
|
75
|
+
|
76
|
+
if !opt.boolean?
|
77
|
+
ary << "#{
|
78
|
+
opt.switch_name
|
79
|
+
}="
|
49
80
|
|
50
|
-
|
51
|
-
|
52
|
-
|
81
|
+
else
|
82
|
+
ary << opt.switch_name
|
83
|
+
ary << "--no-#{opt.switch_name.gsub(
|
84
|
+
/\A--/, ""
|
85
|
+
)}"
|
86
|
+
end
|
87
|
+
|
88
|
+
ary |= \
|
89
|
+
opt.aliases
|
90
|
+
end
|
53
91
|
end
|
92
|
+
|
93
|
+
out
|
54
94
|
end
|
55
95
|
|
56
|
-
|
96
|
+
# --------------------------------------------------------------------------
|
97
|
+
# Recursively pulls out and set's up your commands and opts.
|
98
|
+
# --------------------------------------------------------------------------
|
99
|
+
|
100
|
+
def get_commands(const = Docker::Template::CLI)
|
101
|
+
out = base(
|
102
|
+
const
|
103
|
+
)
|
104
|
+
|
105
|
+
const.subcommands.each do |key, command = normalize_command(key)|
|
106
|
+
const_list = const.to_namespace.push(command.to_namespace)
|
107
|
+
out[command] = send(__method__, Thor::Namespace.resolv(
|
108
|
+
const_list
|
109
|
+
))
|
110
|
+
end
|
111
|
+
|
112
|
+
add_opts(
|
113
|
+
out, const
|
114
|
+
)
|
115
|
+
end
|
116
|
+
|
117
|
+
# --------------------------------------------------------------------------
|
118
|
+
|
119
|
+
def pak_file
|
120
|
+
Pathutil.new("bin/comp-list.pak").expand_path.tap(
|
121
|
+
&:touch
|
122
|
+
)
|
123
|
+
end
|
124
|
+
end
|
125
|
+
|
126
|
+
# ----------------------------------------------------------------------------
|
127
|
+
|
128
|
+
namespace :update do
|
129
|
+
task "comp-list" do
|
130
|
+
require "msgpack"
|
131
|
+
require "docker/template"
|
132
|
+
CompList.update
|
133
|
+
end
|
57
134
|
end
|
data/bin/docker-template
CHANGED
@@ -1,22 +1,36 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
+
# ----------------------------------------------------------------------------
|
2
3
|
# Frozen-string-literal: true
|
3
|
-
# Copyright: 2015 Jordon Bedwell - Apache v2.0 License
|
4
|
+
# Copyright: 2015 - 2016 Jordon Bedwell - Apache v2.0 License
|
4
5
|
# Encoding: utf-8
|
6
|
+
# ----------------------------------------------------------------------------
|
5
7
|
|
6
|
-
$LOAD_PATH.unshift(File.expand_path(
|
8
|
+
$LOAD_PATH.unshift(File.expand_path(
|
9
|
+
"../lib", __dir__
|
10
|
+
))
|
11
|
+
|
12
|
+
# ----------------------------------------------------------------------------
|
7
13
|
|
8
14
|
trap :SIGINT do
|
9
|
-
$stderr.puts
|
10
|
-
|
15
|
+
$stderr.puts Simple::Ansi.red(
|
16
|
+
"\nBye"
|
17
|
+
)
|
18
|
+
|
11
19
|
exit
|
12
20
|
end
|
13
21
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
require "bundler/setup"
|
22
|
+
# ----------------------------------------------------------------------------
|
23
|
+
|
24
|
+
begin
|
18
25
|
require "docker/template"
|
26
|
+
rescue LoadError
|
27
|
+
%w(bundler/setup docker/template).each do |k|
|
28
|
+
require k
|
29
|
+
end
|
19
30
|
end
|
20
31
|
|
21
|
-
|
22
|
-
|
32
|
+
# ----------------------------------------------------------------------------
|
33
|
+
# Time to play the game.
|
34
|
+
# ----------------------------------------------------------------------------
|
35
|
+
|
36
|
+
Docker::Template::CLI.start
|
data/comp/bin
ADDED
data/comp/list
ADDED
@@ -0,0 +1,83 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# ----------------------------------------------------------------------------
|
3
|
+
# Frozen-string-literal: true
|
4
|
+
# Copyright: 2016 Jordon Bedwell - MIT License
|
5
|
+
# Encoding: utf-8
|
6
|
+
# ----------------------------------------------------------------------------
|
7
|
+
# rubocop:disable Style/ElseAlignment
|
8
|
+
# ----------------------------------------------------------------------------
|
9
|
+
|
10
|
+
|
11
|
+
ARGV.shift
|
12
|
+
require "pathutil"
|
13
|
+
require "msgpack"
|
14
|
+
|
15
|
+
# ----------------------------------------------------------------------------
|
16
|
+
|
17
|
+
list = MessagePack.unpack(
|
18
|
+
Pathutil.new(__dir__).expand_path.join("list.pak").read
|
19
|
+
)
|
20
|
+
|
21
|
+
# ----------------------------------------------------------------------------
|
22
|
+
|
23
|
+
if ARGV.first == "build"
|
24
|
+
dir = Pathutil.new("repos").expand_path
|
25
|
+
|
26
|
+
if dir.directory?
|
27
|
+
list["build"] ||= { "_reply" => [] }
|
28
|
+
list["build"]["_reply"].push(*dir.children.map(
|
29
|
+
&:basename
|
30
|
+
))
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
# ----------------------------------------------------------------------------
|
35
|
+
|
36
|
+
def key?(obj, key)
|
37
|
+
obj["_reply"].include?(
|
38
|
+
key
|
39
|
+
)
|
40
|
+
end
|
41
|
+
|
42
|
+
# ----------------------------------------------------------------------------
|
43
|
+
|
44
|
+
def contains?(obj, key)
|
45
|
+
result = obj["_reply"].grep(/#{Regexp.escape(
|
46
|
+
key
|
47
|
+
)}/)
|
48
|
+
|
49
|
+
!result.empty?
|
50
|
+
end
|
51
|
+
|
52
|
+
# ----------------------------------------------------------------------------
|
53
|
+
|
54
|
+
def opt?(key)
|
55
|
+
key =~ /\A-{1,2}/
|
56
|
+
end
|
57
|
+
|
58
|
+
# ----------------------------------------------------------------------------
|
59
|
+
|
60
|
+
if ARGV.empty?
|
61
|
+
$stdout.puts list["_reply"].join(
|
62
|
+
" "
|
63
|
+
)
|
64
|
+
else
|
65
|
+
none = false
|
66
|
+
rtrn = list
|
67
|
+
|
68
|
+
ARGV.each_with_index do |key, index|
|
69
|
+
if rtrn.key?(key) then rtrn = rtrn[key]
|
70
|
+
elsif key?(rtrn, key) && !opt?(key) then none = true
|
71
|
+
elsif index + 1 == ARGV.size && contains?(rtrn, key) then next
|
72
|
+
elsif key?(rtrn, key) && opt?(key) then next
|
73
|
+
else none = true
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
unless none
|
78
|
+
rtrn = rtrn["_reply"]
|
79
|
+
$stdout.puts rtrn.join(
|
80
|
+
" "
|
81
|
+
)
|
82
|
+
end
|
83
|
+
end
|