freighter 0.2.1 → 0.2.2

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: f46424de56a54174c0feeb60213a0802bbd2f1d9
4
- data.tar.gz: 884308db7063d5319f0bf5e34c63b9abb629cb83
3
+ metadata.gz: 8295dacb935aa96503b1e287db0ad5bfb1d49545
4
+ data.tar.gz: 22499c6310016cae6382180d39f3a1469155a90e
5
5
  SHA512:
6
- metadata.gz: e658a0d63238b37b3ee9bc1bed406e6a075a533f819cde405c3ddfbc8ca912ce4fc2345f65f416c407e22e92c9531b1dcc00dff5c712f5180b2384015e8ce4a4
7
- data.tar.gz: 6b3d156462bcf74cca7ba5ab9ee1830bacec6816571f0ad572880beed8d39d198210b4e8c4eaab459c6db9088341dd9d8b069a5330f9d50ab4e746948e3be0ac
6
+ metadata.gz: cba0a378011e59479b5324f0fd23826f9fa3ed6b0183ea105ca3d4e14da0aeb9d3e88c9cd59d5c59bde380fb137c0863b622e4f5931a48c66b063eeae6a8d11f
7
+ data.tar.gz: 1a8327c1c358cb05cccb18316e32c5b13055de192113d0b4b311ddd26bc55f1786a680b8746f5b835fa21954842925b1ad5f3c3fd87587108d9ecb1f8c6d0379
data/README.md CHANGED
@@ -7,6 +7,7 @@ Freighter goals:
7
7
  * Straight forward configuration
8
8
  * Users new to freighter should be able to deploy in minutes
9
9
  * Minimal server-side configuration
10
+ * Clean up old containers and images that are not being used
10
11
  * Fast and reliable
11
12
 
12
13
  ## Installation
@@ -177,15 +178,12 @@ If you find yourself in a pickle of not being able to Ctrl+c (interrupt) the com
177
178
 
178
179
  # Status
179
180
 
181
+ Freighter is currently deploying quickly and reliably as far as I can tell.
182
+
180
183
  Needed:
181
184
  * Needs more testing with more complex scenarios
182
-
183
- Nice to haves:
184
185
  * Container linking options
185
186
  * Volume mounting options
186
- * Container cleanup
187
-
188
- Freighter is currently deploying quickly and reliably as far as I can tell.
189
187
 
190
188
  ## Contributing
191
189
 
@@ -127,17 +127,21 @@ module Freighter
127
127
 
128
128
  def containers_matching_port_map(containers, port_mappings)
129
129
  port_mappings.map do |port_map|
130
- ports = ports(port_map)
130
+ ports = map_ports(port_map)
131
131
  containers.select do |c|
132
132
  c.info['Ports'].detect do |p|
133
133
  p['PrivatePort'] == ports.container && p['PublicPort'] == ports.host
134
134
  end
135
135
  end
136
- end.flatten
136
+ end.compact.flatten
137
137
  end
138
138
 
139
139
  PortMap = Struct.new(:ip, :host, :container)
140
- def ports(port_map)
140
+ def map_ports(port_map)
141
+ # for some unknown reason, containers started without a port mapping specified
142
+ # are getting a default port mapping of 80/tcp. This is why a default port map is
143
+ # being assigned to port 80
144
+ return PortMap.new(nil, nil, 80) if port_map.nil?
141
145
  port_map.match(/^(\d{1,3}\.[\.0-9]*)?:?(\d+)->(\d+)$/)
142
146
  begin
143
147
  raise if $2.nil? or $3.nil?
@@ -163,21 +167,30 @@ module Freighter
163
167
 
164
168
  # start up some new containers
165
169
  image['containers'].map do |container|
166
- port_map = ports(container['port_mapping'])
170
+ port_map = map_ports(container['port_mapping'])
167
171
 
168
172
  # env = container['env'].inject("") { |r, (k,v)| r << "#{k}='#{v}',\n" }
169
173
  env = container['env'].map { |k,v| "#{k}=#{v}" }
170
174
  container_options = {
171
175
  "Image" => image['name'],
172
- "ExposedPorts" => { "#{port_map.container}/tcp" => {} },
173
176
  "Env" => env
174
177
  }
175
178
 
179
+ start_options = {}
180
+
181
+ if port_map.host
182
+ container_options.merge!({ "ExposedPorts" => { "#{port_map.container}/tcp" => {} } })
183
+ start_options.merge!({
184
+ "PortBindings" => {
185
+ "#{port_map.container}/tcp" => [{ "HostPort" => port_map.host.to_s, "HostIp" => port_map.ip }]
186
+ }
187
+ })
188
+ logger.info msg "Starting container with port_mapping: host #{[port_map.ip, port_map.host].join(':')}, container #{port_map.container}"
189
+ end
190
+
176
191
  new_container = Docker::Container.create container_options
177
- logger.info msg "Starting container with port_mapping: host #{[port_map.ip, port_map.host].join(':')}, container #{port_map.container}"
178
- new_container.start(
179
- "PortBindings" => { "#{port_map.container}/tcp" => [{ "HostPort" => port_map.host.to_s, "HostIp" => port_map.ip }] }
180
- )
192
+
193
+ new_container.start start_options
181
194
  totals[:container_ids_started] << new_container.id
182
195
  logger.info msg "New container started with id: #{new_container.id}"
183
196
  totals[:started] += 1
@@ -1,3 +1,3 @@
1
1
  module Freighter
2
- VERSION = "0.2.1"
2
+ VERSION = "0.2.2"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: freighter
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sean McCleary