docker-sync 0.0.9 → 0.0.11
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/Thorfile +0 -3
- data/VERSION +1 -1
- data/bin/docker-sync +2 -2
- data/bin/docker-sync-stack +23 -0
- data/lib/compose.rb +23 -0
- data/lib/config.rb +6 -0
- data/lib/docker_sync/sync_manager.rb +12 -10
- data/lib/docker_sync/sync_strategy/unison.rb +1 -3
- data/lib/update_check.rb +16 -1
- data/tasks/stack/stack.thor +93 -0
- data/tasks/{sync.thor → sync/sync.thor} +2 -2
- metadata +22 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5187439aee543a2580cae6188d1ff4e36a2d2fdc
|
4
|
+
data.tar.gz: 63ee4e96be043f0c1b7744e63c2c5da14575c2e9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 45f6b738ef5138f7a9617694c519d83713cc7af09607f6ace0b3fd1125b37b820de4646448c09866c94d6ea325a729b81dc9bd88fab4524a138a8a114b34ff8d
|
7
|
+
data.tar.gz: 444d000796341735047b6f725e39ab2cbaa8bf1131161d6d1c093544d68328b5a48ad2b284f005137a2c05e32b81dd88d17b215889a935cf479a83461c192470
|
data/Thorfile
CHANGED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.11
|
data/bin/docker-sync
CHANGED
@@ -3,8 +3,8 @@ $LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
|
|
3
3
|
|
4
4
|
require 'thor'
|
5
5
|
require 'update_check'
|
6
|
-
|
7
|
-
thor = File.expand_path('../../tasks', __FILE__)
|
6
|
+
|
7
|
+
thor = File.expand_path('../../tasks/sync', __FILE__)
|
8
8
|
Dir.glob(File.join(thor, '/**/*.thor')).each { |taskfile|
|
9
9
|
load taskfile
|
10
10
|
}
|
@@ -0,0 +1,23 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
$LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
|
3
|
+
|
4
|
+
require 'thor'
|
5
|
+
require 'update_check'
|
6
|
+
|
7
|
+
# ensure docker-compose is installed, if not, do so
|
8
|
+
begin
|
9
|
+
gem 'docker-compose'
|
10
|
+
rescue Gem::LoadError
|
11
|
+
puts "docker-compose gem is missing, installing 'gem install docker-compose'"
|
12
|
+
system('gem install docker-compose')
|
13
|
+
puts 'docker-compose ruby gem installed, please start docker-sync-stack again'
|
14
|
+
exit 0
|
15
|
+
end
|
16
|
+
|
17
|
+
thor = File.expand_path('../../tasks/stack', __FILE__)
|
18
|
+
Dir.glob(File.join(thor, '/**/*.thor')).each { |taskfile|
|
19
|
+
# noinspection RubyResolve
|
20
|
+
load taskfile
|
21
|
+
}
|
22
|
+
|
23
|
+
Stack.start
|
data/lib/compose.rb
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'docker/compose'
|
2
|
+
|
3
|
+
class ComposeManager
|
4
|
+
include Thor::Shell
|
5
|
+
@compose_session
|
6
|
+
def initialize
|
7
|
+
@compose_session = Docker::Compose::Session.new(dir:'./')
|
8
|
+
end
|
9
|
+
|
10
|
+
def run
|
11
|
+
say_status 'ok','starting compose',:white
|
12
|
+
@compose_session.up
|
13
|
+
say_status 'success','started compose',:green
|
14
|
+
end
|
15
|
+
|
16
|
+
def stop
|
17
|
+
@compose_session.stop
|
18
|
+
end
|
19
|
+
|
20
|
+
def clean
|
21
|
+
@compose_session.down
|
22
|
+
end
|
23
|
+
end
|
data/lib/config.rb
CHANGED
@@ -8,6 +8,11 @@ module DockerSyncConfig
|
|
8
8
|
return File.expand_path('~/.docker-sync-global.yml')
|
9
9
|
end
|
10
10
|
|
11
|
+
def is_first_run
|
12
|
+
global_config_path = global_config_location
|
13
|
+
return !File.exist?(global_config_path)
|
14
|
+
end
|
15
|
+
|
11
16
|
def global_config
|
12
17
|
global_config_path = global_config_location
|
13
18
|
date = DateTime.new(2001, 1, 1) #paste
|
@@ -34,6 +39,7 @@ module DockerSyncConfig
|
|
34
39
|
raise('No docker-sync.yml configuration found in your path ( traversing up ) Did you define it for your project?')
|
35
40
|
end
|
36
41
|
end
|
42
|
+
|
37
43
|
# this has been ruthlessly stolen from Thor/runner.rb - please do not hunt me for that :)
|
38
44
|
def find_config_file(skip_lookup = false)
|
39
45
|
# Finds docker-sync.yml by traversing from your current directory down to the root
|
@@ -12,6 +12,7 @@ module Docker_Rsync
|
|
12
12
|
@sync_processes
|
13
13
|
@configurations
|
14
14
|
@config_path
|
15
|
+
|
15
16
|
def initialize(options)
|
16
17
|
@sync_processes = []
|
17
18
|
@config_syncs = []
|
@@ -26,7 +27,7 @@ module Docker_Rsync
|
|
26
27
|
raise "Config could not be loaded from #{@config_path} - it does not exist"
|
27
28
|
end
|
28
29
|
|
29
|
-
config =
|
30
|
+
config = YAML.load_file(@config_path)
|
30
31
|
validate_config(config)
|
31
32
|
@config_options = config['options'] || {}
|
32
33
|
@config_syncs = config['syncs']
|
@@ -70,7 +71,7 @@ module Docker_Rsync
|
|
70
71
|
|
71
72
|
def init_sync_processes(sync_name = nil)
|
72
73
|
if sync_name.nil?
|
73
|
-
@config_syncs.each { |name,sync_configuration|
|
74
|
+
@config_syncs.each { |name, sync_configuration|
|
74
75
|
@sync_processes.push(create_sync(name, sync_configuration))
|
75
76
|
}
|
76
77
|
else
|
@@ -102,27 +103,23 @@ module Docker_Rsync
|
|
102
103
|
@sync_processes.each { |sync_process|
|
103
104
|
sync_process.run
|
104
105
|
}
|
106
|
+
end
|
105
107
|
|
108
|
+
def join_threads
|
106
109
|
begin
|
107
110
|
@sync_processes.each do |sync_process|
|
108
111
|
sync_process.watch_thread.join
|
109
112
|
end
|
110
113
|
|
111
114
|
rescue SystemExit, Interrupt
|
112
|
-
|
113
|
-
puts "Shutting down..."
|
115
|
+
say_status 'shutdown', 'Shutting down...', :blue
|
114
116
|
@sync_processes.each do |sync_process|
|
115
117
|
sync_process.stop
|
116
118
|
end
|
117
|
-
@sync_processes.each do |sync_process|
|
118
|
-
sync_process.watch_thread.kill
|
119
|
-
end
|
120
119
|
|
121
120
|
rescue Exception => e
|
122
|
-
|
123
121
|
puts "EXCEPTION: #{e.inspect}"
|
124
122
|
puts "MESSAGE: #{e.message}"
|
125
|
-
|
126
123
|
end
|
127
124
|
end
|
128
125
|
|
@@ -132,7 +129,12 @@ module Docker_Rsync
|
|
132
129
|
end
|
133
130
|
|
134
131
|
def stop
|
135
|
-
|
132
|
+
@sync_processes.each { |sync_process|
|
133
|
+
sync_process.stop
|
134
|
+
unless sync_process.watch_thread.nil?
|
135
|
+
sync_process.watch_thread.kill
|
136
|
+
end
|
137
|
+
}
|
136
138
|
end
|
137
139
|
end
|
138
140
|
end
|
@@ -55,9 +55,7 @@ module Docker_Sync
|
|
55
55
|
args = []
|
56
56
|
|
57
57
|
unless @options['sync_excludes'].nil?
|
58
|
-
|
59
|
-
say_status 'warning','Excludes are yet not implemented for unison!', :yellow
|
60
|
-
# args = @options['sync_excludes'].map { |pattern| "--exclude='#{pattern}'" } + args
|
58
|
+
args = @options['sync_excludes'].map { |pattern| "-ignore='Path #{pattern}'" } + args
|
61
59
|
end
|
62
60
|
args.push(@options['src'])
|
63
61
|
args.push('-auto')
|
data/lib/update_check.rb
CHANGED
@@ -12,12 +12,13 @@ class UpdateChecker
|
|
12
12
|
|
13
13
|
def run
|
14
14
|
unless @config['update_check']
|
15
|
-
say_status 'hint','Skipping up-to-date check since it has been disabled in
|
15
|
+
say_status 'hint','Skipping up-to-date check since it has been disabled in your ~/.docker-sync-global.yml configuration',:yellow
|
16
16
|
return
|
17
17
|
end
|
18
18
|
unless should_run
|
19
19
|
return
|
20
20
|
end
|
21
|
+
check_rsync_image unless is_first_run # do not check the image if its the first run - since this it will be downloaded anyway
|
21
22
|
check_and_warn(@config['update_enforce'])
|
22
23
|
end
|
23
24
|
|
@@ -32,6 +33,18 @@ class UpdateChecker
|
|
32
33
|
return false
|
33
34
|
end
|
34
35
|
|
36
|
+
def check_rsync_image
|
37
|
+
say_status 'ok','Checking if a newer rsync image is available'
|
38
|
+
|
39
|
+
if system("docker pull eugenmayer/rsync | grep 'Downloaded newer image for'")
|
40
|
+
say_status 'warning', 'Downloaded newer image for rsync', :red
|
41
|
+
say_status 'warning', 'Please use "docker-sync clean" before you start docker-sync again', :red
|
42
|
+
|
43
|
+
exit 0
|
44
|
+
end
|
45
|
+
say_status 'success','Image is (now) up to date'
|
46
|
+
end
|
47
|
+
|
35
48
|
def get_current_version
|
36
49
|
path = File.expand_path('../../', __FILE__)
|
37
50
|
return File.read("#{path}/VERSION")
|
@@ -55,6 +68,8 @@ class UpdateChecker
|
|
55
68
|
say_status 'warning',"There is an update (#{check.latest_version}) available (current version #{check.current_version}). Please update before you continue",:yellow
|
56
69
|
if yes?("Shall i update docker-sync to #{check.latest_version} for you?")
|
57
70
|
system('gem update docker-sync')
|
71
|
+
say_status 'success','Successfully updated, please restart docker-sync and check the changelog at https://github.com/EugenMayer/docker-sync/wiki/5.-Changelog',:green
|
72
|
+
exit 0
|
58
73
|
else
|
59
74
|
exit 1 if update_enforced
|
60
75
|
end
|
@@ -0,0 +1,93 @@
|
|
1
|
+
require 'docker_sync/sync_manager'
|
2
|
+
require 'config'
|
3
|
+
require 'preconditions'
|
4
|
+
require 'update_check'
|
5
|
+
require 'compose'
|
6
|
+
|
7
|
+
class Stack < Thor
|
8
|
+
include DockerSyncConfig
|
9
|
+
include Preconditions
|
10
|
+
|
11
|
+
class_option :config, :aliases => '-c', :default => nil, :type => :string, :desc => 'Path of the docker_sync config'
|
12
|
+
class_option :sync_name, :aliases => '-n', :type => :string, :desc => 'If given, only this sync configuration will be references/started/synced'
|
13
|
+
|
14
|
+
desc 'start', 'Start sync services, watcher and then your docker-compose defined stack'
|
15
|
+
|
16
|
+
def start
|
17
|
+
# do run update check in the start command only
|
18
|
+
updates = UpdateChecker.new
|
19
|
+
updates.run
|
20
|
+
|
21
|
+
begin
|
22
|
+
check_all_preconditions
|
23
|
+
rescue Exception => e
|
24
|
+
say_status 'error', e.message, :red
|
25
|
+
exit 1
|
26
|
+
end
|
27
|
+
|
28
|
+
if options[:config]
|
29
|
+
config_path = options[:config]
|
30
|
+
else
|
31
|
+
begin
|
32
|
+
config_path = find_config
|
33
|
+
rescue Exception => e
|
34
|
+
say_status 'error', e.message, :red
|
35
|
+
return
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
@sync_manager = Docker_Rsync::SyncManager.new(:config_path => config_path)
|
40
|
+
@sync_manager.run(options[:sync_name])
|
41
|
+
|
42
|
+
@compose_manager = ComposeManager.new
|
43
|
+
|
44
|
+
compose_thread = Thread.new {
|
45
|
+
@compose_manager.run
|
46
|
+
}
|
47
|
+
|
48
|
+
begin
|
49
|
+
compose_thread.join
|
50
|
+
#@sync_manager.join_threads
|
51
|
+
rescue SystemExit, Interrupt
|
52
|
+
say_status 'shutdown', 'Shutting down...', :blue
|
53
|
+
|
54
|
+
@sync_manager.stop
|
55
|
+
@compose_manager.stop
|
56
|
+
rescue Exception => e
|
57
|
+
|
58
|
+
puts "EXCEPTION: #{e.inspect}"
|
59
|
+
puts "MESSAGE: #{e.message}"
|
60
|
+
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
desc 'clean', 'compose down your app stack, stop and clean up all sync endpoints'
|
65
|
+
|
66
|
+
def clean
|
67
|
+
begin
|
68
|
+
check_all_preconditions
|
69
|
+
rescue Exception => e
|
70
|
+
say_status 'error', e.message, :red
|
71
|
+
exit 1
|
72
|
+
end
|
73
|
+
|
74
|
+
if options[:config]
|
75
|
+
config_path = options[:config]
|
76
|
+
else
|
77
|
+
begin
|
78
|
+
config_path = find_config
|
79
|
+
rescue Exception => e
|
80
|
+
say_status 'error', e.message, :red
|
81
|
+
return
|
82
|
+
end
|
83
|
+
end
|
84
|
+
@compose_manager = ComposeManager.new
|
85
|
+
@compose_manager.clean
|
86
|
+
say_status 'success', 'Finished cleaning up your app stack', :green
|
87
|
+
|
88
|
+
@sync_manager = Docker_Rsync::SyncManager.new(:config_path => config_path)
|
89
|
+
@sync_manager.clean(options[:sync_name])
|
90
|
+
say_status 'success', 'Finished cleanup. Removed stopped, removed sync container and removed there volumes', :green
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
@@ -35,9 +35,10 @@ class Sync < Thor
|
|
35
35
|
end
|
36
36
|
@sync_manager = Docker_Rsync::SyncManager.new(:config_path => config_path)
|
37
37
|
@sync_manager.run(options[:sync_name])
|
38
|
+
@sync_manager.join_threads
|
38
39
|
end
|
39
40
|
|
40
|
-
desc '
|
41
|
+
desc 'sync', 'sync - do not start a watcher'
|
41
42
|
def sync
|
42
43
|
begin
|
43
44
|
check_all_preconditions
|
@@ -87,7 +88,6 @@ class Sync < Thor
|
|
87
88
|
desc 'list', 'List all sync-points of the project configuration path'
|
88
89
|
method_option :verbose, :default => false, :type => :boolean, :desc => 'Verbose output'
|
89
90
|
def list
|
90
|
-
pp Gem.configuration
|
91
91
|
begin
|
92
92
|
check_all_preconditions
|
93
93
|
rescue Exception => e
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: docker-sync
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.11
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Eugen Mayer
|
@@ -16,39 +16,54 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '0'
|
19
|
+
version: '0.19'
|
20
|
+
- - ">="
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: 0.19.0
|
20
23
|
type: :runtime
|
21
24
|
prerelease: false
|
22
25
|
version_requirements: !ruby/object:Gem::Requirement
|
23
26
|
requirements:
|
24
27
|
- - "~>"
|
25
28
|
- !ruby/object:Gem::Version
|
26
|
-
version: '0'
|
29
|
+
version: '0.19'
|
30
|
+
- - ">="
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: 0.19.0
|
27
33
|
- !ruby/object:Gem::Dependency
|
28
34
|
name: gem_update_checker
|
29
35
|
requirement: !ruby/object:Gem::Requirement
|
30
36
|
requirements:
|
31
37
|
- - "~>"
|
32
38
|
- !ruby/object:Gem::Version
|
33
|
-
version:
|
39
|
+
version: 0.2.0
|
40
|
+
- - ">="
|
41
|
+
- !ruby/object:Gem::Version
|
42
|
+
version: 0.2.0
|
34
43
|
type: :runtime
|
35
44
|
prerelease: false
|
36
45
|
version_requirements: !ruby/object:Gem::Requirement
|
37
46
|
requirements:
|
38
47
|
- - "~>"
|
39
48
|
- !ruby/object:Gem::Version
|
40
|
-
version:
|
49
|
+
version: 0.2.0
|
50
|
+
- - ">="
|
51
|
+
- !ruby/object:Gem::Version
|
52
|
+
version: 0.2.0
|
41
53
|
description: Sync your code live to docker-containers without losing any performance
|
42
54
|
on OSX
|
43
55
|
email: eugen.mayer@kontextwork.de
|
44
56
|
executables:
|
45
57
|
- docker-sync
|
58
|
+
- docker-sync-stack
|
46
59
|
extensions: []
|
47
60
|
extra_rdoc_files: []
|
48
61
|
files:
|
49
62
|
- Thorfile
|
50
63
|
- VERSION
|
51
64
|
- bin/docker-sync
|
65
|
+
- bin/docker-sync-stack
|
66
|
+
- lib/compose.rb
|
52
67
|
- lib/config.rb
|
53
68
|
- lib/docker_sync/sync_manager.rb
|
54
69
|
- lib/docker_sync/sync_process.rb
|
@@ -58,7 +73,8 @@ files:
|
|
58
73
|
- lib/execution.rb
|
59
74
|
- lib/preconditions.rb
|
60
75
|
- lib/update_check.rb
|
61
|
-
- tasks/
|
76
|
+
- tasks/stack/stack.thor
|
77
|
+
- tasks/sync/sync.thor
|
62
78
|
homepage: https://github.com/EugenMayer/docker_sync
|
63
79
|
licenses:
|
64
80
|
- GPL
|