@@ -37,6 +37,39 @@ def configure(options)
37
37
@is_configured = true
38
38
end
39
39
40
+ # Create a dockito vault container for serving private keys
41
+ # https://github.com/dockito/vault
42
+ def create_dockito_vault
43
+ begin
44
+ Docker ::Container . get ( dockito_vault_name )
45
+ puts "Dockito vault container #{ dockito_vault_name } already exists."
46
+ rescue Docker ::Error ::NotFoundError => e
47
+
48
+ # docker run --detach --name vault -p 14242:3000 -v ~/.ssh:/vault/.ssh dockito/vault:latest
49
+ exec "docker run --detach --name #{ dockito_vault_name } -p 14242:3000 -v ~/.ssh:/vault/.ssh dockito/vault:latest"
50
+ puts "Dockito vault container #{ dockito_vault_name } created."
51
+ end
52
+ end
53
+
54
+ def rm_dockito_vault
55
+ begin
56
+ container = Docker ::Container . get ( dockito_vault_name )
57
+ rm_v ( container )
58
+ rescue Docker ::Error ::NotFoundError => e
59
+ puts "Dockito vault container #{ dockito_vault_name } does not exist."
60
+ end
61
+ end
62
+
63
+ # FIXME this needs to by dynamic to this run?
64
+ def dockito_vault_name
65
+ 'vault' #@config[:dockito][:vault][:name]
66
+ end
67
+
68
+ def dockito_vault_enabled?
69
+ @config [ :dockito ] [ :vault ] || false
70
+ end
71
+
72
+
40
73
def compose
41
74
# Write a docker-compose.yml with interpolated variables
42
75
@compose_filename = compose_filename_from project_name
@@ -196,6 +229,14 @@ def rm_dangling
196
229
puts 'Done.'
197
230
end
198
231
232
+ def rm_exited
233
+ puts "\n \n Cleaning up exited containers..."
234
+ puts '-----------------------------'
235
+
236
+ exec ( 'docker rm -v $(docker ps -a -q -f status=exited)' , false , true )
237
+ puts 'Done.'
238
+ end
239
+
199
240
def run_service_command ( service_name , command )
200
241
# Run the compose configuration
201
242
exec_compose ( "run #{ service_name } #{ command } " , false , '' , true )
@@ -227,7 +268,7 @@ def exec(cmd, capture = false, ignore_errors = false)
227
268
output
228
269
end
229
270
230
- # convenience to execute docker-compose with file and project params
271
+ # convenience to execute docker-compose with file and project params
231
272
def exec_compose ( cmd , capture = false , options = '' , ignore_errors = false )
232
273
# in the case of running a bash session, this file may dissappear, just make sure it is there.
233
274
compose unless File . exists? ( @compose_filename )
@@ -259,7 +300,7 @@ def verbose?
259
300
@verbose ||= ( @config [ 'verbose' ] unless @config . nil? ) || false
260
301
end
261
302
262
- # accessible so that we can delete patterns
303
+ # accessible so that we can delete patterns
263
304
def compose_filename_from ( project_name )
264
305
"docker-compose-#{ project_name } .yml"
265
306
end
@@ -306,7 +347,7 @@ def stop(container)
306
347
kill ( container )
307
348
end
308
349
309
- # kill container, progressively more forceful from -1, -9, then full Chuck Norris.
350
+ # kill container, progressively more forceful from -1, -9, then full Chuck Norris.
310
351
def kill ( container )
311
352
%w( SIGHUP SIGKILL SIGSTOP ) . each do |signal |
312
353
if container . up?
0 commit comments