buncker 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/NEWS +3 -0
- data/bin/buncker +50 -40
- data/build/build.sh +21 -1
- data/buncker.gemspec +2 -1
- data/lib/buncker/patches.rb +1 -0
- data/lib/buncker/patches/docker.rb +49 -0
- data/lib/buncker/version.rb +1 -1
- metadata +7 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: edb0ab76169ff8f781ae8d4a12f3709e41ef20dc
|
4
|
+
data.tar.gz: 39945d9f50f70e26ba10759cb5a6a91e3e039997
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3e5f46a878f45073a2ac882df67edae4e7d5146a0560c4ab2a294bb3dd4b8880fd521b199f68c5e42139bbca22bd427a3fb61979e55ec7cb6a5f7b3a4696922a
|
7
|
+
data.tar.gz: b326d9ae0dec35911fd8e310e129c349bbe2398a5ec52e9d76f97d89f5c55b5a136327a4f9dac1caf2a7fa3a9064a29564148dbd686c63f56dc19bccaa998f03
|
data/bin/buncker
CHANGED
@@ -1,5 +1,9 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
|
+
$: << File.expand_path('../../lib', __FILE__)
|
4
|
+
|
5
|
+
require 'buncker/patches'
|
6
|
+
|
3
7
|
require 'docker'
|
4
8
|
require 'fileutils'
|
5
9
|
require 'pathname'
|
@@ -7,64 +11,70 @@ require 'pathname'
|
|
7
11
|
name, tag = ARGV
|
8
12
|
|
9
13
|
cachedir = Pathname.pwd + '.buncker/cache'
|
10
|
-
cidfile = Pathname.pwd + '.buncker/cid'
|
11
14
|
|
12
15
|
FileUtils.mkdir_p cachedir
|
13
|
-
FileUtils.rm_f cidfile
|
14
16
|
|
15
|
-
|
17
|
+
build_sh = File.expand_path("../../build/build.sh", __FILE__)
|
18
|
+
|
19
|
+
def create_container opts
|
20
|
+
Docker::Container.create opts
|
21
|
+
rescue Docker::Error::NotFoundError
|
22
|
+
# try to pull
|
23
|
+
warn "Image #{image = opts['Image']} not found, trying to pull"
|
24
|
+
Docker::Image.create fromImage: image
|
25
|
+
Docker::Container.create opts
|
26
|
+
end
|
16
27
|
|
17
|
-
|
18
|
-
builder = Docker::Container.create(
|
28
|
+
builder = create_container(
|
19
29
|
'Image' => 'conjurinc/buncker:build',
|
20
30
|
'Volumes' => {
|
21
|
-
'/app/vendor' => {}
|
31
|
+
'/app/vendor' => {},
|
22
32
|
},
|
23
33
|
'OpenStdin' => true,
|
24
34
|
'StdinOnce' => true,
|
25
35
|
)
|
36
|
+
builder.start 'Binds' => ["#{cachedir}:/app/vendor"]
|
26
37
|
|
27
|
-
|
28
|
-
|
29
|
-
slug = File.open slugpath, 'w'
|
30
|
-
|
31
|
-
builder.attach(
|
32
|
-
stdin: StringIO.new(archive),
|
33
|
-
stdout: true,
|
34
|
-
stderr: true,
|
35
|
-
logs: true,
|
36
|
-
) do |stream, chunk|
|
37
|
-
case stream
|
38
|
-
when :stdout
|
39
|
-
slug.write chunk
|
40
|
-
else
|
41
|
-
print chunk
|
42
|
-
end
|
43
|
-
end;
|
44
|
-
|
45
|
-
builder.wait
|
46
|
-
builder.remove
|
47
|
-
|
48
|
-
slug.close
|
49
|
-
|
50
|
-
target = Docker::Container.create(
|
38
|
+
target = create_container(
|
51
39
|
'Image' => 'conjurinc/buncker',
|
52
40
|
'OpenStdin' => true,
|
53
41
|
'StdinOnce' => true,
|
54
|
-
'Cmd' => %w(tar
|
42
|
+
'Cmd' => %w(tar xvC/)
|
55
43
|
)
|
56
|
-
|
57
44
|
target.start
|
58
45
|
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
46
|
+
# fork the builder
|
47
|
+
open "|-", 'r' do |builder_pipe|
|
48
|
+
if builder_pipe.nil?
|
49
|
+
# in the child
|
50
|
+
builder.attach(
|
51
|
+
stdin: open('| git archive HEAD', 'r'),
|
52
|
+
stdout: true,
|
53
|
+
stderr: true,
|
54
|
+
logs: true,
|
55
|
+
) do |stream, chunk|
|
56
|
+
case stream
|
57
|
+
when :stdout
|
58
|
+
# push to target
|
59
|
+
$stdout.write chunk
|
60
|
+
else
|
61
|
+
$stderr.print chunk
|
62
|
+
end
|
63
|
+
end;
|
64
|
+
builder.wait
|
65
|
+
else
|
66
|
+
target.attach(
|
67
|
+
stdin: builder_pipe,
|
68
|
+
stdout: true,
|
69
|
+
stderr: true,
|
70
|
+
logs: true,
|
71
|
+
) do |stream, chunk|
|
72
|
+
print chunk
|
73
|
+
end
|
74
|
+
target.wait
|
75
|
+
end
|
66
76
|
end
|
67
77
|
|
68
|
-
|
78
|
+
builder.remove
|
69
79
|
target.commit repo: name, tag: tag
|
70
80
|
target.remove
|
data/build/build.sh
CHANGED
@@ -34,7 +34,27 @@ bundle install --deployment --without development test cucumber appliance >&2
|
|
34
34
|
bundle clean >&2
|
35
35
|
|
36
36
|
cd /
|
37
|
-
tar
|
37
|
+
tar cv \
|
38
|
+
--exclude 'app/vendor/bundle/ruby/*/build_info' \
|
39
|
+
--exclude 'app/vendor/bundle/ruby/*/cache' \
|
40
|
+
--exclude 'app/vendor/bundle/ruby/*/gems/*/doc' \
|
41
|
+
--exclude 'app/vendor/bundle/ruby/*/gems/*/doc-api' \
|
42
|
+
--exclude 'app/vendor/bundle/ruby/*/gems/*/examples' \
|
43
|
+
--exclude 'app/vendor/bundle/ruby/*/gems/*/guides' \
|
44
|
+
--exclude 'app/vendor/bundle/ruby/*/gems/*/java' \
|
45
|
+
--exclude 'app/vendor/bundle/ruby/*/gems/*/spec' \
|
46
|
+
--exclude 'app/vendor/bundle/ruby/*/gems/*/test' \
|
47
|
+
--exclude 'app/vendor/bundle/ruby/*/gems/*/tests' \
|
48
|
+
--exclude 'app/vendor/bundle/ruby/*/bundler/gems/*/doc' \
|
49
|
+
--exclude 'app/vendor/bundle/ruby/*/bundler/gems/*/doc-api' \
|
50
|
+
--exclude 'app/vendor/bundle/ruby/*/bundler/gems/*/examples' \
|
51
|
+
--exclude 'app/vendor/bundle/ruby/*/bundler/gems/*/guides' \
|
52
|
+
--exclude 'app/vendor/bundle/ruby/*/bundler/gems/*/java' \
|
53
|
+
--exclude 'app/vendor/bundle/ruby/*/bundler/gems/*/spec' \
|
54
|
+
--exclude 'app/vendor/bundle/ruby/*/bundler/gems/*/test' \
|
55
|
+
--exclude 'app/vendor/bundle/ruby/*/bundler/gems/*/tests' \
|
56
|
+
--exclude '.git' \
|
57
|
+
app
|
38
58
|
|
39
59
|
# some echo here is required, otherwise clients break connection prematurely
|
40
60
|
echo Slug built successfully. >&2
|
data/buncker.gemspec
CHANGED
@@ -17,7 +17,8 @@ Gem::Specification.new do |spec|
|
|
17
17
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
18
18
|
spec.require_paths = ["lib"]
|
19
19
|
|
20
|
-
|
20
|
+
# freeze version because of the monkey patch
|
21
|
+
spec.add_runtime_dependency "docker-api", "= 1.17"
|
21
22
|
|
22
23
|
spec.add_development_dependency "bundler", "~> 1.7"
|
23
24
|
spec.add_development_dependency "rake", "~> 10.0"
|
@@ -0,0 +1 @@
|
|
1
|
+
require 'buncker/patches/docker'
|
@@ -0,0 +1,49 @@
|
|
1
|
+
require 'docker'
|
2
|
+
require 'docker/util'
|
3
|
+
|
4
|
+
class Docker::Container
|
5
|
+
# the original doesn't work with SSL sockets
|
6
|
+
# due to inability to close just one half of them
|
7
|
+
#
|
8
|
+
# work around that by opening a separate connection for stdin
|
9
|
+
|
10
|
+
alias_method :orig_attach, :attach
|
11
|
+
|
12
|
+
def attach(options = {}, &block)
|
13
|
+
if (stdin = options.delete(:stdin))
|
14
|
+
stdin_thread = stream_stdin stdin
|
15
|
+
end
|
16
|
+
|
17
|
+
orig_attach options, &block
|
18
|
+
stdin_thread.join
|
19
|
+
end
|
20
|
+
|
21
|
+
private
|
22
|
+
|
23
|
+
# clones a connection and launches a thread to stream stdin
|
24
|
+
def stream_stdin stdin
|
25
|
+
conn = Docker::Connection.new connection.url, connection.options
|
26
|
+
|
27
|
+
Thread.new do
|
28
|
+
conn.post(
|
29
|
+
path_for(:attach),
|
30
|
+
{ stream: true, stdout: false, stderr: false, stdin: true },
|
31
|
+
hijack_block: Docker::Util.hijack_stdin_for(stdin)
|
32
|
+
)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
module Docker::Util
|
38
|
+
module_function
|
39
|
+
|
40
|
+
# hijack only for stdin (to work with SSL sockets)
|
41
|
+
def hijack_stdin_for(stdin)
|
42
|
+
lambda do |socket|
|
43
|
+
debug "hijack_stdin: copying stdin => socket"
|
44
|
+
IO.copy_stream stdin, socket
|
45
|
+
debug "hijack_stdin: closing hijacked write socket"
|
46
|
+
socket.close
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
data/lib/buncker/version.rb
CHANGED
metadata
CHANGED
@@ -1,27 +1,27 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: buncker
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Rafał Rzepecki
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-01-
|
11
|
+
date: 2015-01-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: docker-api
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - '='
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '1.17'
|
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
26
|
version: '1.17'
|
27
27
|
- !ruby/object:Gem::Dependency
|
@@ -64,6 +64,7 @@ files:
|
|
64
64
|
- Gemfile
|
65
65
|
- LICENSE
|
66
66
|
- Makefile
|
67
|
+
- NEWS
|
67
68
|
- README.md
|
68
69
|
- Rakefile
|
69
70
|
- app/Dockerfile
|
@@ -74,6 +75,8 @@ files:
|
|
74
75
|
- build/build.sh
|
75
76
|
- buncker.gemspec
|
76
77
|
- lib/buncker.rb
|
78
|
+
- lib/buncker/patches.rb
|
79
|
+
- lib/buncker/patches/docker.rb
|
77
80
|
- lib/buncker/version.rb
|
78
81
|
homepage: https://github.com/conjurinc/buncker
|
79
82
|
licenses:
|