docker_deploy 0.2.3 → 0.3.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4c3d2b3a9b0a67da7951adfbc01f3db53333e2a9
4
- data.tar.gz: 9bc2556b0b346abb57f50b98a37ae0b33d6efb51
3
+ metadata.gz: 63619a798b6a3fa44aec2d3228cb9750fb96ce8f
4
+ data.tar.gz: 8c61215138a2d56de1e3e8a0813aa59a12936343
5
5
  SHA512:
6
- metadata.gz: cb7dac4efc0772bc95e2d32b96b322db9c781662062cd0cefee924d0520f0e7bcf2b5c0b29f835cb9ff78d03eb810b1947263f73f76c776a76a1a6de54363b33
7
- data.tar.gz: dc173f9148a3801d46f8389f804367f5e05a31f82aeb96518cf86f90185cc2715d7f9e801275d3e796fc71cf4379e92b98197ec956c1b7a5e4516fbc173cf573
6
+ metadata.gz: ff17a90efec549e9f1ea391a52a078b74b7c389348c9b993388c5eb3eb0cbaae5d05df8642b698fa8f015726e0cd4f5b0cb27a46c3ce95eaefe15e0bb0812a60
7
+ data.tar.gz: 4966d4578f640b5530f5c574ed2aabb709aa593ebe52483b86fedf1e2db96508946a430a8f9bde72cb41da1d90325aea99f252e2219b6ffbea356daaf696534a
@@ -13,6 +13,6 @@ module DockerDeploy
13
13
  def run(cmd)
14
14
  sh(cmd)
15
15
  end
16
- alias_method :run_once, :run
16
+ alias_method :shell, :run
17
17
  end
18
18
  end
@@ -15,10 +15,8 @@ module DockerDeploy
15
15
  end
16
16
  end
17
17
 
18
- def run_once(cmd)
19
- on servers.first do
20
- execute(cmd)
21
- end
18
+ def shell(cmd = nil)
19
+ DockerDeploy.shell(servers.first, cmd)
22
20
  end
23
21
  end
24
22
  end
@@ -0,0 +1,43 @@
1
+ module DockerDeploy
2
+ def self.shell(server, command = nil)
3
+ Net::SSH.start('app1.projectpuzzle.com', 'ubuntu') do |ssh|
4
+ channel = ssh.open_channel do |ch|
5
+ ch.on_data do |c, data|
6
+ $stdout.print data
7
+ end
8
+
9
+ ch.on_extended_data do |c, type, data|
10
+ $stderr.print data
11
+ end
12
+
13
+ ch.request_pty
14
+
15
+ if command
16
+ ch.exec(command)
17
+ else
18
+ ch.send_channel_request "shell"
19
+ end
20
+ end
21
+
22
+ read, write = UNIXSocket.pair
23
+
24
+ Thread.new(write) do |write|
25
+ loop do
26
+ buf = $stdin.raw { |r| r.readpartial(1) }
27
+ write.write(buf)
28
+ end
29
+ end
30
+
31
+ read.extend(Net::SSH::BufferedIo)
32
+
33
+ ssh.listen_to(read)
34
+
35
+ ssh.loop do
36
+ buf = read.read_available
37
+ channel.send_data buf unless buf.empty?
38
+
39
+ ssh.busy?
40
+ end
41
+ end
42
+ end
43
+ end
@@ -24,11 +24,6 @@ module DockerDeploy
24
24
  desc "deploy the application"
25
25
  task deploy: stage.deploy
26
26
 
27
- desc "Pull down code from the docker registry"
28
- task :pull do
29
- stage.run "docker pull #{context.image}"
30
- end
31
-
32
27
  desc "Stop the application and remove its container"
33
28
  task :stop do
34
29
  stage.run "docker inspect #{stage.container} 2>&1 > /dev/null && docker kill #{stage.container} && docker rm #{stage.container} || true"
@@ -43,30 +38,33 @@ module DockerDeploy
43
38
 
44
39
  desc "Run migrations in the latest image."
45
40
  task :migrate do
46
- stage.run_once "docker run #{stage.link_mappings} #{stage.options} -i -t --rm=true #{context.image}:latest bundle exec rake db:create db:migrate"
41
+ stage.shell "docker run #{stage.link_mappings} #{stage.options} -i -t --rm=true #{context.image}:latest bundle exec rake db:create db:migrate"
47
42
  end
48
43
 
49
44
  desc "Run a Rails console in a container"
50
45
  task :console do
51
- cmd = "docker run #{stage.options} -i -t --rm=true #{stage.link_mappings} #{context.image}:latest bundle exec rails console"
52
- if stage.is_a?(RemoteStage)
53
- puts "Console is currently broken :("
54
- puts "SSH in and run:\n"
55
- puts cmd
56
- else
57
- stage.run_once(cmd)
58
- end
46
+ stage.shell "docker run #{stage.options} -i -t --rm=true #{stage.link_mappings} #{context.image}:latest bundle exec rails console"
59
47
  end
60
48
 
61
49
  desc "Run a shell in a container"
62
50
  task :shell do
63
- cmd = "docker run #{stage.options} -i -t --rm=true #{stage.link_mappings} #{context.image}:latest /bin/bash"
64
- if stage.is_a?(RemoteStage)
65
- puts "Shell is currently broken :("
66
- puts "SSH in and run:\n"
67
- puts cmd
68
- else
69
- stage.run_once(cmd)
51
+ stage.shell "docker run #{stage.options} -i -t --rm=true #{stage.link_mappings} #{context.image}:latest /bin/bash"
52
+ end
53
+
54
+ desc "Tail log files"
55
+ task :tail do
56
+ stage.run "docker logs --tail 50 -f #{stage.container}"
57
+ end
58
+
59
+ if stage.is_a?(RemoteStage)
60
+ desc "Pull down code from the docker registry"
61
+ task :pull do
62
+ stage.run "docker pull #{context.image}"
63
+ end
64
+
65
+ desc "SSH into a host server"
66
+ task :ssh do
67
+ stage.shell
70
68
  end
71
69
  end
72
70
 
@@ -1,3 +1,3 @@
1
1
  module DockerDeploy
2
- VERSION = "0.2.3"
2
+ VERSION = "0.3.0"
3
3
  end
data/lib/docker_deploy.rb CHANGED
@@ -1,8 +1,10 @@
1
1
  require "sshkit"
2
2
  require "sshkit/dsl"
3
3
  require "shellwords"
4
+ require "io/console"
4
5
 
5
6
  require "docker_deploy/version"
7
+ require "docker_deploy/shell"
6
8
  require "docker_deploy/context"
7
9
  require "docker_deploy/stage"
8
10
  require "docker_deploy/remote_stage"
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.2.3
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jonas Nicklas
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-11-11 00:00:00.000000000 Z
12
+ date: 2014-11-12 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: sshkit
@@ -71,6 +71,7 @@ files:
71
71
  - lib/docker_deploy/context.rb
72
72
  - lib/docker_deploy/local_stage.rb
73
73
  - lib/docker_deploy/remote_stage.rb
74
+ - lib/docker_deploy/shell.rb
74
75
  - lib/docker_deploy/stage.rb
75
76
  - lib/docker_deploy/task.rb
76
77
  - lib/docker_deploy/version.rb