docker-utils 0.1.25 → 0.1.26

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/share/scripts/toolchain +53 -6
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 21bf4f835d889a6b040d2bec00b880985139a260
4
- data.tar.gz: 7b48d84fba66ccfd5dd944ed828e272cbda5fb7c
3
+ metadata.gz: c0355614ccc50f0aa3d720ff6689aa7e37ec0411
4
+ data.tar.gz: c616c14508be93f3332adf24ceff29f73ad8fdcb
5
5
  SHA512:
6
- metadata.gz: 5020de7e181d295b84a3ee771b435529a81afacb49e13eebb45fc1353ec8a013d58cc185f586b4f7f3bed8ef7ee86dfbe4f9823981e47ae4a1a93860ed592dea
7
- data.tar.gz: a660931bfbe03357a3a8e44e4bf15dde088a4b648620e55031476445afbbdb7aa9950f6cc0add263c67db2c0fb51d73a738d4f35616b327c0272584dbf77ee9d
6
+ metadata.gz: 7a749890cff3d1933f9d9042b1d7b25086d8c6d2868c3ba00d22b292895be76a74d9c5204cf4b276a16a147b8a81ef06a5f21ea195f435858bba5fdf121c06a8
7
+ data.tar.gz: 1dcf64149294fc1d552b9cd2f2c795d5313b91c7bdd0e9a20c8638f9a100b6d849b22b101c989160b2981829bcc5175f549e57d57efe8d95157508cafeb67a2e
@@ -1,7 +1,16 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
3
  EXPUNGE_ENV_KEYS = [
4
- 'TMPDIR'
4
+ 'TMPDIR',
5
+ 'DOCKER_HOST',
6
+ 'LOGNAME',
7
+ 'LANG',
8
+ 'PWD',
9
+ 'OLDPWD',
10
+ 'PS1',
11
+ 'SHELL',
12
+ 'USER',
13
+ '_'
5
14
  ]
6
15
 
7
16
  require 'optparse'
@@ -51,7 +60,13 @@ if host_repo_root
51
60
 
52
61
  toolchain_docker_args.concat([
53
62
  '-v', "#{host_repo_root}:#{guest_repo_root}",
54
- '-w', guest_cwd.to_s
63
+ '-w', '/build'
64
+ ])
65
+
66
+ data_container_name = host_repo_root.basename.to_s + "-build"
67
+
68
+ toolchain_docker_args.concat([
69
+ "--volumes-from=#{data_container_name}"
55
70
  ])
56
71
  end
57
72
 
@@ -65,6 +80,10 @@ exposed_env_keys = ENV.keys - EXPUNGE_ENV_KEYS
65
80
  container_env_keys = `docker inspect -f '{{.Config.Env}}' #{toolchain_image}`.chomp[1..-2].split(' ').map{ |pair| pair.split('=').first }
66
81
  toolchain_docker_args.concat((exposed_env_keys - container_env_keys).map{ |k| ['-e', k] }.flatten)
67
82
 
83
+ toolchain_docker_args.concat([
84
+ '-v', "#{ENV['HOME']}/.ssh:/root/.ssh"
85
+ ])
86
+
68
87
  # network options
69
88
  if options[:bind_net]
70
89
  toolchain_docker_args.push '--net=host'
@@ -73,7 +92,35 @@ end
73
92
 
74
93
 
75
94
  docker_bin_path = `which docker`.chomp
76
- Kernel.exec docker_bin_path, 'run', '--rm',
77
- *toolchain_docker_args,
78
- toolchain_image,
79
- *toolchain_subcommand_args
95
+ toolchain = lambda do |*subcommand|
96
+ Kernel.system docker_bin_path, 'run', '--rm',
97
+ *toolchain_docker_args,
98
+ toolchain_image,
99
+ *subcommand
100
+ end
101
+
102
+ if data_container_name
103
+ data_container_image = 'tianon/true:latest'
104
+ data_container_image_available = system docker_bin_path, 'inspect', '-f', '{{.Id}}', data_container_image, out: '/dev/null', err: '/dev/null'
105
+ unless data_container_image_available or system(docker_bin_path, 'pull', data_container_image)
106
+ $stderr.puts "could not locate data-container image '#{data_container_image}'; aborting"
107
+ Kernel.exit 1
108
+ end
109
+
110
+ data_container_exists = system docker_bin_path, 'inspect', '-f', '{{.Id}}', data_container_name, out: '/dev/null', err: '/dev/null'
111
+
112
+ #toolchain.call 'find', '/build', '-mindepth', '1', '-maxdepth', '1', '-type', 'l', '-exec', 'rm', '{}', ';'
113
+ unless data_container_exists
114
+ Kernel.system(
115
+ docker_bin_path, 'run',
116
+ "--name=#{data_container_name}",
117
+ '-v', '/build',
118
+ data_container_image
119
+ )
120
+
121
+ toolchain.call 'find', '/src', '-mindepth', '1', '-maxdepth', '1', '-exec', 'ln', '-sF', '{}', ';'
122
+ end
123
+ end
124
+
125
+
126
+ toolchain.call *toolchain_subcommand_args
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: docker-utils
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.25
4
+ version: 0.1.26
5
5
  platform: ruby
6
6
  authors:
7
7
  - Levi Aul
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-07-14 00:00:00.000000000 Z
11
+ date: 2014-07-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ruby-uuid