capistrano-container 0.0.4 → 0.0.5
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 +14 -2
- data/capistrano-container.gemspec +1 -1
- data/lib/capistrano/container.rb +15 -1
- data/lib/capistrano/container/instance.rb +12 -2
- data/lib/capistrano/tasks/container.rb +9 -3
- 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: b66d2f2836473bfc923351f031c8df1e6631734c
|
4
|
+
data.tar.gz: a80e51690199e3b4bf45c62017e87f5120db9658
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0249e96887773e12a302fb6b6e18f46e0ed681711e18285467f954097231aa07e969618a5c11e7ff0cd70ad37b6e2aa613ae86e4e48ddc81f105c4993d20e259
|
7
|
+
data.tar.gz: 2c8161968220469a38f5a14c89b6771c03f77c16c2149e6ef96995d26b8e2aab9dcb7d4823cb47b18b0df063fafb9ab95938002413dbf9c9be4c224450405d1b
|
data/README.md
CHANGED
@@ -6,6 +6,8 @@ This project is in an early stage but helps me alot dealing with my container de
|
|
6
6
|
|
7
7
|
This gem does not handle Dockerfiles or such things, for that there are enough capistrano modules available.
|
8
8
|
|
9
|
+
Container auto detect if they should execute on local or remote depending on stage (see below).
|
10
|
+
|
9
11
|
## Installation
|
10
12
|
|
11
13
|
Add this lines to your application's Gemfile:
|
@@ -143,14 +145,24 @@ A container has the following methods:
|
|
143
145
|
def invoke(task_name)
|
144
146
|
```
|
145
147
|
|
148
|
+
### local stage detection
|
149
|
+
Local stage per default is named ```:local```. If you which to change do ```set :local_stage_name, :local``` in your stage config.
|
150
|
+
|
146
151
|
## TODO
|
147
152
|
* Write tests.
|
148
|
-
* Implement
|
153
|
+
* Implement adapter pattern for other container manager.
|
149
154
|
|
150
155
|
## Changes
|
156
|
+
### Version 0.0.5
|
157
|
+
* container now auto detect if they should execute, download and upload on local or remote host.
|
158
|
+
|
151
159
|
### Version 0.0.4
|
152
160
|
* description
|
153
|
-
|
161
|
+
|
162
|
+
### Version 0.0.3
|
163
|
+
* add local stage detection
|
164
|
+
* container autodetect if they should execute on local or remote host
|
165
|
+
|
154
166
|
### Version 0.0.3
|
155
167
|
* use sh instead of bash for docker exec
|
156
168
|
* use correct github url
|
@@ -4,7 +4,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
4
|
|
5
5
|
Gem::Specification.new do |spec|
|
6
6
|
spec.name = 'capistrano-container'
|
7
|
-
spec.version = '0.0.
|
7
|
+
spec.version = '0.0.5'
|
8
8
|
spec.date = '2016-09-26'
|
9
9
|
spec.summary = 'Helps managing docker container and files inside docker container for Capistrano 3.x'
|
10
10
|
spec.description = spec.summary
|
data/lib/capistrano/container.rb
CHANGED
@@ -69,7 +69,7 @@ module Capistrano
|
|
69
69
|
|
70
70
|
else
|
71
71
|
on roles(:container_host) do
|
72
|
-
|
72
|
+
puts capture("docker #{command}")
|
73
73
|
end
|
74
74
|
end
|
75
75
|
end
|
@@ -81,5 +81,19 @@ module Capistrano
|
|
81
81
|
|
82
82
|
fetch(:container_id)
|
83
83
|
end
|
84
|
+
|
85
|
+
def local_stage?
|
86
|
+
fetch(:local_stage_name).to_sym == fetch(:stage).to_sym
|
87
|
+
end
|
88
|
+
|
89
|
+
def execute_local_or_remote(cmd)
|
90
|
+
if local_stage?
|
91
|
+
run_locally do
|
92
|
+
execute cmd
|
93
|
+
end
|
94
|
+
else
|
95
|
+
execute cmd
|
96
|
+
end
|
97
|
+
end
|
84
98
|
end
|
85
99
|
end
|
@@ -30,6 +30,11 @@ class Instance
|
|
30
30
|
end
|
31
31
|
|
32
32
|
def upload!(src, target)
|
33
|
+
if @dsl.local_stage?
|
34
|
+
self.cp(src, "#{container_id}:#{target}")
|
35
|
+
return
|
36
|
+
end
|
37
|
+
|
33
38
|
tmp = "#{@config[:shared_on_host]}/capistrano-docker.#{SecureRandom.uuid}.tmp"
|
34
39
|
|
35
40
|
@dsl.upload!(src, tmp)
|
@@ -40,6 +45,11 @@ class Instance
|
|
40
45
|
end
|
41
46
|
|
42
47
|
def download!(src, target)
|
48
|
+
if @dsl.local_stage?
|
49
|
+
self.cp("#{container_id}:#{src}", target)
|
50
|
+
return
|
51
|
+
end
|
52
|
+
|
43
53
|
tmp = "#{@config[:shared_on_host]}/capistrano-docker.#{SecureRandom.uuid}.tmp"
|
44
54
|
|
45
55
|
self.cp("#{container_id}:#{src}", tmp)
|
@@ -52,13 +62,13 @@ class Instance
|
|
52
62
|
def execute(command)
|
53
63
|
command = "docker exec -i #{container_id} sh -c '#{command.gsub("'", "\'")}'"
|
54
64
|
|
55
|
-
@dsl.
|
65
|
+
@dsl.execute_local_or_remote(command)
|
56
66
|
end
|
57
67
|
|
58
68
|
def cp(src, target)
|
59
69
|
command = "docker cp #{src} #{target}"
|
60
70
|
|
61
|
-
@dsl.
|
71
|
+
@dsl.execute_local_or_remote(command)
|
62
72
|
end
|
63
73
|
|
64
74
|
def invoke(task_name)
|
@@ -1,9 +1,9 @@
|
|
1
1
|
require_relative '../container/mixins.rb'
|
2
2
|
|
3
3
|
namespace :container do
|
4
|
-
desc "
|
5
|
-
task :
|
6
|
-
run_container_command("
|
4
|
+
desc "show docker version"
|
5
|
+
task :version do
|
6
|
+
run_container_command("-v")
|
7
7
|
end
|
8
8
|
|
9
9
|
desc "show all docker containers"
|
@@ -18,3 +18,9 @@ namespace :container do
|
|
18
18
|
|
19
19
|
Mixins.define_tasks
|
20
20
|
end
|
21
|
+
|
22
|
+
namespace :load do
|
23
|
+
task :defaults do
|
24
|
+
set :local_stage_name, :local
|
25
|
+
end
|
26
|
+
end
|