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 +4 -4
- data/lib/docker_deploy/local_stage.rb +1 -1
- data/lib/docker_deploy/remote_stage.rb +2 -4
- data/lib/docker_deploy/shell.rb +43 -0
- data/lib/docker_deploy/task.rb +19 -21
- data/lib/docker_deploy/version.rb +1 -1
- data/lib/docker_deploy.rb +2 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 63619a798b6a3fa44aec2d3228cb9750fb96ce8f
|
4
|
+
data.tar.gz: 8c61215138a2d56de1e3e8a0813aa59a12936343
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ff17a90efec549e9f1ea391a52a078b74b7c389348c9b993388c5eb3eb0cbaae5d05df8642b698fa8f015726e0cd4f5b0cb27a46c3ce95eaefe15e0bb0812a60
|
7
|
+
data.tar.gz: 4966d4578f640b5530f5c574ed2aabb709aa593ebe52483b86fedf1e2db96508946a430a8f9bde72cb41da1d90325aea99f252e2219b6ffbea356daaf696534a
|
@@ -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
|
data/lib/docker_deploy/task.rb
CHANGED
@@ -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.
|
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
|
-
|
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
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
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
|
|
data/lib/docker_deploy.rb
CHANGED
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.
|
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-
|
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
|