docker-compose 1.0.0rc1 → 1.0.0rc2
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/.coveralls.yml +1 -0
- data/Gemfile +5 -2
- data/README.md +4 -8
- data/lib/docker/compose/mapper.rb +27 -17
- data/lib/docker/compose/net_info.rb +2 -2
- data/lib/docker/compose/session.rb +17 -2
- data/lib/docker/compose/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0ac6123a9b77b5d0ff6902f5e89467fd17ed34fe
|
4
|
+
data.tar.gz: 585201f65eb1fb6d654af2a484a09e2f8f27ba75
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4517ccd9c0f2e9aef88e4c30a8fd653cc27cc3aa2b11759e191569a687ae03d8358c9d2db5dc8a74f24435add97ac7007121ab9a504804642438437c2f0b5e8d
|
7
|
+
data.tar.gz: 07c4f04f8417b07fa8b9dda91026c512186840b0cfb9ffed0d9ecfe2d8562b34a62948397004cf7f69c6a26c2c56bf73c1cc475edc4ca43fa758f8dd7eb1a17a
|
data/.coveralls.yml
ADDED
@@ -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',
|
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
|
-
[](https://travis-ci.org/xeger/docker-compose) [](http://www.rubydoc.info/gems/docker-compose)
|
4
|
-
|
1
|
+
[](https://travis-ci.org/xeger/docker-compose) [](https://coveralls.io/github/xeger/docker-compose?branch=coveralls) [](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
|
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
|
-
|
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 [
|
49
|
-
|
50
|
-
|
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
|
77
|
-
#
|
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
|
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.
|
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.
|
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-
|
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"
|