nutkins 0.11.0 → 0.12.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/nutkins/docker_builder.rb +46 -27
- data/lib/nutkins/version.rb +1 -1
- data/readme.md +3 -3
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 30d41118cac65bc2af20312bb21560e8465430f4
|
4
|
+
data.tar.gz: 7bb9fb87a3d56797d2ef774c86da9ebdf5d6c6eb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e1378926ff0871fb1126383ec776d13606edc7620b5635ca21ba765c984d787da0ab7404f7da87e7cddd4ea14d62326cf5b1dc90519bbff484a63fc799b7db49
|
7
|
+
data.tar.gz: 9a8d6ab3159a5717d07a0aa43a814dbab8695a7aaf6fc3987141fba0c59e55ba7847c0a769d9a47502ea8e8578fad2eab43c6f6302a20771222772c75b94b311
|
@@ -36,8 +36,7 @@ module Nutkins::Docker::Builder
|
|
36
36
|
# docker run is always used and forms the basis of the cache key
|
37
37
|
run_args = nil
|
38
38
|
env_args = nil
|
39
|
-
|
40
|
-
add_files_dest = nil
|
39
|
+
copies = []
|
41
40
|
|
42
41
|
case cmd
|
43
42
|
when "run"
|
@@ -46,31 +45,48 @@ module Nutkins::Docker::Builder
|
|
46
45
|
else
|
47
46
|
run_args = cmd_args.join ' && '
|
48
47
|
end
|
49
|
-
when "
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
48
|
+
when "copy"
|
49
|
+
if cmd_args.kind_of? String
|
50
|
+
all_copy_args = [ cmd_args ]
|
51
|
+
else
|
52
|
+
all_copy_args = cmd_args
|
53
|
+
end
|
54
|
+
|
55
|
+
copies = all_copy_args.map do |copy_args|
|
56
|
+
*add_files, add_files_dest = copy_args.split ' '
|
57
|
+
add_files = add_files.map { |src| Dir.glob src }.flatten
|
58
|
+
# ensure checksum of each file is embedded into run command
|
59
|
+
# if any file changes the cache is dirtied
|
60
|
+
|
61
|
+
if not run_args
|
62
|
+
run_args = '#(nop) copy '
|
63
|
+
else
|
64
|
+
run_args += ';'
|
65
|
+
end
|
66
|
+
|
67
|
+
run_args += add_files.map do |src|
|
68
|
+
if File.directory? src
|
69
|
+
md5 = Digest::MD5.new
|
70
|
+
update_md5_dir = Proc.new do |dir|
|
71
|
+
Dir.glob("#{dir}/*").each do |dir_entry|
|
72
|
+
if File.directory? dir_entry
|
73
|
+
update_md5_dir.call dir_entry
|
74
|
+
else
|
75
|
+
md5.update(File.read dir_entry)
|
76
|
+
end
|
63
77
|
end
|
64
78
|
end
|
79
|
+
|
80
|
+
update_md5_dir.call src
|
81
|
+
hash = md5.hexdigest
|
82
|
+
else
|
83
|
+
hash = Digest::MD5.file(src).to_s
|
65
84
|
end
|
85
|
+
src + ':' + hash
|
86
|
+
end.push(add_files_dest).join(' ')
|
66
87
|
|
67
|
-
|
68
|
-
|
69
|
-
else
|
70
|
-
hash = Digest::MD5.file(src).to_s
|
71
|
-
end
|
72
|
-
src + ':' + hash
|
73
|
-
end.push(add_files_dest).join(' ')
|
88
|
+
{ srcs: add_files, dest: add_files_dest }
|
89
|
+
end
|
74
90
|
when "cmd", "entrypoint", "env", "expose", "label", "onbuild", "user", "volume", "workdir"
|
75
91
|
env_args = cmd + ' ' + (cmd_args.kind_of?(String) ? cmd_args : JSON.dump(cmd_args))
|
76
92
|
run_args = "#(nop) #{env_args}"
|
@@ -104,10 +120,13 @@ module Nutkins::Docker::Builder
|
|
104
120
|
|
105
121
|
cont_id = `docker ps -aq`.lines.first.strip
|
106
122
|
begin
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
123
|
+
unless copies.empty?
|
124
|
+
copies.each do |copy|
|
125
|
+
copy[:srcs].each do |src|
|
126
|
+
puts "copy #{src} -> #{cont_id}:#{copy[:dest]}"
|
127
|
+
if not Docker.run 'cp', src, "#{cont_id}:#{copy[:dest]}"
|
128
|
+
raise "could not copy #{src} to #{cont_id}:#{copy[:dest]}"
|
129
|
+
end
|
111
130
|
end
|
112
131
|
end
|
113
132
|
end
|
data/lib/nutkins/version.rb
CHANGED
data/readme.md
CHANGED
@@ -66,13 +66,13 @@ build:
|
|
66
66
|
- apt-get update
|
67
67
|
- apt-get install -y vim zsh less nano rsync git net-tools
|
68
68
|
- groupadd -g 5496 sslcerts
|
69
|
-
-
|
69
|
+
- copy: bin/* /bin/
|
70
70
|
- entrypoint: ["/bin/smell-baron"]
|
71
71
|
```
|
72
72
|
|
73
73
|
The `resources` section downloads files to local directories so that they can be used in the image. In the case of `confd` it also extracts a file from a `tar.gz` compressed archive.
|
74
74
|
|
75
|
-
The `commands` section is like a `Dockerfile` and is used to build a container. In this case it runs multiple commands,
|
75
|
+
The `commands` section is like a `Dockerfile` and is used to build a container. In this case it runs multiple commands, copies some files to the image and sets an `entrypoint`. This image would be tagged `myorg/base:0.0.1`. The image name comes from the subdirectory but can be overriden along with the `version`:
|
76
76
|
|
77
77
|
```yaml
|
78
78
|
base: ubuntu:16.04
|
@@ -92,7 +92,7 @@ This will output various information as it builds the image. If the same command
|
|
92
92
|
```bash
|
93
93
|
% nutkins build base
|
94
94
|
cached: apt-get update && apt-get install -y vim zsh less nano rsync git net-tools && groupadd -g 5496 sslcerts
|
95
|
-
cached: #(nop)
|
95
|
+
cached: #(nop) copy bin/confd:33472f6b8f9522ec7bdb01a8feeb03fb bin/etcdctl:8edfaac7c726e8231c6e0e8f75ffb678 bin/smell-baron:909345dcbc4a029d42f39278486a32b9 /bin/
|
96
96
|
cached: #(nop) entrypoint ["/bin/smell-baron"]
|
97
97
|
unchanged image: myorg/base:0.0.1
|
98
98
|
```
|