docker-sync 0.5.14 → 0.6.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 +5 -5
- data/VERSION +1 -1
- data/lib/docker-sync/dependencies/docker.rb +1 -1
- data/lib/docker-sync/dependencies/rsync.rb +1 -2
- data/lib/docker-sync/dependencies/unison.rb +1 -2
- data/lib/docker-sync/dependencies/unox.rb +2 -4
- data/lib/docker-sync/environment.rb +3 -1
- data/lib/docker-sync/sync_manager.rb +1 -1
- data/lib/docker-sync/sync_strategy/native_osx.rb +1 -1
- data/lib/docker-sync/sync_strategy/unison.rb +46 -41
- data/lib/docker-sync/update_check.rb +1 -1
- data/tasks/sync/sync.thor +11 -0
- metadata +11 -12
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 1670b82d1e005cdfb4485db9241a513f962a732b29d4bd3cf6beec9227c52e65
|
4
|
+
data.tar.gz: da40497b93174d5794d9fe7271a9c8a02c86fac647ee038b6d2380500da0cd31
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e0bf6820a799a2381e343d4cd9e5719a2f1adf2879f1cf82bc1a96833110963b8737a019c5870e74c6a59cb76a9951a97e1bf3226bea5e94a423c69897767dc7
|
7
|
+
data.tar.gz: 550d7628a372fab1328ff3d06452919259409ac4d4d6d01324da9eab1fb99e6dbd26f9ba033fbbf0762134d766691e07edaf6e68117baa0371671c2b21accb43
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.6.0
|
@@ -15,10 +15,8 @@ module DockerSync
|
|
15
15
|
# should never have been called anyway - fix the call that it should check for the OS
|
16
16
|
raise 'Unox cannot be available for other platforms then MacOS' unless Environment.mac?
|
17
17
|
|
18
|
-
|
19
|
-
cmd
|
20
|
-
@available = Environment.system(cmd)
|
21
|
-
@available
|
18
|
+
cmd = 'brew list unox > /dev/null 2>&1'
|
19
|
+
Environment.system(cmd)
|
22
20
|
end
|
23
21
|
|
24
22
|
def self.ensure!
|
@@ -4,11 +4,13 @@ module DockerSync
|
|
4
4
|
module Environment
|
5
5
|
def self.linux?
|
6
6
|
return @linux if defined? @linux
|
7
|
+
|
7
8
|
@linux = OS.linux?
|
8
9
|
end
|
9
10
|
|
10
11
|
def self.mac?
|
11
12
|
return @mac if defined? @mac
|
13
|
+
|
12
14
|
@mac = OS.mac?
|
13
15
|
end
|
14
16
|
|
@@ -17,7 +19,7 @@ module DockerSync
|
|
17
19
|
end
|
18
20
|
|
19
21
|
def self.system(cmd)
|
20
|
-
defined?(Bundler) ? Bundler.
|
22
|
+
defined?(Bundler) ? Bundler.unbundled_system(cmd) : Kernel.system(cmd)
|
21
23
|
end
|
22
24
|
end
|
23
25
|
end
|
@@ -48,7 +48,7 @@ module DockerSync
|
|
48
48
|
end
|
49
49
|
|
50
50
|
if @config_syncs[name].key?('dest')
|
51
|
-
puts 'Please do no longer use "dest" in your docker-sync.yml configuration - also see https://
|
51
|
+
puts 'Please do no longer use "dest" in your docker-sync.yml configuration - also see https://docker-sync.readthedocs.io/en/latest/getting-started/upgrade.html#id4'
|
52
52
|
exit 1
|
53
53
|
else
|
54
54
|
@config_syncs[name]['dest'] = '/app_sync'
|
@@ -14,16 +14,16 @@ module DockerSync
|
|
14
14
|
@sync_name
|
15
15
|
@watch_thread
|
16
16
|
@local_server_pid
|
17
|
-
UNISON_CONTAINER_PORT = '5000'
|
17
|
+
UNISON_CONTAINER_PORT = '5000'.freeze
|
18
18
|
def initialize(sync_name, options)
|
19
19
|
@options = options
|
20
20
|
@sync_name = sync_name
|
21
21
|
# if a custom image is set, apply it
|
22
|
-
if @options.key?('image')
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
22
|
+
@docker_image = if @options.key?('image')
|
23
|
+
@options['image']
|
24
|
+
else
|
25
|
+
'eugenmayer/unison:2.51.3-4.12.0-AMD64'
|
26
|
+
end
|
27
27
|
begin
|
28
28
|
Dependencies::Unison.ensure!
|
29
29
|
Dependencies::Unox.ensure! if Environment.mac?
|
@@ -61,7 +61,7 @@ module DockerSync
|
|
61
61
|
|
62
62
|
def watch
|
63
63
|
args = sync_options
|
64
|
-
args.push(
|
64
|
+
args.push('-repeat watch')
|
65
65
|
cmd = ''
|
66
66
|
cmd = cmd + 'ulimit -n ' + @options['max_inotify_watches'].to_s + ' && ' if @options.key?('max_inotify_watches')
|
67
67
|
cmd = cmd + 'unison ' + args.join(' ')
|
@@ -77,18 +77,18 @@ module DockerSync
|
|
77
77
|
say_status 'command', cmd, :white if @options['verbose']
|
78
78
|
|
79
79
|
stdout, stderr, exit_status = Open3.capture3(cmd)
|
80
|
-
if
|
80
|
+
if !exit_status.success?
|
81
81
|
say_status 'error', "Error starting sync, exit code #{$?.exitstatus}", :red
|
82
82
|
say_status 'message', stdout
|
83
83
|
say_status 'message', stderr
|
84
84
|
else
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
if @options['verbose']
|
90
|
-
say_status 'output', stdout
|
85
|
+
if @options['notify_terminal']
|
86
|
+
TerminalNotifier.notify(
|
87
|
+
"Synced #{@options['src']}", title: @sync_name
|
88
|
+
)
|
91
89
|
end
|
90
|
+
say_status 'ok', "Synced #{@options['src']}", :white
|
91
|
+
say_status 'output', stdout if @options['verbose']
|
92
92
|
end
|
93
93
|
end
|
94
94
|
|
@@ -96,18 +96,16 @@ module DockerSync
|
|
96
96
|
expanded_ignore_strings = []
|
97
97
|
|
98
98
|
exclude_type = 'Name'
|
99
|
-
unless @options['sync_excludes_type'].nil?
|
100
|
-
exclude_type = @options['sync_excludes_type']
|
101
|
-
end
|
99
|
+
exclude_type = @options['sync_excludes_type'] unless @options['sync_excludes_type'].nil?
|
102
100
|
|
103
101
|
unless @options['sync_excludes'].nil?
|
104
102
|
expanded_ignore_strings = @options['sync_excludes'].map do |pattern|
|
105
|
-
if exclude_type == 'none'
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
103
|
+
ignore_string = if exclude_type == 'none'
|
104
|
+
# the ignore type like Name / Path are part of the pattern
|
105
|
+
pattern.to_s
|
106
|
+
else
|
107
|
+
"#{exclude_type} #{pattern}"
|
108
|
+
end
|
111
109
|
"-ignore='#{ignore_string}'"
|
112
110
|
end
|
113
111
|
end
|
@@ -128,32 +126,33 @@ module DockerSync
|
|
128
126
|
if @options.key?('sync_group') || @options.key?('sync_groupid')
|
129
127
|
raise('Unison does not support sync_group, sync_groupid - please use rsync if you need that')
|
130
128
|
end
|
131
|
-
|
129
|
+
|
130
|
+
args
|
132
131
|
end
|
133
132
|
|
134
133
|
# cares about conflict resolution
|
135
134
|
def sync_prefer
|
136
135
|
case @options.fetch('sync_prefer', 'default')
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
136
|
+
when 'default' then "-prefer '#{@options['src']}' -copyonconflict" # thats our default, if nothing is set
|
137
|
+
when 'src' then "-prefer '#{@options['src']}'"
|
138
|
+
when 'dest' then "-prefer 'socket://#{@options['sync_host_ip']}:#{sync_host_port}'"
|
139
|
+
else "-prefer '#{@options['sync_prefer']}'"
|
141
140
|
end
|
142
141
|
end
|
143
142
|
|
144
|
-
|
145
143
|
def start_container
|
146
144
|
say_status 'ok', "Starting unison for sync #{@sync_name}", :white
|
147
145
|
|
148
146
|
container_name = get_container_name
|
149
147
|
volume_name = get_volume_name
|
150
148
|
env = {}
|
151
|
-
|
149
|
+
if @options.key?('sync_user')
|
150
|
+
raise 'sync_user is no longer supported, since it ise no needed, use sync_userid only please'
|
151
|
+
end
|
152
152
|
|
153
153
|
env['UNISON_SRC'] = '-socket 5000'
|
154
154
|
env['UNISON_DEST'] = '/app_sync'
|
155
155
|
|
156
|
-
|
157
156
|
env['MONIT_ENABLE'] = 'false'
|
158
157
|
env['MONIT_INTERVAL'] = ''
|
159
158
|
env['MONIT_HIGH_CPU_CYCLES'] = ''
|
@@ -171,17 +170,19 @@ module DockerSync
|
|
171
170
|
end
|
172
171
|
|
173
172
|
# start unison-image in unison socket mode mode
|
174
|
-
env['HOSTSYNC_ENABLE']=0
|
175
|
-
env['UNISONSOCKET_ENABLE']=1
|
173
|
+
env['HOSTSYNC_ENABLE'] = 0
|
174
|
+
env['UNISONSOCKET_ENABLE'] = 1
|
176
175
|
|
177
|
-
additional_docker_env = env.map{ |key,value| "-e #{key}=\"#{value}\"" }.join(' ')
|
176
|
+
additional_docker_env = env.map { |key, value| "-e #{key}=\"#{value}\"" }.join(' ')
|
178
177
|
running = `docker ps --filter 'status=running' --filter 'name=#{container_name}' --format "{{.Names}}" | grep '^#{container_name}$'`
|
179
178
|
if running == ''
|
180
179
|
say_status 'ok', "#{container_name} container not running", :white if @options['verbose']
|
181
180
|
exists = `docker ps --filter "status=exited" --filter "name=#{container_name}" --format "{{.Names}}" | grep '^#{container_name}$'`
|
182
181
|
if exists == ''
|
183
182
|
run_privileged = ''
|
184
|
-
|
183
|
+
if @options.key?('max_inotify_watches')
|
184
|
+
run_privileged = '--privileged'
|
185
|
+
end # TODO: replace by the minimum capabilities required
|
185
186
|
tz_expression = '-e TZ=$(basename $(dirname `readlink /etc/localtime`))/$(basename `readlink /etc/localtime`)'
|
186
187
|
say_status 'ok', 'Starting precopy', :white if @options['verbose']
|
187
188
|
# we just run the precopy script and remove the container
|
@@ -204,7 +205,7 @@ module DockerSync
|
|
204
205
|
say_status 'ok', "starting initial sync of #{container_name}", :white if @options['verbose']
|
205
206
|
# wait until container is started, then sync:
|
206
207
|
sync_host_port = get_host_port(get_container_name, UNISON_CONTAINER_PORT)
|
207
|
-
cmd = "unison -testserver #{@options['
|
208
|
+
cmd = "unison -testserver #{@options['src']} \"socket://#{@options['sync_host_ip']}:#{sync_host_port}\""
|
208
209
|
say_status 'command', cmd, :white if @options['verbose']
|
209
210
|
attempt = 0
|
210
211
|
max_attempt = @options['max_attempt'] || 5
|
@@ -212,8 +213,12 @@ module DockerSync
|
|
212
213
|
# noinspection RubyUnusedLocalVariable
|
213
214
|
stdout, stderr, exit_status = Open3.capture3(cmd)
|
214
215
|
break if exit_status == 0
|
216
|
+
|
215
217
|
attempt += 1
|
216
|
-
|
218
|
+
if attempt > max_attempt
|
219
|
+
raise "Failed to start unison container in time, try to increase max_attempt (currently #{max_attempt}) in your configuration. See https://github.com/EugenMayer/docker-sync/wiki/2.-Configuration for more informations"
|
220
|
+
end
|
221
|
+
|
217
222
|
sleep 1
|
218
223
|
end
|
219
224
|
sync
|
@@ -221,7 +226,7 @@ module DockerSync
|
|
221
226
|
end
|
222
227
|
|
223
228
|
# noinspection RubyUnusedLocalVariable
|
224
|
-
def get_host_port(container_name,
|
229
|
+
def get_host_port(container_name, _container_port)
|
225
230
|
cmd = 'docker inspect --format=\'{{(index (index .NetworkSettings.Ports "5000/tcp") 0).HostPort}}\' ' + container_name
|
226
231
|
say_status 'command', cmd, :white if @options['verbose']
|
227
232
|
stdout, stderr, exit_status = Open3.capture3(cmd)
|
@@ -230,15 +235,15 @@ module DockerSync
|
|
230
235
|
say_status 'error', "Error getting mapped port, exit code #{$?.exitstatus}", :red
|
231
236
|
say_status 'message', stderr
|
232
237
|
end
|
233
|
-
|
238
|
+
stdout.gsub("\n", '')
|
234
239
|
end
|
235
240
|
|
236
241
|
def get_container_name
|
237
|
-
|
242
|
+
@sync_name.to_s
|
238
243
|
end
|
239
244
|
|
240
245
|
def get_volume_name
|
241
|
-
|
246
|
+
@sync_name
|
242
247
|
end
|
243
248
|
|
244
249
|
def stop_container
|
@@ -93,7 +93,7 @@ class UpdateChecker
|
|
93
93
|
say_status 'warning',"There is an update (#{check.latest_version}) available (current version #{check.current_version}). Please update before you continue",:yellow
|
94
94
|
if yes?("Shall I update docker-sync to #{check.latest_version} for you?")
|
95
95
|
if system('gem update docker-sync')
|
96
|
-
say_status 'success','Successfully updated, please restart docker-sync and check the changelog at https://github.com/EugenMayer/docker-sync/
|
96
|
+
say_status 'success','Successfully updated, please restart docker-sync and check the changelog at https://github.com/EugenMayer/docker-sync/releases',:green
|
97
97
|
exit 0
|
98
98
|
else
|
99
99
|
say_status 'error','Unable to update docker-sync',:red
|
data/tasks/sync/sync.thor
CHANGED
@@ -79,6 +79,17 @@ class Sync < Thor
|
|
79
79
|
|
80
80
|
end
|
81
81
|
|
82
|
+
desc 'restart', 'Restart docker-sync daemon'
|
83
|
+
method_option :daemon, :aliases => '-d', :default => false, :type => :boolean, :desc => 'Run in the background'
|
84
|
+
method_option :foreground, :aliases => '-f', :default => false, :type => :boolean, :desc => 'Run in the foreground'
|
85
|
+
method_option :app_name, :aliases => '--name', :default => 'daemon', :type => :string, :desc => 'App name used in PID and OUTPUT file name for Daemon'
|
86
|
+
method_option :dir, :aliases => '--dir', :default => './.docker-sync', :type => :string, :desc => 'Path to PID and OUTPUT file Directory'
|
87
|
+
method_option :logd, :aliases => '--logd', :default => true, :type => :boolean, :desc => 'To log OUPUT to file on Daemon or not'
|
88
|
+
def restart
|
89
|
+
invoke :stop, options.select{|k, _| ["app_name", "dir"].include?(k) }
|
90
|
+
invoke :start
|
91
|
+
end
|
92
|
+
|
82
93
|
desc 'sync', 'just sync - do not start a watcher though'
|
83
94
|
def sync
|
84
95
|
print_version if options[:version]
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: docker-sync
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Eugen Mayer
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-04-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|
@@ -16,20 +16,20 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '0
|
19
|
+
version: '1.0'
|
20
20
|
- - ">="
|
21
21
|
- !ruby/object:Gem::Version
|
22
|
-
version: 0.
|
22
|
+
version: 1.0.0
|
23
23
|
type: :runtime
|
24
24
|
prerelease: false
|
25
25
|
version_requirements: !ruby/object:Gem::Requirement
|
26
26
|
requirements:
|
27
27
|
- - "~>"
|
28
28
|
- !ruby/object:Gem::Version
|
29
|
-
version: '0
|
29
|
+
version: '1.0'
|
30
30
|
- - ">="
|
31
31
|
- !ruby/object:Gem::Version
|
32
|
-
version: 0.
|
32
|
+
version: 1.0.0
|
33
33
|
- !ruby/object:Gem::Dependency
|
34
34
|
name: gem_update_checker
|
35
35
|
requirement: !ruby/object:Gem::Requirement
|
@@ -209,7 +209,7 @@ homepage: https://github.com/EugenMayer/docker_sync
|
|
209
209
|
licenses:
|
210
210
|
- GPL-3.0
|
211
211
|
metadata: {}
|
212
|
-
post_install_message:
|
212
|
+
post_install_message:
|
213
213
|
rdoc_options: []
|
214
214
|
require_paths:
|
215
215
|
- lib
|
@@ -217,16 +217,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
217
217
|
requirements:
|
218
218
|
- - ">="
|
219
219
|
- !ruby/object:Gem::Version
|
220
|
-
version: '2.
|
220
|
+
version: '2.4'
|
221
221
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
222
222
|
requirements:
|
223
223
|
- - ">="
|
224
224
|
- !ruby/object:Gem::Version
|
225
225
|
version: '0'
|
226
226
|
requirements: []
|
227
|
-
|
228
|
-
|
229
|
-
signing_key:
|
227
|
+
rubygems_version: 3.1.4
|
228
|
+
signing_key:
|
230
229
|
specification_version: 4
|
231
230
|
summary: Docker Sync - Fast and efficient way to sync code to docker-containers
|
232
231
|
test_files: []
|