docker_deploy 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/docker_deploy/context.rb +6 -1
- data/lib/docker_deploy/stage.rb +13 -2
- data/lib/docker_deploy/task.rb +3 -3
- data/lib/docker_deploy/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: f2c1ca6ba03a922837423fefa9c35e93dd9aa553
|
4
|
+
data.tar.gz: 0c0e6536e1b5e84576cc4c110fcff28cdf02a53e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: df1ddf8e1380db78c3e42950a29c03817bc9fbfe13500b0f1a0dec38519452b41619461eaf4003bc815570f4d451eb66a37a3a6e5c3de0b01fafa509258eaa6a
|
7
|
+
data.tar.gz: ef8faaffd025f8132db1383748c8a1fe959aaefad28033a9d88a9ddd8c94cdbf59bf9903523302f3cfb026af1ba45b20dac358928adcaf9355bc58c8130cd25c
|
@@ -1,11 +1,12 @@
|
|
1
1
|
module DockerDeploy
|
2
2
|
class Context
|
3
|
-
attr_reader :stages, :variables, :ports
|
3
|
+
attr_reader :stages, :variables, :ports, :links
|
4
4
|
|
5
5
|
def initialize
|
6
6
|
@stages = []
|
7
7
|
@variables = {}
|
8
8
|
@ports = {}
|
9
|
+
@links = {}
|
9
10
|
end
|
10
11
|
|
11
12
|
def env(variables = {})
|
@@ -16,6 +17,10 @@ module DockerDeploy
|
|
16
17
|
@ports.merge!(ports)
|
17
18
|
end
|
18
19
|
|
20
|
+
def link(links = {})
|
21
|
+
@links.merge!(links)
|
22
|
+
end
|
23
|
+
|
19
24
|
def image(name = nil)
|
20
25
|
@image = name if name
|
21
26
|
@image
|
data/lib/docker_deploy/stage.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
module DockerDeploy
|
2
2
|
class Stage
|
3
|
-
attr_reader :name, :servers, :variables
|
3
|
+
attr_reader :name, :servers, :variables, :links
|
4
4
|
|
5
5
|
def initialize(context, name)
|
6
6
|
@context = context
|
@@ -8,6 +8,7 @@ module DockerDeploy
|
|
8
8
|
@servers = []
|
9
9
|
@variables = {}
|
10
10
|
@ports = {}
|
11
|
+
@links = {}
|
11
12
|
@deploy = ["docker:build", "docker:push", :pull, :restart]
|
12
13
|
end
|
13
14
|
|
@@ -19,6 +20,10 @@ module DockerDeploy
|
|
19
20
|
@ports.merge!(ports)
|
20
21
|
end
|
21
22
|
|
23
|
+
def link(links = {})
|
24
|
+
@links.merge!(links)
|
25
|
+
end
|
26
|
+
|
22
27
|
def deploy(sequence = nil)
|
23
28
|
@deploy = sequence if sequence
|
24
29
|
@deploy
|
@@ -33,7 +38,13 @@ module DockerDeploy
|
|
33
38
|
@servers << SSHKit::Host.new(server)
|
34
39
|
end
|
35
40
|
|
36
|
-
def
|
41
|
+
def link_mappings
|
42
|
+
@context.links.merge(@links).each_with_object("") do |(from, to), s|
|
43
|
+
s << " --link %s:%s " % [from, to]
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
def port_mappings
|
37
48
|
@context.ports.merge(@ports).each_with_object("") do |(from, to), s|
|
38
49
|
s << " -p %d:%d " % [from, to]
|
39
50
|
end
|
data/lib/docker_deploy/task.rb
CHANGED
@@ -41,7 +41,7 @@ module DockerDeploy
|
|
41
41
|
desc "Start the application in a container using the latest image."
|
42
42
|
task :start do
|
43
43
|
on stage.servers do
|
44
|
-
execute :docker, "run -d #{stage.
|
44
|
+
execute :docker, "run -d #{stage.port_mappings} #{stage.link_mappings} #{stage.options} --name #{context.container} #{context.image}:latest"
|
45
45
|
|
46
46
|
puts "\n\nStarted: #{stage.host}\n"
|
47
47
|
end
|
@@ -50,7 +50,7 @@ module DockerDeploy
|
|
50
50
|
desc "Run migrations in the latest image."
|
51
51
|
task :migrate do
|
52
52
|
on stage.servers.first do
|
53
|
-
execute :docker, "run #{stage.options} -i -t --rm=true #{context.image}:latest bundle exec rake db:create db:migrate"
|
53
|
+
execute :docker, "run #{stage.link_mappings} #{stage.options} -i -t --rm=true #{context.image}:latest bundle exec rake db:create db:migrate"
|
54
54
|
end
|
55
55
|
end
|
56
56
|
|
@@ -59,7 +59,7 @@ module DockerDeploy
|
|
59
59
|
puts "Console is currently broken :("
|
60
60
|
puts "Run:\n"
|
61
61
|
puts "ssh #{stage.servers.first}"
|
62
|
-
puts "docker run #{stage.options} -i -t --rm=true #{context.image}:latest bundle exec rails console"
|
62
|
+
puts "docker run #{stage.options} -i -t --rm=true #{stage.link_mappings} #{context.image}:latest bundle exec rails console"
|
63
63
|
end
|
64
64
|
|
65
65
|
desc "Restart the running container."
|