freighter 0.2.1 → 0.2.2
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/README.md +3 -5
- data/lib/freighter/deploy.rb +22 -9
- data/lib/freighter/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8295dacb935aa96503b1e287db0ad5bfb1d49545
|
4
|
+
data.tar.gz: 22499c6310016cae6382180d39f3a1469155a90e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
|
data/lib/freighter/deploy.rb
CHANGED
@@ -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 =
|
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
|
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 =
|
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
|
-
|
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
|
data/lib/freighter/version.rb
CHANGED