dockly 2.0.2 → 2.1.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.
- data/README.md +1 -1
- data/lib/dockly/build_cache/base.rb +2 -1
- data/lib/dockly/build_cache/docker.rb +36 -19
- data/lib/dockly/deb.rb +8 -8
- data/lib/dockly/version.rb +1 -1
- data/snippets/file_diff_docker_import.erb +1 -1
- data/spec/dockly/deb_spec.rb +20 -7
- metadata +2 -2
data/README.md
CHANGED
@@ -283,7 +283,7 @@ In addition to the above attributes, `deb` has the following references:
|
|
283
283
|
- required: `false`
|
284
284
|
- default: `nil`
|
285
285
|
- class: `Dockly::Foreman`
|
286
|
-
- description: any Foreman scripts used in the deb
|
286
|
+
- description: any Foreman scripts used in the deb.
|
287
287
|
|
288
288
|
`rpm`
|
289
289
|
-----
|
@@ -9,7 +9,7 @@ class Dockly::BuildCache::Base
|
|
9
9
|
dsl_attribute :s3_bucket, :s3_object_prefix, :use_latest,
|
10
10
|
:hash_command, :build_command, :parameter_commands,
|
11
11
|
:base_dir, :command_dir, :output_dir, :tmp_dir,
|
12
|
-
:keep_old_files
|
12
|
+
:keep_old_files, :safe_push_cache
|
13
13
|
|
14
14
|
default_value :use_latest, false
|
15
15
|
default_value :parameter_commands, {}
|
@@ -17,6 +17,7 @@ class Dockly::BuildCache::Base
|
|
17
17
|
default_value :output_dir, '.'
|
18
18
|
default_value :tmp_dir, Dir.tmpdir
|
19
19
|
default_value :keep_old_files, false
|
20
|
+
default_value :safe_push_cache, false
|
20
21
|
|
21
22
|
def execute!
|
22
23
|
debug "Looking for cache for hash: #{hash_output}"
|
@@ -25,25 +25,11 @@ class Dockly::BuildCache::Docker < Dockly::BuildCache::Base
|
|
25
25
|
ensure_present! :output_dir
|
26
26
|
if cache = pull_from_s3(version)
|
27
27
|
debug "inserting to #{output_directory}"
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
'Cmd' => ['/bin/bash', '-c', [
|
34
|
-
"mkdir -p #{File.dirname(output_directory)}",
|
35
|
-
'&&',
|
36
|
-
"tar #{tar_flags} #{File.join('/', 'host', path)} -C #{File.dirname(output_directory)}"
|
37
|
-
].join(' ')
|
38
|
-
],
|
39
|
-
'Volumes' => {
|
40
|
-
File.join('/', 'host', path_parent) => { path_parent => 'rw' }
|
41
|
-
}
|
42
|
-
)
|
43
|
-
container.start('Binds' => ["#{path_parent}:#{File.join('/', 'host', path_parent)}"])
|
44
|
-
result = container.wait['StatusCode']
|
45
|
-
raise "Got bad status code when copying build cache: #{result}" unless result.zero?
|
46
|
-
self.image = container.commit
|
28
|
+
if safe_push_cache
|
29
|
+
push_cache_safe(cache)
|
30
|
+
else
|
31
|
+
push_cache_with_volumes(cache)
|
32
|
+
end
|
47
33
|
debug "inserted cache into #{output_directory}"
|
48
34
|
cache.close
|
49
35
|
else
|
@@ -51,6 +37,37 @@ class Dockly::BuildCache::Docker < Dockly::BuildCache::Base
|
|
51
37
|
end
|
52
38
|
end
|
53
39
|
|
40
|
+
def push_cache_safe(cache)
|
41
|
+
container = image.run("mkdir -p #{File.dirname(output_directory)}")
|
42
|
+
image_with_dir = container.tap(&:wait).commit
|
43
|
+
self.image = image_with_dir.insert_local(
|
44
|
+
'localPath' => cache.path,
|
45
|
+
'outputPath' => File.dirname(output_directory)
|
46
|
+
)
|
47
|
+
end
|
48
|
+
|
49
|
+
def push_cache_with_volumes(cache)
|
50
|
+
path = File.expand_path(cache.path)
|
51
|
+
path_parent = File.dirname(path)
|
52
|
+
tar_flags = keep_old_files ? '-xkf' : 'xf'
|
53
|
+
container = ::Docker::Container.create(
|
54
|
+
'Image' => image.id,
|
55
|
+
'Cmd' => ['/bin/bash', '-c', [
|
56
|
+
"mkdir -p #{File.dirname(output_directory)}",
|
57
|
+
'&&',
|
58
|
+
"tar #{tar_flags} #{File.join('/', 'host', path)} -C #{File.dirname(output_directory)}"
|
59
|
+
].join(' ')
|
60
|
+
],
|
61
|
+
'Volumes' => {
|
62
|
+
File.join('/', 'host', path_parent) => { path_parent => 'rw' }
|
63
|
+
}
|
64
|
+
)
|
65
|
+
container.start('Binds' => ["#{path_parent}:#{File.join('/', 'host', path_parent)}"])
|
66
|
+
result = container.wait['StatusCode']
|
67
|
+
raise "Got bad status code when copying build cache: #{result}" unless result.zero?
|
68
|
+
self.image = container.commit
|
69
|
+
end
|
70
|
+
|
54
71
|
def copy_output_dir(container)
|
55
72
|
ensure_present! :output_dir
|
56
73
|
file_path = File.join(tmp_dir,s3_object(hash_output))
|
data/lib/dockly/deb.rb
CHANGED
@@ -10,7 +10,7 @@ class Dockly::Deb
|
|
10
10
|
:post_uninstall, :s3_bucket, :files, :app_user, :vendor
|
11
11
|
|
12
12
|
dsl_class_attribute :docker, Dockly::Docker
|
13
|
-
dsl_class_attribute :foreman, Dockly::Foreman
|
13
|
+
dsl_class_attribute :foreman, Dockly::Foreman, type: Array
|
14
14
|
|
15
15
|
default_value :version, '0.0'
|
16
16
|
default_value :release, '0'
|
@@ -127,14 +127,14 @@ private
|
|
127
127
|
end
|
128
128
|
|
129
129
|
def add_foreman(package)
|
130
|
-
return if foreman.
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
package.input('.')
|
130
|
+
return if (foreman || []).empty?
|
131
|
+
foreman.each do |fore|
|
132
|
+
info "adding foreman export '#{fore.name}'"
|
133
|
+
fore.create!
|
134
|
+
package.attributes[:prefix] = fore.init_dir
|
135
|
+
Dir.chdir(fore.build_dir) { package.input('.') }
|
136
|
+
package.attributes[:prefix] = nil
|
136
137
|
end
|
137
|
-
package.attributes[:prefix] = nil
|
138
138
|
end
|
139
139
|
|
140
140
|
def add_files(package)
|
data/lib/dockly/version.rb
CHANGED
@@ -13,7 +13,7 @@ docker_import() {
|
|
13
13
|
|
14
14
|
worked=1
|
15
15
|
for attempt in {1..200}; do
|
16
|
-
[[ $worked != 0]] || break
|
16
|
+
[[ $worked != 0 ]] || break
|
17
17
|
docker_import && worked=0 || (log "fetch: attempt $attempt failed, sleeping 30"; sleep 30)
|
18
18
|
done
|
19
19
|
[[ $worked != 0 ]] && fatal "fetch: failed to import diff image"
|
data/spec/dockly/deb_spec.rb
CHANGED
@@ -25,23 +25,36 @@ describe Dockly::Deb do
|
|
25
25
|
end
|
26
26
|
end
|
27
27
|
|
28
|
-
context 'when it has
|
28
|
+
context 'when it has foreman exports' do
|
29
|
+
let(:contents) { `dpkg --contents #{filename}` }
|
30
|
+
|
29
31
|
before do
|
30
32
|
subject.foreman do
|
31
|
-
name 'foreman'
|
32
|
-
init_dir '/etc/systemd/system'
|
33
|
+
name 'systemd-foreman'
|
33
34
|
build_dir 'build/foreman'
|
35
|
+
init_dir '/etc/systemd/system'
|
34
36
|
procfile File.join(File.dirname(__FILE__), '..', 'fixtures', 'Procfile')
|
35
37
|
user 'root'
|
36
38
|
type 'systemd'
|
37
39
|
prefix '/bin/sh'
|
38
40
|
end
|
39
|
-
end
|
40
41
|
|
41
|
-
|
42
|
+
subject.foreman do
|
43
|
+
name 'upstart-foreman'
|
44
|
+
build_dir 'build/foreman'
|
45
|
+
init_dir '/etc/systemd/system'
|
46
|
+
procfile File.join(File.dirname(__FILE__), '..', 'fixtures', 'Procfile')
|
47
|
+
user 'root'
|
48
|
+
type 'upstart'
|
49
|
+
prefix '/bin/sh'
|
50
|
+
end
|
51
|
+
|
42
52
|
subject.create_package!
|
43
|
-
|
44
|
-
|
53
|
+
end
|
54
|
+
|
55
|
+
it 'exports the foreman to the deb', :cur do
|
56
|
+
expect(contents).to match(/upstart-foreman/)
|
57
|
+
expect(contents).to match(/systemd-foreman/)
|
45
58
|
end
|
46
59
|
end
|
47
60
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dockly
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0
|
4
|
+
version: 2.1.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2015-
|
12
|
+
date: 2015-04-24 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: clamp
|