qtc-sdk 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/.gitignore +18 -18
- data/Changelog.md +14 -6
- data/Gemfile +4 -4
- data/LICENSE.txt +22 -22
- data/README.md +44 -44
- data/Rakefile +1 -1
- data/bin/qtc-cli +13 -13
- data/lib/qtc/cli/commands.rb +15 -15
- data/lib/qtc/cli/common.rb +146 -91
- data/lib/qtc/cli/eds/base.rb +27 -27
- data/lib/qtc/cli/eds/commands.rb +20 -20
- data/lib/qtc/cli/eds/instances.rb +30 -30
- data/lib/qtc/cli/mar/apps.rb +116 -125
- data/lib/qtc/cli/mar/base.rb +60 -60
- data/lib/qtc/cli/mar/commands.rb +221 -199
- data/lib/qtc/cli/mar/debug.rb +87 -86
- data/lib/qtc/cli/mar/domains.rb +35 -38
- data/lib/qtc/cli/mar/env.rb +38 -40
- data/lib/qtc/cli/mar/repository.rb +24 -26
- data/lib/qtc/cli/mar/ssl_certificates.rb +40 -42
- data/lib/qtc/cli/mar/stack.rb +29 -0
- data/lib/qtc/cli/mdb/base.rb +47 -43
- data/lib/qtc/cli/mdb/commands.rb +43 -31
- data/lib/qtc/cli/mdb/instances.rb +79 -60
- data/lib/qtc/cli/platform/clouds.rb +33 -15
- data/lib/qtc/cli/platform/commands.rb +132 -65
- data/lib/qtc/cli/platform/datacenters.rb +23 -21
- data/lib/qtc/cli/platform/ssh_keys.rb +41 -41
- data/lib/qtc/cli/platform/user.rb +25 -25
- data/lib/qtc/cli/platform/vpn.rb +93 -0
- data/lib/qtc/client.rb +170 -170
- data/lib/qtc/eds/client.rb +116 -116
- data/lib/qtc/eds/collection.rb +124 -124
- data/lib/qtc/eds/user_collection.rb +13 -13
- data/lib/qtc/eds/usergroup_collection.rb +41 -41
- data/lib/qtc/errors.rb +13 -11
- data/lib/qtc/version.rb +3 -3
- data/lib/qtc-sdk.rb +1 -1
- data/qtc-sdk.gemspec +28 -28
- data/spec/unit/qtc/client_spec.rb +147 -147
- metadata +20 -19
- data/lib/qtc/mws/client.rb +0 -89
data/lib/qtc/cli/mar/commands.rb
CHANGED
@@ -1,199 +1,221 @@
|
|
1
|
-
require_relative 'apps'
|
2
|
-
require_relative 'domains'
|
3
|
-
require_relative 'ssl_certificates'
|
4
|
-
require_relative 'env'
|
5
|
-
require_relative 'repository'
|
6
|
-
require_relative 'debug'
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
c.
|
11
|
-
c.
|
12
|
-
|
13
|
-
|
14
|
-
end
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
c.
|
19
|
-
c.
|
20
|
-
c.
|
21
|
-
c.option '--
|
22
|
-
c.
|
23
|
-
|
24
|
-
|
25
|
-
end
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
c.
|
30
|
-
c.
|
31
|
-
c.option '--
|
32
|
-
c.
|
33
|
-
|
34
|
-
|
35
|
-
end
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
c.
|
40
|
-
c.
|
41
|
-
c.
|
42
|
-
|
43
|
-
raise ArgumentError.new('NAME is required') if args[
|
44
|
-
Qtc::Cli::Mar::Apps.new.create(args[0],
|
45
|
-
end
|
46
|
-
end
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
c.
|
51
|
-
c.
|
52
|
-
c.option '--
|
53
|
-
c.
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
c.
|
61
|
-
c.
|
62
|
-
c.option '--
|
63
|
-
c.
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
c.
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
c.
|
85
|
-
c.
|
86
|
-
c.option '--
|
87
|
-
c.option '--
|
88
|
-
c.action do |args, options|
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
c.
|
96
|
-
c.
|
97
|
-
c.option '--
|
98
|
-
c.
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
c.
|
107
|
-
c.
|
108
|
-
c.
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
c.
|
117
|
-
c.
|
118
|
-
c.option '--
|
119
|
-
c.
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
c.
|
128
|
-
c.
|
129
|
-
c.option '--
|
130
|
-
c.
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
c.
|
153
|
-
c.
|
154
|
-
c.
|
155
|
-
|
156
|
-
|
157
|
-
Qtc::Cli::Mar::
|
158
|
-
end
|
159
|
-
end
|
160
|
-
|
161
|
-
command 'mar
|
162
|
-
c.syntax = 'qtc-cli mar
|
163
|
-
c.description = '
|
164
|
-
c.option '--app APP', String, 'App instance id'
|
165
|
-
c.option '--remote REMOTE', String, 'Git remote to use, eg "staging"'
|
166
|
-
c.action do |args, options|
|
167
|
-
Qtc::Cli::Mar::
|
168
|
-
end
|
169
|
-
end
|
170
|
-
|
171
|
-
command 'mar
|
172
|
-
c.syntax = 'qtc-cli mar
|
173
|
-
c.
|
174
|
-
c.
|
175
|
-
c.
|
176
|
-
|
177
|
-
|
178
|
-
end
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
c.
|
183
|
-
c.
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
c.
|
193
|
-
c.option '--
|
194
|
-
c.
|
195
|
-
|
196
|
-
|
197
|
-
Qtc::Cli::Mar::
|
198
|
-
end
|
199
|
-
end
|
1
|
+
require_relative 'apps'
|
2
|
+
require_relative 'domains'
|
3
|
+
require_relative 'ssl_certificates'
|
4
|
+
require_relative 'env'
|
5
|
+
require_relative 'repository'
|
6
|
+
require_relative 'debug'
|
7
|
+
require_relative 'stack'
|
8
|
+
|
9
|
+
command 'mar list' do |c|
|
10
|
+
c.syntax = 'qtc-cli mar list'
|
11
|
+
c.description = 'List all apps'
|
12
|
+
c.action do |args, options|
|
13
|
+
Qtc::Cli::Mar::Apps.new.list
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
command 'mar show' do |c|
|
18
|
+
c.syntax = 'qtc-cli mar show'
|
19
|
+
c.description = 'Show app details'
|
20
|
+
c.example 'Show app details for app with instance id: mar-eu-1-example', 'qtc-cli mar show --app mar-eu-1-example'
|
21
|
+
c.option '--app APP', String, 'App instance id'
|
22
|
+
c.option '--remote REMOTE', String, 'Git remote to use, eg "staging"'
|
23
|
+
c.action do |args, options|
|
24
|
+
Qtc::Cli::Mar::Apps.new.show(options)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
command 'mar restart' do |c|
|
29
|
+
c.syntax = 'qtc-cli mar restart'
|
30
|
+
c.description = 'Restart app'
|
31
|
+
c.option '--app APP', String, 'App instance id'
|
32
|
+
c.option '--remote REMOTE', String, 'Git remote to use, eg "staging"'
|
33
|
+
c.action do |args, options|
|
34
|
+
Qtc::Cli::Mar::Apps.new.restart(options)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
command 'mar create' do |c|
|
39
|
+
c.syntax = 'qtc-cli mar create NAME'
|
40
|
+
c.description = 'Create a new app instance'
|
41
|
+
c.option '--size SIZE', String, 'App runtime size'
|
42
|
+
c.action do |args, options|
|
43
|
+
raise ArgumentError.new('NAME is required') if args[0].nil?
|
44
|
+
Qtc::Cli::Mar::Apps.new.create(args[0], options)
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
command 'mar stack' do |c|
|
49
|
+
c.syntax = 'qtc-cli mar stack'
|
50
|
+
c.description = 'Get app stack'
|
51
|
+
c.option '--app APP', String, 'App instance id'
|
52
|
+
c.option '--remote REMOTE', String, 'Git remote to use, eg "staging"'
|
53
|
+
c.action do |args, options|
|
54
|
+
Qtc::Cli::Mar::Stack.new.show(args[0], options)
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
command 'mar stack:set' do |c|
|
59
|
+
c.syntax = 'qtc-cli mar stack:set STACK'
|
60
|
+
c.description = 'Set app stack'
|
61
|
+
c.option '--app APP', String, 'App instance id'
|
62
|
+
c.option '--remote REMOTE', String, 'Git remote to use, eg "staging"'
|
63
|
+
c.action do |args, options|
|
64
|
+
raise ArgumentError.new('STACK is required') if args[0].nil?
|
65
|
+
Qtc::Cli::Mar::Stack.new.update(args[0], options)
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
command 'mar scale' do |c|
|
70
|
+
c.syntax = 'qtc-cli mar scale KEY=VALUE'
|
71
|
+
c.description = 'Scale app processes'
|
72
|
+
c.option '--app APP', String, 'App instance id'
|
73
|
+
c.option '--remote REMOTE', String, 'Git remote to use, eg "staging"'
|
74
|
+
c.action do |args, options|
|
75
|
+
Qtc::Cli::Mar::Apps.new.scale(args, options)
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
command 'mar logs' do |c|
|
80
|
+
c.syntax = 'qtc-cli mar logs'
|
81
|
+
c.description = 'List app log entries'
|
82
|
+
c.option '--app APP', String, 'App instance id'
|
83
|
+
c.option '--remote REMOTE', String, 'Git remote to use, eg "staging"'
|
84
|
+
c.option '--timestamp', String, 'Include timestamp'
|
85
|
+
c.option '--stream', String, 'stdout or stderr'
|
86
|
+
c.option '--limit LIMIT', Integer, 'Limit'
|
87
|
+
c.option '--offset OFFSET', Integer, 'Offset'
|
88
|
+
c.action do |args, options|
|
89
|
+
Qtc::Cli::Mar::Apps.new.logs(options)
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
command 'mar domains' do |c|
|
94
|
+
c.syntax = 'qtc-cli mar domains'
|
95
|
+
c.description = 'List app domains'
|
96
|
+
c.option '--app APP', String, 'App instance id'
|
97
|
+
c.option '--remote REMOTE', String, 'Git remote to use, eg "staging"'
|
98
|
+
c.action do |args, options|
|
99
|
+
Qtc::Cli::Mar::Domains.new.list(options)
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
103
|
+
command 'mar domains:add' do |c|
|
104
|
+
c.syntax = 'qtc-cli mar domains:add DOMAIN'
|
105
|
+
c.description = 'Add custom domain to app'
|
106
|
+
c.option '--app APP', String, 'App instance id'
|
107
|
+
c.option '--remote REMOTE', String, 'Git remote to use, eg "staging"'
|
108
|
+
c.action do |args, options|
|
109
|
+
raise ArgumentError.new('DOMAIN is required') if args[0].nil?
|
110
|
+
Qtc::Cli::Mar::Domains.new.create(args[0], options)
|
111
|
+
end
|
112
|
+
end
|
113
|
+
|
114
|
+
command 'mar domains:remove' do |c|
|
115
|
+
c.syntax = 'qtc-cli domains:remove DOMAIN'
|
116
|
+
c.description = 'Remove custom domain from app'
|
117
|
+
c.option '--app APP', String, 'App instance id'
|
118
|
+
c.option '--remote REMOTE', String, 'Git remote to use, eg "staging"'
|
119
|
+
c.action do |args, options|
|
120
|
+
raise ArgumentError.new('DOMAIN is required') if args[0].nil?
|
121
|
+
Qtc::Cli::Mar::Domains.new.destroy(args[0], options)
|
122
|
+
end
|
123
|
+
end
|
124
|
+
|
125
|
+
command 'mar envs' do |c|
|
126
|
+
c.syntax = 'qtc-cli mar envs'
|
127
|
+
c.description = 'List app environment variables'
|
128
|
+
c.option '--app APP', String, 'App instance id'
|
129
|
+
c.option '--remote REMOTE', String, 'Git remote to use, eg "staging"'
|
130
|
+
c.action do |args, options|
|
131
|
+
Qtc::Cli::Mar::Env.new.show(options)
|
132
|
+
end
|
133
|
+
end
|
134
|
+
|
135
|
+
command 'mar envs:set' do |c|
|
136
|
+
c.syntax = 'qtc-cli mar envs:set KEY=value'
|
137
|
+
c.description = 'Set app environment variable'
|
138
|
+
c.option '--app APP', String, 'App instance id'
|
139
|
+
c.option '--remote REMOTE', String, 'Git remote to use, eg "staging"'
|
140
|
+
c.action do |args, options|
|
141
|
+
raise ArgumentError.new("You didn't specify any values") if args[0].nil?
|
142
|
+
Qtc::Cli::Mar::Env.new.set(args, options)
|
143
|
+
end
|
144
|
+
end
|
145
|
+
|
146
|
+
command 'mar ssl:add' do |c|
|
147
|
+
c.syntax = 'qtc-cli mar ssl:add --key=<path_to_pem> --cert=<path_to_crt>'
|
148
|
+
c.description = 'Add SSL certificate to app'
|
149
|
+
c.option '--app APP', String, 'App instance id'
|
150
|
+
c.option '--remote REMOTE', String, 'Git remote to use, eg "staging"'
|
151
|
+
c.option '--key PATH', String, 'Path to private key file'
|
152
|
+
c.option '--cert PATH', String, 'Path to certificate file'
|
153
|
+
c.option '--chain PATH', String, 'Path to certificate chain file'
|
154
|
+
c.action do |args, options|
|
155
|
+
raise ArgumentError.new("--key is required") unless options.key
|
156
|
+
raise ArgumentError.new("--cert is required") unless options.cert
|
157
|
+
Qtc::Cli::Mar::SslCertificates.new.create(options)
|
158
|
+
end
|
159
|
+
end
|
160
|
+
|
161
|
+
command 'mar ssl:remove' do |c|
|
162
|
+
c.syntax = 'qtc-cli mar remove-ssl-cert'
|
163
|
+
c.description = 'Remove SSL certificate from app'
|
164
|
+
c.option '--app APP', String, 'App instance id'
|
165
|
+
c.option '--remote REMOTE', String, 'Git remote to use, eg "staging"'
|
166
|
+
c.action do |args, options|
|
167
|
+
Qtc::Cli::Mar::SslCertificates.new.destroy(options)
|
168
|
+
end
|
169
|
+
end
|
170
|
+
|
171
|
+
command 'mar repo:purge_cache' do |c|
|
172
|
+
c.syntax = 'qtc-cli mar repo:purge_cache'
|
173
|
+
c.description = 'Delete remote repository build cache contents'
|
174
|
+
c.option '--app APP', String, 'App instance id'
|
175
|
+
c.option '--remote REMOTE', String, 'Git remote to use, eg "staging"'
|
176
|
+
c.action do |args, options|
|
177
|
+
Qtc::Cli::Mar::Repository.new.purge_cache(options)
|
178
|
+
end
|
179
|
+
end
|
180
|
+
|
181
|
+
command 'mar repo:reset' do |c|
|
182
|
+
c.syntax = 'qtc-cli mar repo:reset'
|
183
|
+
c.description = 'Reset remote git repository'
|
184
|
+
c.option '--app APP', String, 'App instance id'
|
185
|
+
c.option '--remote REMOTE', String, 'Git remote to use, eg "staging"'
|
186
|
+
c.action do |args, options|
|
187
|
+
Qtc::Cli::Mar::Repository.new.reset(options)
|
188
|
+
end
|
189
|
+
end
|
190
|
+
|
191
|
+
command 'mar local:run' do |c|
|
192
|
+
c.syntax = 'qtc-cli mar local:run'
|
193
|
+
c.option '--clean', String, 'Force clean build'
|
194
|
+
c.option '--stack STRING', String, 'Define used stack (default: cedar-14)'
|
195
|
+
c.description = 'Debug mar app locally (requires docker)'
|
196
|
+
c.action do |args, options|
|
197
|
+
Qtc::Cli::Mar::Debug.new.local_debug(args, options)
|
198
|
+
end
|
199
|
+
end
|
200
|
+
|
201
|
+
command 'mar local:build_slug' do |c|
|
202
|
+
c.syntax = 'qtc-cli mar local:build_slug'
|
203
|
+
c.option '--stack STRING', String, 'Define used stack (default: cedar-14)'
|
204
|
+
c.description = 'Build mar app slug locally (requires docker)'
|
205
|
+
c.action do |args, options|
|
206
|
+
Qtc::Cli::Mar::Debug.new.local_build(options)
|
207
|
+
end
|
208
|
+
end
|
209
|
+
|
210
|
+
command 'mar exec' do |c|
|
211
|
+
c.syntax = 'qtc-cli mar exec <cmd>'
|
212
|
+
c.description = 'Execute command inside app process'
|
213
|
+
c.option '--process PROCESS_ID', String, 'App process id'
|
214
|
+
c.option '--app APP', String, 'App instance id'
|
215
|
+
c.option '--remote REMOTE', String, 'Git remote to use, eg "staging"'
|
216
|
+
c.action do |args, options|
|
217
|
+
raise ArgumentError.new("command required") if args.size == 0
|
218
|
+
raise ArgumentError.new("--process is required") unless options.process
|
219
|
+
Qtc::Cli::Mar::Apps.new.exec(args.join(" "), options)
|
220
|
+
end
|
221
|
+
end
|
data/lib/qtc/cli/mar/debug.rb
CHANGED
@@ -1,86 +1,87 @@
|
|
1
|
-
require_relative 'base'
|
2
|
-
require 'open3'
|
3
|
-
|
4
|
-
module Qtc
|
5
|
-
module Cli
|
6
|
-
class Mar::Debug < Mar::Base
|
7
|
-
|
8
|
-
def local_debug(commands, options)
|
9
|
-
app_home = File.realpath('.')
|
10
|
-
docker_id = nil
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
'-e
|
26
|
-
|
27
|
-
'-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
end
|
85
|
-
|
86
|
-
end
|
1
|
+
require_relative 'base'
|
2
|
+
require 'open3'
|
3
|
+
|
4
|
+
module Qtc
|
5
|
+
module Cli
|
6
|
+
class Mar::Debug < Mar::Base
|
7
|
+
|
8
|
+
def local_debug(commands, options)
|
9
|
+
app_home = File.realpath('.')
|
10
|
+
docker_id = nil
|
11
|
+
stack = options.stack || 'cedar-14'
|
12
|
+
puts "-----> Starting to build MAR app locally"
|
13
|
+
|
14
|
+
if options.clean == true && File.exists?("#{app_home}/slug.tgz")
|
15
|
+
File.delete("#{app_home}/slug.tgz")
|
16
|
+
end
|
17
|
+
|
18
|
+
unless File.exists?("#{app_home}/slug.tgz")
|
19
|
+
docker_id = build_slug(app_home, stack)
|
20
|
+
else
|
21
|
+
puts " Existing slug.tgz found, build not needed."
|
22
|
+
end
|
23
|
+
puts "-----> Starting app container"
|
24
|
+
run_opts = [
|
25
|
+
'-e PORT=5000',
|
26
|
+
"-e STACK=#{stack}",
|
27
|
+
'-e SLUG_URL=file:///tmp/fake_slug.tgz',
|
28
|
+
'-p 5000',
|
29
|
+
"-v #{app_home}/slug.tgz:/tmp/fake_slug.tgz"
|
30
|
+
]
|
31
|
+
if File.exists?("#{app_home}/.env")
|
32
|
+
run_opts << "--env-file=#{app_home}/.env"
|
33
|
+
end
|
34
|
+
if commands.size == 0
|
35
|
+
cmd = 'start web'
|
36
|
+
else
|
37
|
+
cmd = commands.join(" ")
|
38
|
+
end
|
39
|
+
|
40
|
+
exec("docker run -it #{run_opts.join(" ")} qtcs/slugrunner:#{stack} #{cmd}")
|
41
|
+
end
|
42
|
+
|
43
|
+
def local_build_slug(options)
|
44
|
+
app_home = File.realpath('.')
|
45
|
+
puts "-----> Starting to build MAR app locally"
|
46
|
+
build_slug(app_home)
|
47
|
+
end
|
48
|
+
|
49
|
+
def build_slug(app_home, stack)
|
50
|
+
docker_id = nil
|
51
|
+
run_opts = ''
|
52
|
+
if File.exists?("#{app_home}/.env")
|
53
|
+
run_opts << "--env-file=#{app_home}/.env"
|
54
|
+
end
|
55
|
+
Open3.popen3("docker run -d #{run_opts} -v #{app_home}:/tmp/gitrepo:r qtcs/slugbuilder:#{stack}") {|stdin, stdout, stderr, wait_thr|
|
56
|
+
docker_id = stdout.gets
|
57
|
+
if docker_id
|
58
|
+
docker_id.strip!
|
59
|
+
else
|
60
|
+
puts stderr.gets
|
61
|
+
end
|
62
|
+
exit_status = wait_thr.value
|
63
|
+
unless exit_status.success?
|
64
|
+
raise "ERROR: build failed to start"
|
65
|
+
end
|
66
|
+
}
|
67
|
+
Open3.popen2('docker', 'attach', docker_id){|stdin, stdout, wait_thr|
|
68
|
+
stdin.close
|
69
|
+
while line = stdout.gets
|
70
|
+
puts line
|
71
|
+
end
|
72
|
+
exit_status = wait_thr.value
|
73
|
+
unless exit_status.success?
|
74
|
+
raise "ERROR: build failed to complete"
|
75
|
+
end
|
76
|
+
}
|
77
|
+
puts "-----> Extracting slug from build image to ./slug.tgz"
|
78
|
+
system("docker cp #{docker_id}:/tmp/slug.tgz . > /dev/null")
|
79
|
+
|
80
|
+
docker_id
|
81
|
+
rescue => exc
|
82
|
+
system("docker rm -f #{docker_id}") if docker_id
|
83
|
+
raise exc
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|