docker-compose 1.0.0rc1 → 1.0.0rc2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 365d253ec8bea621b383762ab6d130991374aaef
4
- data.tar.gz: 678be8f50dd021feffbf00e4c67eb0da5985321f
3
+ metadata.gz: 0ac6123a9b77b5d0ff6902f5e89467fd17ed34fe
4
+ data.tar.gz: 585201f65eb1fb6d654af2a484a09e2f8f27ba75
5
5
  SHA512:
6
- metadata.gz: 42fe1651bc466fdcf4df95098ccc566b613d485f79b056f41eb3bc9a68c90cb1d5642bee1227e4ee7f4361106f7fef8071a7eacfe6994d5a93b25a3b5ed2c902
7
- data.tar.gz: b096804ff73321e4efad1b29725feb4d2388068106f6f0a7d751c9e23236f4f8c6c06e32143c09959ef97cdc78b82ca9148c2ef8fe9bb35c1b35c86a75fdb42c
6
+ metadata.gz: 4517ccd9c0f2e9aef88e4c30a8fd653cc27cc3aa2b11759e191569a687ae03d8358c9d2db5dc8a74f24435add97ac7007121ab9a504804642438437c2f0b5e8d
7
+ data.tar.gz: 07c4f04f8417b07fa8b9dda91026c512186840b0cfb9ffed0d9ecfe2d8562b34a62948397004cf7f69c6a26c2c56bf73c1cc475edc4ca43fa758f8dd7eb1a17a
@@ -0,0 +1 @@
1
+ repo_token: hMWX6XPNvG4Gfy9gCDEvrxhQVKdyN5e2m
data/Gemfile CHANGED
@@ -1,13 +1,16 @@
1
- # encoding: utf-8
2
1
  source 'https://rubygems.org'
3
2
 
4
3
  # Specify your gem's dependencies in docker-compose.gemspec
5
4
  gemspec
6
5
 
7
- gem 'backticks', path:'/Users/tony/Code/xeger/backticks'
6
+ gem 'backticks', '1.0.0rc1'
8
7
 
9
8
  group :development do
10
9
  gem 'pry'
11
10
  gem 'pry-byebug'
12
11
  gem 'rubocop'
13
12
  end
13
+
14
+ group :test do
15
+ gem 'coveralls', require: false
16
+ end
data/README.md CHANGED
@@ -1,14 +1,11 @@
1
-
2
-
3
- [![Build Status](https://travis-ci.org/xeger/docker-compose.svg)](https://travis-ci.org/xeger/docker-compose) [![Docs](https://img.shields.io/badge/docs-rubydoc-orange.svg)](http://www.rubydoc.info/gems/docker-compose)
4
-
1
+ [![Build Status](https://travis-ci.org/xeger/docker-compose.svg)](https://travis-ci.org/xeger/docker-compose) [![Coverage Status](https://coveralls.io/repos/github/xeger/docker-compose/badge.svg?branch=coveralls)](https://coveralls.io/github/xeger/docker-compose?branch=coveralls) [![Docs](https://img.shields.io/badge/docs-rubydoc-blue.svg)](http://www.rubydoc.info/gems/docker-compose)
5
2
 
6
3
  # Docker::Compose
7
4
 
8
5
  This is a Ruby OOP wrapper for the [docker-compose](https://github.com/docker/compose)
9
- container orchestration tool from Docker Inc.
6
+ container orchestration tool from Docker Inc.
10
7
 
11
- In addition to wrapping the CLI, this gem provides an environment-variable mapping
8
+ In addition to wrapping the CLI, this gem provides an environment-variable mapping
12
9
  feature that allows you to export environment variables into your _host_ that point
13
10
  to network services exposed by containers. This allows you to run an application on
14
11
  your host for quicker and easier development, but run all of its dependencies --
@@ -54,7 +51,7 @@ exited = compose.ps.where { |c| !c.up? }
54
51
  puts "We have some exited containers: " + exited.join(', ')
55
52
 
56
53
  sum = compose.ps.inject(0) { |a,c| a + c.size }
57
- puts format("Composition is using %.1f MiB disk space", sum/1024.0**2)
54
+ puts format("Composition is using %.1f MiB disk space", sum/1024.0**2)
58
55
  ```
59
56
 
60
57
  ### Invoking from Rake
@@ -171,4 +168,3 @@ Bug reports and pull requests are welcome on GitHub at https://github.com/xeger/
171
168
  ## License
172
169
 
173
170
  The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
174
-
@@ -1,7 +1,16 @@
1
1
  # encoding: utf-8
2
2
  module Docker::Compose
3
3
  # Uses a Session to discover information about services' IP addresses and
4
- # ports as reachable from the host, then
4
+ # ports as reachable from localhost, then maps URLs and other common network
5
+ # address formats so they point to the right host and port.
6
+ #
7
+ # **NOTE**: this class uses some heuristics to deal with cases where the
8
+ # Docker client is talking to a remote server because the `DOCKER_HOST`
9
+ # environment variable is set. In those cases, Mapper tries to determine
10
+ # the IP address of the exposed services as reachable from localhost;
11
+ # it generally makes a correct guess, but in certain super-complex networking
12
+ # scenarios it may guess wrong. Please open a GitHub issue if you find
13
+ # a situation where Mapper provides a wrong answer.
5
14
  class Mapper
6
15
  # Pattern that matches an "elided" host or port that should be omitted from
7
16
  # output, but is needed to identify a specific container and port.
@@ -16,23 +25,12 @@ module Docker::Compose
16
25
  # Instantiate a mapper; map some environment variables; yield to caller for
17
26
  # additional processing.
18
27
  #
28
+ # @param [Hash] env a set of keys/values whose values will be mapped
19
29
  # @param [Session] session
20
30
  # @param [NetInfo] net_info
21
31
  # @yield yields with each substituted (key, value) pair
22
32
  def self.map(env, session:Session.new, net_info:NetInfo.new)
23
- # TODO: encapsulate this trickiness better ... inside NetInfo perhaps?
24
- docker_host = ENV['DOCKER_HOST']
25
- if docker_host.nil? || docker_host =~ /^(\/|unix|file)/
26
- # If DOCKER_HOST is blank, or pointing to a local socket, then we
27
- # can trust the address information returned by `docker-compose port`.
28
- override_host = nil
29
- else
30
- # If DOCKER_HOST is present, assume that containers have bound to
31
- # whatever IP we reach it at; don't fall victim to dirty NAT lies!
32
- override_host = net_info.docker_routable_ip
33
- end
34
-
35
- mapper = new(session, override_host)
33
+ mapper = new(session, net_info)
36
34
  env.each_pair do |k, v|
37
35
  begin
38
36
  v = mapper.map(v)
@@ -44,10 +42,22 @@ module Docker::Compose
44
42
  end
45
43
 
46
44
  # Create an instance of Mapper
45
+ #
47
46
  # @param [Docker::Compose::Session] session
48
- # @param [String] override_host forcible address or DNS hostname to use;
49
- # leave nil to trust docker-compose output.
50
- def initialize(session, override_host = nil)
47
+ # @param [NetInfo] net_info
48
+ def initialize(session=Session.new, net_info=NetInfo.new)
49
+ docker_host = ENV['DOCKER_HOST']
50
+ if docker_host.nil? || docker_host =~ /^(\/|unix|file)/
51
+ # If DOCKER_HOST is blank, or pointing to a local socket, then we
52
+ # can trust the address information returned by `docker-compose port`.
53
+ override_host = nil
54
+ else
55
+ # If DOCKER_HOST is present, assume that containers have bound to
56
+ # whatever IP we reach it at; don't fall victim to docker-compose's
57
+ # dirty lies!
58
+ override_host = net_info.docker_routable_ip
59
+ end
60
+
51
61
  @session = session
52
62
  @override_host = override_host
53
63
  end
@@ -73,8 +73,8 @@ module Docker::Compose
73
73
  docker_dns = @docker_url.host
74
74
  docker_port = @docker_url.port || 2376
75
75
  else
76
- # Cheap trick: for unix or other protocols, assume docker daemon
77
- # is listening on 127.0.0.1:2376
76
+ # Cheap trick: for unix, file or other protocols, assume docker ports
77
+ # are proxied to localhost in addition to other interfaces
78
78
  docker_dns = 'localhost'
79
79
  docker_port = 2376
80
80
  end
@@ -140,15 +140,30 @@ module Docker::Compose
140
140
  run!('kill', o, services)
141
141
  end
142
142
 
143
- # Figure out which host a port a given service port has been published to.
143
+ # Figure out which interface(s) and port a given service port has been published to.
144
+ #
145
+ # **NOTE**: if Docker Compose is communicating with a remote Docker host, this method
146
+ # returns IP addresses from the point of view of *that* host and its interfaces. If
147
+ # you need to know the address as reachable from localhost, you probably want to use
148
+ # `Mapper`.
149
+ #
150
+ # @see Docker::Compose::Mapper
151
+ #
144
152
  # @param [String] service name of service from docker-compose.yml
145
153
  # @param [Integer] port number of port
146
154
  # @param [String] protocol 'tcp' or 'udp'
147
155
  # @param [Integer] index of container (if multiple instances running)
156
+ # @return [String,nil] an ip:port pair such as "0.0.0.0:32176" or nil if the service is not running
148
157
  # @raise [Error] if command fails
149
158
  def port(service, port, protocol: 'tcp', index: 1)
159
+ inter = @shell.interactive
160
+ @shell.interactive = false
161
+
150
162
  o = opts(protocol: [protocol, 'tcp'], index: [index, 1])
151
- run!('port', o, service, port)
163
+ s = run!('port', o, service, port).strip
164
+ (!s.empty? && s) || nil
165
+ ensure
166
+ @shell.interactive = inter
152
167
  end
153
168
 
154
169
  # Determine the installed version of docker-compose.
@@ -1,6 +1,6 @@
1
1
  # encoding: utf-8
2
2
  module Docker
3
3
  module Compose
4
- VERSION = '1.0.0rc1'
4
+ VERSION = '1.0.0rc2'
5
5
  end
6
6
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: docker-compose
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0rc1
4
+ version: 1.0.0rc2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tony Spataro
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-07-29 00:00:00.000000000 Z
11
+ date: 2016-08-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: backticks
@@ -74,6 +74,7 @@ executables: []
74
74
  extensions: []
75
75
  extra_rdoc_files: []
76
76
  files:
77
+ - ".coveralls.yml"
77
78
  - ".gitignore"
78
79
  - ".rspec"
79
80
  - ".rubocop.yml"