docker-template 0.2.0 → 0.3.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/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
@@ -0,0 +1,76 @@
|
|
1
|
+
#!/bin/sh
|
2
|
+
[ "$DEBUG" ] && set -x
|
3
|
+
set -e
|
4
|
+
|
5
|
+
arch=$(uname -i)
|
6
|
+
rootfs=$(mktemp -d)
|
7
|
+
partner_url="https://partner-images.canonical.com/core"
|
8
|
+
dpkg_arch=$(dpkg --print-architecture)
|
9
|
+
tmp=$(mktemp -d)
|
10
|
+
|
11
|
+
cd $tmp
|
12
|
+
gpg --keyserver keyserver.ubuntu.com --recv-keys 7db87c81
|
13
|
+
sudo apt-get update && sudo apt-get install --no-install-recommends -y wget
|
14
|
+
wget -nv $partner_url/<%= @metadata.release %>/current/SHA256SUMS.gpg
|
15
|
+
wget -nv $partner_url/<%= @metadata.release %>/current/SHA256SUMS
|
16
|
+
gpg --verify SHA256SUMS.gpg SHA256SUMS
|
17
|
+
|
18
|
+
img=$(cat SHA256SUMS | grep "$dpkg_arch" | awk -F' *' '{ print $2 }' | sed -r 's/^\*//')
|
19
|
+
sha=$(cat SHA256SUMS | grep "$dpkg_arch" | awk -F' *' '{ print $1 }')
|
20
|
+
|
21
|
+
wget -nv "$partner_url/<%= @metadata.release %>/current/$img"
|
22
|
+
if [ "$(sha256sum $img | awk '{ print $1 }')" != "$sha" ]; then
|
23
|
+
echo "Bailing, the SHA256sum did not match."
|
24
|
+
fi
|
25
|
+
|
26
|
+
tar xzf $img -C $rootfs
|
27
|
+
cd -> /dev/null
|
28
|
+
|
29
|
+
rm -rf $rootfs/etc/hosts
|
30
|
+
rm -rf $rootfs/etc/resolv.conf
|
31
|
+
cp /etc/resolv.conf $rootfs/etc/resolv.conf
|
32
|
+
cp /etc/hosts $rootfs/etc/hosts
|
33
|
+
|
34
|
+
chroot "$rootfs" sh -ec "{
|
35
|
+
dpkg-divert --local --rename --add /sbin/initctl
|
36
|
+
dpkg-divert --local --rename --add /usr/sbin/update-rc.d
|
37
|
+
ln -s /bin/true /usr/sbin/update-rc.d
|
38
|
+
ln -s /bin/true /sbin/initctl
|
39
|
+
}"
|
40
|
+
|
41
|
+
chroot "$rootfs" sh -ec "{
|
42
|
+
sed -i 's/^#\s*\(deb.*universe\)$/\1/g' /etc/apt/sources.list
|
43
|
+
echo \"debconf debconf/frontend select Noninteractive\" | debconf-set-selections
|
44
|
+
echo 'Dpkg::Options { \"--force-confdef\"; \"--force-confold\"; }' > /etc/apt/apt.conf.d/local
|
45
|
+
echo \"exit 101\" > /usr/sbin/policy-rc.d policy-rc.d
|
46
|
+
sed -ri '/^(deb-src\s+|$|#)/d' /etc/apt/sources.list
|
47
|
+
chmod uog+x /usr/sbin/policy-rc.d
|
48
|
+
|
49
|
+
apt-get update
|
50
|
+
apt-get dist-upgrade -yf
|
51
|
+
apt-get install --no-install-recommends -yf \
|
52
|
+
locales deborphan
|
53
|
+
|
54
|
+
apt-get autoremove --purge $REMOVE -yf
|
55
|
+
apt-get autoremove --purge \$(deborphan --guess-all) deborphan -yf
|
56
|
+
<% if @metadata.pkgs? %>apt-get install --no-install-recommends -y <%= @metadata.pkgs %><% end %>
|
57
|
+
<% if @metadata.packages? %>apt-get install --no-install-recommends -y <%= @metadata.packages %><% end %>
|
58
|
+
<% if @metadata.package_cleanup? %>apt-get autoremove --purge -y <%= @metadata.package_cleanup %><% end %>
|
59
|
+
<% if @metadata.pkg_cleanup? %>apt-get autoremove --purge -y <%= @metadata.pkg_cleanup %><% end %>
|
60
|
+
apt-get autoremove --purge
|
61
|
+
apt-get autoclean
|
62
|
+
apt-get clean
|
63
|
+
|
64
|
+
rm -rf /tmp/remove
|
65
|
+
}"
|
66
|
+
|
67
|
+
cp -R $COPY_DIR/* $rootfs
|
68
|
+
mkdir -p $rootfs/etc/startup1.d
|
69
|
+
mkdir -p $rootfs/etc/startup2.d
|
70
|
+
mkdir -p $rootfs/etc/startup3.d
|
71
|
+
mkdir -p $rootfs/etc/shutdown.d
|
72
|
+
|
73
|
+
rm -rf $rootfs/etc/hosts
|
74
|
+
rm -rf $rootfs/etc/resolv.conf
|
75
|
+
docker-helper cleanup $rootfs
|
76
|
+
tar -zf $TAR_GZ --numeric-owner -C $rootfs -c .
|
metadata
CHANGED
@@ -1,85 +1,113 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: docker-template
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jordon Bedwell
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-04-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
name:
|
14
|
+
name: thor
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
19
|
+
version: '0.19'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '
|
26
|
+
version: '0.19'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: docker-api
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '1.
|
33
|
+
version: '1.28'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.28'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: activesupport
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '4.2'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '4.2'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: simple-ansi
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '1.0'
|
34
62
|
type: :runtime
|
35
63
|
prerelease: false
|
36
64
|
version_requirements: !ruby/object:Gem::Requirement
|
37
65
|
requirements:
|
38
66
|
- - "~>"
|
39
67
|
- !ruby/object:Gem::Version
|
40
|
-
version: '1.
|
68
|
+
version: '1.0'
|
41
69
|
- !ruby/object:Gem::Dependency
|
42
|
-
name:
|
70
|
+
name: pathutil
|
43
71
|
requirement: !ruby/object:Gem::Requirement
|
44
72
|
requirements:
|
45
73
|
- - "~>"
|
46
74
|
- !ruby/object:Gem::Version
|
47
|
-
version: '
|
48
|
-
type: :
|
75
|
+
version: '0.7'
|
76
|
+
type: :runtime
|
49
77
|
prerelease: false
|
50
78
|
version_requirements: !ruby/object:Gem::Requirement
|
51
79
|
requirements:
|
52
80
|
- - "~>"
|
53
81
|
- !ruby/object:Gem::Version
|
54
|
-
version: '
|
82
|
+
version: '0.7'
|
55
83
|
- !ruby/object:Gem::Dependency
|
56
|
-
name:
|
84
|
+
name: extras
|
57
85
|
requirement: !ruby/object:Gem::Requirement
|
58
86
|
requirements:
|
59
87
|
- - "~>"
|
60
88
|
- !ruby/object:Gem::Version
|
61
|
-
version: '
|
62
|
-
type: :
|
89
|
+
version: '0.1'
|
90
|
+
type: :runtime
|
63
91
|
prerelease: false
|
64
92
|
version_requirements: !ruby/object:Gem::Requirement
|
65
93
|
requirements:
|
66
94
|
- - "~>"
|
67
95
|
- !ruby/object:Gem::Version
|
68
|
-
version: '
|
96
|
+
version: '0.1'
|
69
97
|
- !ruby/object:Gem::Dependency
|
70
|
-
name:
|
98
|
+
name: json
|
71
99
|
requirement: !ruby/object:Gem::Requirement
|
72
100
|
requirements:
|
73
101
|
- - "~>"
|
74
102
|
- !ruby/object:Gem::Version
|
75
|
-
version: '
|
76
|
-
type: :
|
103
|
+
version: '1.8'
|
104
|
+
type: :runtime
|
77
105
|
prerelease: false
|
78
106
|
version_requirements: !ruby/object:Gem::Requirement
|
79
107
|
requirements:
|
80
108
|
- - "~>"
|
81
109
|
- !ruby/object:Gem::Version
|
82
|
-
version: '
|
110
|
+
version: '1.8'
|
83
111
|
description: Build and template awesome Docker images a variety of ways.
|
84
112
|
email:
|
85
113
|
- jordon@envygeeks.io
|
@@ -93,43 +121,29 @@ files:
|
|
93
121
|
- README.md
|
94
122
|
- Rakefile
|
95
123
|
- bin/docker-template
|
124
|
+
- comp/bin
|
125
|
+
- comp/list
|
126
|
+
- comp/list.pak
|
96
127
|
- lib/docker/template.rb
|
97
|
-
- lib/docker/template/
|
98
|
-
- lib/docker/template/
|
99
|
-
- lib/docker/template/
|
100
|
-
- lib/docker/template/common.rb
|
101
|
-
- lib/docker/template/config.rb
|
128
|
+
- lib/docker/template/builder.rb
|
129
|
+
- lib/docker/template/cache.rb
|
130
|
+
- lib/docker/template/cli.rb
|
102
131
|
- lib/docker/template/error.rb
|
103
|
-
- lib/docker/template/
|
104
|
-
- lib/docker/template/error/bad_repo_name.rb
|
105
|
-
- lib/docker/template/error/invalid_repo_type.rb
|
106
|
-
- lib/docker/template/error/invalid_targz_file.rb
|
107
|
-
- lib/docker/template/error/no_rootfs_copy_dir.rb
|
108
|
-
- lib/docker/template/error/no_rootfs_mkimg.rb
|
109
|
-
- lib/docker/template/error/no_setup_context_found.rb
|
110
|
-
- lib/docker/template/error/not_implemented.rb
|
111
|
-
- lib/docker/template/error/repo_not_found.rb
|
112
|
-
- lib/docker/template/interface.rb
|
132
|
+
- lib/docker/template/logger.rb
|
113
133
|
- lib/docker/template/metadata.rb
|
134
|
+
- lib/docker/template/normal.rb
|
135
|
+
- lib/docker/template/notify.rb
|
114
136
|
- lib/docker/template/parser.rb
|
115
|
-
- lib/docker/template/patches.rb
|
116
|
-
- lib/docker/template/patches/array.rb
|
117
|
-
- lib/docker/template/patches/hash.rb
|
118
|
-
- lib/docker/template/patches/object.rb
|
119
|
-
- lib/docker/template/patches/pathname.rb
|
120
|
-
- lib/docker/template/patches/string.rb
|
121
137
|
- lib/docker/template/repo.rb
|
122
138
|
- lib/docker/template/rootfs.rb
|
123
|
-
- lib/docker/template/routable.rb
|
124
139
|
- lib/docker/template/scratch.rb
|
125
|
-
- lib/docker/template/simple.rb
|
126
|
-
- lib/docker/template/stream.rb
|
127
|
-
- lib/docker/template/templates/rootfs.erb
|
128
|
-
- lib/docker/template/templates/scratch.erb
|
129
|
-
- lib/docker/template/util.rb
|
130
|
-
- lib/docker/template/util/copy.rb
|
131
|
-
- lib/docker/template/util/data.rb
|
132
140
|
- lib/docker/template/version.rb
|
141
|
+
- lib/erb/context.rb
|
142
|
+
- shas.yml
|
143
|
+
- templates/rootfs.erb
|
144
|
+
- templates/rootfs/alpine.erb
|
145
|
+
- templates/rootfs/ubuntu.erb
|
146
|
+
- templates/scratch.erb
|
133
147
|
homepage: http://github.com/envygeeks/docker-template/
|
134
148
|
licenses:
|
135
149
|
- MIT
|
@@ -142,7 +156,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
142
156
|
requirements:
|
143
157
|
- - ">="
|
144
158
|
- !ruby/object:Gem::Version
|
145
|
-
version:
|
159
|
+
version: 2.3.0
|
146
160
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
147
161
|
requirements:
|
148
162
|
- - ">="
|
@@ -150,7 +164,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
150
164
|
version: '0'
|
151
165
|
requirements: []
|
152
166
|
rubyforge_project:
|
153
|
-
rubygems_version: 2.
|
167
|
+
rubygems_version: 2.6.3
|
154
168
|
signing_key:
|
155
169
|
specification_version: 4
|
156
170
|
summary: Build and template Docker images a variety of ways.
|
@@ -1,28 +0,0 @@
|
|
1
|
-
module Docker
|
2
|
-
module Template
|
3
|
-
class Alias
|
4
|
-
def initialize(aliased)
|
5
|
-
@aliased = aliased
|
6
|
-
end
|
7
|
-
|
8
|
-
#
|
9
|
-
|
10
|
-
def build
|
11
|
-
Util.notify_alias(@aliased)
|
12
|
-
prebuild unless @aliased.parent_img
|
13
|
-
@aliased.parent_img.tag(@aliased.repo.to_tag_h)
|
14
|
-
@aliased.push
|
15
|
-
end
|
16
|
-
|
17
|
-
#
|
18
|
-
|
19
|
-
private
|
20
|
-
def prebuild
|
21
|
-
repo = @aliased.parent_repo
|
22
|
-
simple = @aliased.repo.type == "simple"
|
23
|
-
@aliased.class.new(repo, @aliased.rootfs_img) unless simple
|
24
|
-
@aliased.class.new(repo).build if simple
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|
data/lib/docker/template/ansi.rb
DELETED
@@ -1,85 +0,0 @@
|
|
1
|
-
# Frozen-string-literal: true
|
2
|
-
# Copyright: 2015 Jordon Bedwell - Apache v2.0 License
|
3
|
-
# Encoding: utf-8
|
4
|
-
|
5
|
-
module Docker
|
6
|
-
module Template
|
7
|
-
module Ansi
|
8
|
-
module_function
|
9
|
-
|
10
|
-
ESCAPE = format("%c", 27)
|
11
|
-
MATCH = /#{ESCAPE}\[(?:\d+)(?:;\d+)*(j|k|m|s|u|A|B|G)|\e\(B\e\[m/ix.freeze
|
12
|
-
COLORS = {
|
13
|
-
:red => 31,
|
14
|
-
:green => 32,
|
15
|
-
:black => 30,
|
16
|
-
:magenta => 35,
|
17
|
-
:yellow => 33,
|
18
|
-
:white => 37,
|
19
|
-
:blue => 34,
|
20
|
-
:cyan => 36
|
21
|
-
}
|
22
|
-
|
23
|
-
# Strip ANSI from the current string. It also strips cursor stuff,
|
24
|
-
# well some of it, and it also strips some other stuff that a lot of
|
25
|
-
# the other ANSI strippers don't.
|
26
|
-
|
27
|
-
def strip(str)
|
28
|
-
str.gsub MATCH, ""
|
29
|
-
end
|
30
|
-
|
31
|
-
# Reset the vterm view if it's supported. Depending on how badly
|
32
|
-
# your vterm is implemented it might reset rather than clear scrollback
|
33
|
-
# with a few empty lines added on the top.
|
34
|
-
|
35
|
-
def clear
|
36
|
-
$stdout.print(format("%c[H%c[2J", 27, 27))
|
37
|
-
end
|
38
|
-
|
39
|
-
#
|
40
|
-
|
41
|
-
def has?(str)
|
42
|
-
!!(str =~ MATCH)
|
43
|
-
end
|
44
|
-
|
45
|
-
# Jump the cursor up and then back down or just up and down. This is
|
46
|
-
# useful when streaming async downloads from something like Docker. It
|
47
|
-
# also works better than using `tput`
|
48
|
-
|
49
|
-
def jump(str = "", up: nil, down: nil, both: nil)
|
50
|
-
str = clear_line(str)
|
51
|
-
|
52
|
-
return format("%c[%dA%s%c[%dB", 27, up || both, str, 27, down || both) if (up && down) || both
|
53
|
-
up ? format("%c[%dA%s", 27, up, str) : format("%s%c[%dB", str, 27, down)
|
54
|
-
end
|
55
|
-
|
56
|
-
# Reset the color back to the default color so that you do not leak any
|
57
|
-
# colors when you move onto the next line. This is probably normally
|
58
|
-
# used as part of a wrapper so that we don't leak colors.
|
59
|
-
|
60
|
-
def reset(str = "")
|
61
|
-
@ansi_reset ||= format("%c[0m", 27)
|
62
|
-
"#{@ansi_reset}#{str}"
|
63
|
-
end
|
64
|
-
|
65
|
-
#
|
66
|
-
|
67
|
-
def clear_line(str = "")
|
68
|
-
@ansi_clear_line ||= format("%c[2K\r", 27)
|
69
|
-
"#{@ansi_clear_line}#{str}\r"
|
70
|
-
end
|
71
|
-
|
72
|
-
# SEE: `self::COLORS` for a list of methods. They are mostly
|
73
|
-
# standard base colors supported by pretty much any xterm-color, we do
|
74
|
-
# not need more than the base colors so we do not include them.
|
75
|
-
# Actually... if I'm honest we don't even need most of the
|
76
|
-
# base colors.
|
77
|
-
|
78
|
-
COLORS.each do |color, num|
|
79
|
-
define_method color do |str|
|
80
|
-
"#{format("%c", 27)}[#{num}m#{str}#{reset}"
|
81
|
-
end; module_function color
|
82
|
-
end
|
83
|
-
end
|
84
|
-
end
|
85
|
-
end
|
data/lib/docker/template/auth.rb
DELETED
@@ -1,25 +0,0 @@
|
|
1
|
-
module Docker
|
2
|
-
module Template
|
3
|
-
module Auth
|
4
|
-
module_function
|
5
|
-
|
6
|
-
def auth!
|
7
|
-
return unless login = credentials
|
8
|
-
login["auths"].each do |server, auth|
|
9
|
-
username, password = Base64.decode64(auth["auth"]).split(":", 2)
|
10
|
-
Docker.authenticate!({
|
11
|
-
"username" => username,
|
12
|
-
"serveraddress" => server,
|
13
|
-
"email" => auth["email"],
|
14
|
-
"password" => password
|
15
|
-
})
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
def credentials
|
20
|
-
path = Pathname.new("~/.docker/config.json").expand_path
|
21
|
-
JSON.parse(path.read) if path.exist?
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
@@ -1,130 +0,0 @@
|
|
1
|
-
# Frozen-string-literal: true
|
2
|
-
# Copyright: 2015 Jordon Bedwell - Apache v2.0 License
|
3
|
-
# Encoding: utf-8
|
4
|
-
|
5
|
-
module Docker
|
6
|
-
module Template
|
7
|
-
class Common
|
8
|
-
CopyMethods = [
|
9
|
-
:setup_context, :copy_global,
|
10
|
-
:copy_all, :copy_type, :copy_tag, :build_context,
|
11
|
-
:verify_context].freeze
|
12
|
-
|
13
|
-
def push
|
14
|
-
return if rootfs? || !Interface.push?
|
15
|
-
|
16
|
-
Auth.auth!
|
17
|
-
img = @img || Docker::Image.get(@repo.to_s)
|
18
|
-
logger = Stream.new.method(:log)
|
19
|
-
img.push(&logger)
|
20
|
-
end
|
21
|
-
|
22
|
-
#
|
23
|
-
|
24
|
-
def aliased?
|
25
|
-
@repo.tag != @repo.aliased && !rootfs?
|
26
|
-
end
|
27
|
-
|
28
|
-
#
|
29
|
-
|
30
|
-
def rootfs?
|
31
|
-
false
|
32
|
-
end
|
33
|
-
|
34
|
-
#
|
35
|
-
|
36
|
-
def parent_repo
|
37
|
-
return false unless aliased?
|
38
|
-
@parent_repo ||= begin
|
39
|
-
Repo.new(@repo.to_h.merge("tag" => @repo.aliased))
|
40
|
-
end
|
41
|
-
end
|
42
|
-
|
43
|
-
#
|
44
|
-
|
45
|
-
def parent_img
|
46
|
-
return false unless aliased?
|
47
|
-
@parent_img ||= Docker::Image.get(parent_repo.to_s)
|
48
|
-
rescue Docker::Error::NotFoundError
|
49
|
-
if aliased?
|
50
|
-
nil
|
51
|
-
end
|
52
|
-
end
|
53
|
-
|
54
|
-
#
|
55
|
-
|
56
|
-
def build
|
57
|
-
return Alias.new(self).build if aliased?
|
58
|
-
|
59
|
-
Ansi.clear
|
60
|
-
Util.notify_build(@repo, rootfs: rootfs?)
|
61
|
-
copy_build_and_verify
|
62
|
-
chdir_build
|
63
|
-
rescue SystemExit => exit_
|
64
|
-
unlink img: true
|
65
|
-
raise exit_
|
66
|
-
ensure
|
67
|
-
if rootfs?
|
68
|
-
unlink img: false else unlink
|
69
|
-
end
|
70
|
-
end
|
71
|
-
|
72
|
-
#
|
73
|
-
|
74
|
-
def chdir_build
|
75
|
-
Dir.chdir(@context) do
|
76
|
-
@img = Docker::Image.build_from_dir(".", &Stream.new.method(:log))
|
77
|
-
@img.tag rootfs?? @repo.to_rootfs_h : @repo.to_tag_h
|
78
|
-
push
|
79
|
-
end
|
80
|
-
end
|
81
|
-
|
82
|
-
#
|
83
|
-
|
84
|
-
private
|
85
|
-
def copy_build_and_verify
|
86
|
-
unless respond_to?(:setup_context, true)
|
87
|
-
raise Error::NoSetupContextFound
|
88
|
-
end
|
89
|
-
|
90
|
-
CopyMethods.each do |val|
|
91
|
-
send(val) if respond_to?(val, true)
|
92
|
-
end
|
93
|
-
end
|
94
|
-
|
95
|
-
private
|
96
|
-
def copy_tag
|
97
|
-
return if rootfs?
|
98
|
-
dir = @repo.copy_dir("tag", @repo.tag)
|
99
|
-
Util::Copy.directory(dir, @copy)
|
100
|
-
end
|
101
|
-
|
102
|
-
#
|
103
|
-
|
104
|
-
private
|
105
|
-
def copy_global
|
106
|
-
return if rootfs?
|
107
|
-
dir = Template.root.join(@repo.metadata["copy_dir"])
|
108
|
-
Util::Copy.directory(dir, @copy)
|
109
|
-
end
|
110
|
-
|
111
|
-
#
|
112
|
-
|
113
|
-
private
|
114
|
-
def copy_type
|
115
|
-
return unless !rootfs? && build_type = @repo.metadata["tags"][@repo.tag]
|
116
|
-
dir = @repo.copy_dir("type", build_type)
|
117
|
-
Util::Copy.directory(dir, @copy)
|
118
|
-
end
|
119
|
-
|
120
|
-
#
|
121
|
-
|
122
|
-
private
|
123
|
-
def copy_all
|
124
|
-
return if rootfs?
|
125
|
-
dir = @repo.copy_dir("all")
|
126
|
-
Util::Copy.directory(dir, @copy)
|
127
|
-
end
|
128
|
-
end
|
129
|
-
end
|
130
|
-
end
|