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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9c0a6af4b603facef00bb395c7598fbc4265605a
4
- data.tar.gz: fc8a912ed44073f881859ae0934d9b59411daa52
3
+ metadata.gz: f2c1ca6ba03a922837423fefa9c35e93dd9aa553
4
+ data.tar.gz: 0c0e6536e1b5e84576cc4c110fcff28cdf02a53e
5
5
  SHA512:
6
- metadata.gz: 0eb9eb0c1975c9cdcb44a9e10507046593caa4298ccd683e5c2e2367d9ed9a6e58f6fe936b83108c246b881c3104e06565546ce3b74cbd7a6f29563658fe3d9e
7
- data.tar.gz: 0555bb0bce47a2a169fa29c24e72d35af502a1c6535a0fae1b9269b6eabdad1efc73a2d57cc803be1c3725922eb6690a4f28a55b5f6e2c251ab79853101649d5
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
@@ -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 mappings
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
@@ -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.mappings} #{stage.options} --name #{context.container} #{context.image}:latest"
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."
@@ -1,3 +1,3 @@
1
1
  module DockerDeploy
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: docker_deploy
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jonas Nicklas