docksync 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +17 -0
- data/.travis.yml +4 -0
- data/Gemfile +4 -0
- data/Guardfile +12 -0
- data/LICENSE.txt +22 -0
- data/README.md +44 -0
- data/Rakefile +6 -0
- data/bin/docksync +9 -0
- data/docksync.gemspec +29 -0
- data/lib/docksync.rb +8 -0
- data/lib/docksync/bash/install-rsync.sh +52 -0
- data/lib/docksync/cli.rb +24 -0
- data/lib/docksync/cli/help.rb +27 -0
- data/lib/docksync/rsync.rb +33 -0
- data/lib/docksync/rsync/install.rb +56 -0
- data/lib/docksync/rsync/sync.rb +81 -0
- data/lib/docksync/version.rb +3 -0
- data/lib/docksync/watch.rb +22 -0
- data/spec/fixtures/project/.gitignore +34 -0
- data/spec/fixtures/project/Dockerfile +9 -0
- data/spec/lib/cli_spec.rb +20 -0
- data/spec/lib/rsync/install_spec.rb +25 -0
- data/spec/lib/rsync/sync_spec.rb +38 -0
- data/spec/lib/rsync_spec.rb +19 -0
- data/spec/spec_helper.rb +19 -0
- metadata +175 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: fba1d34a7a0f8e938efc1cea2ea53d2186114c3a
|
4
|
+
data.tar.gz: c2aadddd20ff5c49e47f15c519c8546d1a3720d3
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: d331f6208862910a5c88ef825d8426bed9199e8ded8c9d146e4e7f85394b892289ecbebe9d9d86d8434bcabdb26183ecfe7ce2be1296ed68ae96f15f6285c847
|
7
|
+
data.tar.gz: a19de6416f425bdeb525d21c065569e4e252630e474f43f2cff147a001edfde8f759e41af407631ab1e92e4d9d737cc601654db09c777b7ad2b9aeb845614d6e
|
data/.gitignore
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/Guardfile
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
guard 'rspec' do
|
2
|
+
watch(%r{^spec/.+_spec\.rb$})
|
3
|
+
watch(%r{^lib/(.+)\.rb$}) { "spec/docksync_spec.rb" }
|
4
|
+
watch(%r{^lib/docksync/(.+)\.rb$}) { "spec/docksync_spec.rb" }
|
5
|
+
watch('spec/spec_helper.rb') { "spec/docksync_spec.rb" }
|
6
|
+
watch(%r{^lib/docksync/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
|
7
|
+
end
|
8
|
+
|
9
|
+
guard 'bundler' do
|
10
|
+
watch('Gemfile')
|
11
|
+
watch(/^.+\.gemspec/)
|
12
|
+
end
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2013 Tung Nguyen
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
# Docksync
|
2
|
+
|
3
|
+
|
4
|
+
[![Build Status](https://travis-ci.org/tongueroo/docksync.svg?branch=master)](https://travis-ci.org/tongueroo/docksync)
|
5
|
+
[![Code Climate](https://codeclimate.com/github/tongueroo/docksync/badges/gpa.svg)](https://codeclimate.com/github/tongueroo/docksync)
|
6
|
+
|
7
|
+
Tool to rsync your files from your macosx machine to the docker container.
|
8
|
+
|
9
|
+
Sharing volumes from macosx to the docker host to the container is extremely slow. In one of our large applications a task that normally takes 15 seconds takes about 5 mins with the shared volume. This is a 20x performance hit. The issue is not docker, the issue is that the shared volume is slow. For small projects sharing volumes is fine, but for larger projects it is too slow for development. This tool is a hack to sync files from macosx to the docker container. The tool is useful until shared volumes on macosx is faster.
|
10
|
+
|
11
|
+
## How it works
|
12
|
+
|
13
|
+
* It installs and setups an rsync server on the running container.
|
14
|
+
* It then watches for any changed files on your filesystem and will sync them over as needed.
|
15
|
+
* It uses the WORKDIR configured in your Dockerfile and will rsync the project files there.
|
16
|
+
* This only works on ubuntu because it uses apt-get to install the rsync server to the running container.
|
17
|
+
* This also assumes you are using boot2docker.
|
18
|
+
* IMPORTANT: You'll need to expose port 873 so that this script works. You can put this in your Dockerfile, fig.yml or in the docker run command.
|
19
|
+
* Make sure you are not using volumes, the whole point of this gem is to avoid the volume sharing.
|
20
|
+
|
21
|
+
## Installation
|
22
|
+
|
23
|
+
<pre>
|
24
|
+
$ gem install docksync
|
25
|
+
</pre>
|
26
|
+
|
27
|
+
## Usage
|
28
|
+
|
29
|
+
<pre>
|
30
|
+
$ docksync watch [CONTAINER_ID]
|
31
|
+
</pre>
|
32
|
+
|
33
|
+
Example:
|
34
|
+
|
35
|
+
<pre>
|
36
|
+
$ cd project
|
37
|
+
$ docksync watch abcde
|
38
|
+
</pre>
|
39
|
+
|
40
|
+
For more help:
|
41
|
+
|
42
|
+
<pre>
|
43
|
+
$ docksync help
|
44
|
+
</pre>
|
data/Rakefile
ADDED
data/bin/docksync
ADDED
data/docksync.gemspec
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'docksync/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "docksync"
|
8
|
+
spec.version = Docksync::VERSION
|
9
|
+
spec.authors = ["Tung Nguyen"]
|
10
|
+
spec.email = ["tongueroo@gmail.com"]
|
11
|
+
spec.description = %q{Rsync files from your macosx machine to the docker container}
|
12
|
+
spec.summary = %q{Rsync files from your macosx machine to the docker container}
|
13
|
+
spec.homepage = ""
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files`.split($/)
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_dependency "thor"
|
22
|
+
spec.add_dependency "hashie"
|
23
|
+
spec.add_dependency "colorize"
|
24
|
+
spec.add_dependency "filewatcher"
|
25
|
+
|
26
|
+
spec.add_development_dependency "bundler", "~> 1.3"
|
27
|
+
spec.add_development_dependency "rspec"
|
28
|
+
spec.add_development_dependency "rake"
|
29
|
+
end
|
data/lib/docksync.rb
ADDED
@@ -0,0 +1,52 @@
|
|
1
|
+
#!/bin/bash
|
2
|
+
|
3
|
+
APP_ROOT=${APP_ROOT:=$1}
|
4
|
+
APP_ROOT=${APP_ROOT:=/app} # defaults to /app
|
5
|
+
|
6
|
+
install() {
|
7
|
+
if type rsync > /dev/null ; then
|
8
|
+
echo "rsync already installed"
|
9
|
+
else
|
10
|
+
echo "installing rsync"
|
11
|
+
apt-get install -y rsync
|
12
|
+
fi
|
13
|
+
}
|
14
|
+
|
15
|
+
configure() {
|
16
|
+
if [ -f /etc/rsyncd.conf ]; then
|
17
|
+
echo "rsync already configured"
|
18
|
+
else
|
19
|
+
echo "configuring rsync"
|
20
|
+
cat >> /etc/rsyncd.conf << EOF
|
21
|
+
uid = root
|
22
|
+
gid = root
|
23
|
+
use chroot = yes
|
24
|
+
pid file = /var/run/rsyncd.pid
|
25
|
+
log file = /dev/stdout
|
26
|
+
|
27
|
+
[volume]
|
28
|
+
hosts deny = *
|
29
|
+
hosts allow = 192.168.0.0/16 172.16.0.0/12
|
30
|
+
read only = false
|
31
|
+
path = $APP_ROOT
|
32
|
+
comment = app folder
|
33
|
+
EOF
|
34
|
+
fi
|
35
|
+
}
|
36
|
+
|
37
|
+
start() {
|
38
|
+
if [ -f /var/run/rsyncd.pid ]; then
|
39
|
+
echo "rsync already running"
|
40
|
+
else
|
41
|
+
echo "starting rsync"
|
42
|
+
/usr/bin/rsync --daemon --config /etc/rsyncd.conf /bin/bash
|
43
|
+
fi
|
44
|
+
}
|
45
|
+
|
46
|
+
main() {
|
47
|
+
install
|
48
|
+
configure
|
49
|
+
start
|
50
|
+
}
|
51
|
+
|
52
|
+
main
|
data/lib/docksync/cli.rb
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'thor'
|
2
|
+
require 'docksync/cli/help'
|
3
|
+
|
4
|
+
module Docksync
|
5
|
+
|
6
|
+
class CLI < Thor
|
7
|
+
class_option :mute, :type => :boolean
|
8
|
+
class_option :noop, :type => :boolean
|
9
|
+
class_option :cwd, :default => '.'
|
10
|
+
|
11
|
+
desc "rsync [CID]", "rsync local changes to container"
|
12
|
+
long_desc Help.rsync
|
13
|
+
def rsync(cid)
|
14
|
+
Rsync.new(options.merge(:cid => cid)).run
|
15
|
+
end
|
16
|
+
|
17
|
+
desc "watch [CID]", "watch directory and continuously rsync to container"
|
18
|
+
long_desc Help.watch
|
19
|
+
def watch(cid)
|
20
|
+
Watch.new(options.merge(:cid => cid)).run
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
module Docksync
|
2
|
+
class CLI < Thor
|
3
|
+
class Help
|
4
|
+
class << self
|
5
|
+
def rsync
|
6
|
+
<<-EOL
|
7
|
+
Rsync local files to docker container once.
|
8
|
+
|
9
|
+
Examples:
|
10
|
+
|
11
|
+
$ docksync rsync abcde
|
12
|
+
EOL
|
13
|
+
end
|
14
|
+
|
15
|
+
def watch
|
16
|
+
<<-EOL
|
17
|
+
Watch local files and continuously rsync to container.
|
18
|
+
|
19
|
+
Examples:
|
20
|
+
|
21
|
+
$ docksync watch abcde
|
22
|
+
EOL
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
require 'fileutils'
|
2
|
+
require 'colorize'
|
3
|
+
|
4
|
+
module Docksync
|
5
|
+
class Rsync
|
6
|
+
autoload :Install, 'docksync/rsync/install'
|
7
|
+
autoload :Sync, 'docksync/rsync/sync'
|
8
|
+
|
9
|
+
def initialize(options)
|
10
|
+
@options = options
|
11
|
+
@cid = @options[:cid]
|
12
|
+
@cwd = @options[:cwd]
|
13
|
+
end
|
14
|
+
|
15
|
+
def run
|
16
|
+
unless @options[:noop]
|
17
|
+
check
|
18
|
+
Install.new(@options).run unless @options[:skip_install]
|
19
|
+
Sync.new(@options).run
|
20
|
+
end
|
21
|
+
msg = "Done rsyncing to container #{@cid}"
|
22
|
+
@options[:mute] ? msg : puts(msg)
|
23
|
+
end
|
24
|
+
|
25
|
+
def check
|
26
|
+
running = `docker inspect -f {{.State.Running}} #{@cid}`.strip == 'true'
|
27
|
+
unless running
|
28
|
+
puts "Container #{@cid} is not running".colorize(:red)
|
29
|
+
exit 0
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,56 @@
|
|
1
|
+
require 'fileutils'
|
2
|
+
|
3
|
+
module Docksync
|
4
|
+
class Rsync
|
5
|
+
class Install
|
6
|
+
def initialize(options)
|
7
|
+
@options = options
|
8
|
+
@cid = @options[:cid]
|
9
|
+
end
|
10
|
+
|
11
|
+
def run
|
12
|
+
copy_script
|
13
|
+
run_script
|
14
|
+
end
|
15
|
+
|
16
|
+
# hacky way to copy file to the container
|
17
|
+
def copy_script
|
18
|
+
puts "Copying install-rsync.sh script to container"
|
19
|
+
# temporarily use home since boot2docker host mounts /Users
|
20
|
+
src = File.expand_path("../../bash/install-rsync.sh", __FILE__)
|
21
|
+
tmp = "#{ENV['HOME']}/#{File.basename(src)}"
|
22
|
+
FileUtils.cp(src, tmp)
|
23
|
+
|
24
|
+
# copy to actual container
|
25
|
+
system(container_copy_command(tmp))
|
26
|
+
|
27
|
+
# clean up
|
28
|
+
FileUtils.rm_f(tmp)
|
29
|
+
end
|
30
|
+
|
31
|
+
def container_copy_command(src)
|
32
|
+
full_cid = docker_inspect
|
33
|
+
dest = "/var/lib/docker/aufs/mnt/#{full_cid}/tmp/"
|
34
|
+
cmd = %Q|boot2docker ssh "cp #{src} #{dest}"|
|
35
|
+
puts "Running: #{cmd}" unless @options[:mute]
|
36
|
+
cmd
|
37
|
+
end
|
38
|
+
|
39
|
+
def docker_inspect
|
40
|
+
`docker inspect -f '{{.Id}}' #{@cid}`.strip
|
41
|
+
end
|
42
|
+
|
43
|
+
def run_script
|
44
|
+
puts "Installing rsync to container"
|
45
|
+
puts `docker exec #{@cid} /bin/bash -e /tmp/install-rsync.sh #{app_root}`
|
46
|
+
end
|
47
|
+
|
48
|
+
def app_root
|
49
|
+
dockerfile = @options[:cwd] + "/Dockerfile"
|
50
|
+
data = File.read(dockerfile).split("\n").grep(/WORKDIR/)
|
51
|
+
workdir = data.first.split(' ').last
|
52
|
+
end
|
53
|
+
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
@@ -0,0 +1,81 @@
|
|
1
|
+
module Docksync
|
2
|
+
class Rsync
|
3
|
+
class Sync
|
4
|
+
def initialize(options)
|
5
|
+
@options = options
|
6
|
+
@cid = @options[:cid]
|
7
|
+
end
|
8
|
+
|
9
|
+
def dockerhost
|
10
|
+
host = `boot2docker ip 2>&1 | grep address | awk '{print $NF}'`.strip # old version of boot2docker
|
11
|
+
host = `boot2docker ip`.strip if host.empty?
|
12
|
+
host = '192.168.59.103' if host.empty?
|
13
|
+
host
|
14
|
+
end
|
15
|
+
|
16
|
+
def docker_ps_for_port
|
17
|
+
`docker ps | grep #{@cid}`
|
18
|
+
end
|
19
|
+
|
20
|
+
def dockerport
|
21
|
+
out = docker_ps_for_port
|
22
|
+
md = out.match(/0\.0\.0\.0\:(\d+)->873/)
|
23
|
+
if md
|
24
|
+
md[1]
|
25
|
+
else
|
26
|
+
msg = "Could not find expose port 873. Are you sure you exposed port 837 for #{@cid} container?".colorize(:red)
|
27
|
+
if @options[:mute]
|
28
|
+
return msg
|
29
|
+
else
|
30
|
+
puts msg
|
31
|
+
leave
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
def leave
|
37
|
+
exit 0
|
38
|
+
end
|
39
|
+
|
40
|
+
def run
|
41
|
+
puts "Executing: #{command}"
|
42
|
+
system(command)
|
43
|
+
raise "rsync execution returned failure" if ($?.exitstatus != 0)
|
44
|
+
end
|
45
|
+
|
46
|
+
def command
|
47
|
+
# --numeric-ids don't map uid/gid values by user/group name
|
48
|
+
# --safe-links ignore symlinks that point outside the tree
|
49
|
+
# -a, --archive recursion and preserve almost everything (-rlptgoD)
|
50
|
+
# -x, --one-file-system don't cross filesystem boundaries
|
51
|
+
# -z, --compress compress file data during the transfer
|
52
|
+
# -S, --sparse handle sparse files efficiently
|
53
|
+
# -v, --verbose verbose
|
54
|
+
exclude = %w/.git tmp log/
|
55
|
+
exclude += get_excludes('.gitignore')
|
56
|
+
exclude += get_excludes('.dockerignore')
|
57
|
+
exclude = exclude.uniq.map{|path| "--exclude='#{path}'"}.join(' ')
|
58
|
+
options = "--delete --numeric-ids --safe-links -axzSv #{exclude}"
|
59
|
+
src = get_src
|
60
|
+
dest = "rsync://#{dockerhost}:#{dockerport}/volume/"
|
61
|
+
|
62
|
+
"rsync #{options} #{src} #{dest}"
|
63
|
+
end
|
64
|
+
|
65
|
+
def get_excludes(file)
|
66
|
+
exclude = []
|
67
|
+
path = "#{@options[:cwd]}/#{file}"
|
68
|
+
if File.exist?(path)
|
69
|
+
exclude = File.read(path).split("\n")
|
70
|
+
end
|
71
|
+
result = exclude.map {|i| i.strip}.reject {|i| i =~ /^#/ || i.empty?}
|
72
|
+
result
|
73
|
+
end
|
74
|
+
|
75
|
+
def get_src
|
76
|
+
src = @options[:cwd] || '.'
|
77
|
+
src[-1] == '/' ? src : "#{src}/"
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'filewatcher'
|
2
|
+
|
3
|
+
module Docksync
|
4
|
+
class Watch
|
5
|
+
def initialize(options)
|
6
|
+
@options = options
|
7
|
+
end
|
8
|
+
|
9
|
+
def run
|
10
|
+
Dir.chdir(@options[:cwd]) do
|
11
|
+
puts "Watching dir #{@options[:cwd]}"
|
12
|
+
ignore = %w[. .. .git log tmp]
|
13
|
+
files = Dir.glob(['.*','*']) - ignore
|
14
|
+
return false if @options[:noop]
|
15
|
+
Rsync.new(@options).run
|
16
|
+
FileWatcher.new(files).watch() do |filename, event|
|
17
|
+
Rsync.new(@options.merge(:skip_install => true)).run
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
# See http://help.github.com/ignore-files/ for more about ignoring files.
|
2
|
+
#
|
3
|
+
# If you find yourself ignoring temporary files generated by your text editor
|
4
|
+
# or operating system, you probably want to add a global ignore instead:
|
5
|
+
# git config --global core.excludesfile ~/.gitignore_global
|
6
|
+
|
7
|
+
*~
|
8
|
+
|
9
|
+
temp*
|
10
|
+
*.dump
|
11
|
+
|
12
|
+
# Ignore bundler config
|
13
|
+
/.bundle
|
14
|
+
|
15
|
+
# Ignore the default SQLite database.
|
16
|
+
/db/*.sqlite3
|
17
|
+
|
18
|
+
# Ignore all logfiles, tempfiles, and public/uploads.
|
19
|
+
/log/*.log
|
20
|
+
/tmp
|
21
|
+
/public/uploads/
|
22
|
+
/public/assets/
|
23
|
+
|
24
|
+
# Ignore Rubymine system files
|
25
|
+
.idea/
|
26
|
+
|
27
|
+
.DS_Store
|
28
|
+
|
29
|
+
coverage
|
30
|
+
coverage/*
|
31
|
+
|
32
|
+
# Generated via boxen
|
33
|
+
/.env
|
34
|
+
/config/database.yml
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Docksync::CLI do
|
4
|
+
before(:all) do
|
5
|
+
@args = "--noop"
|
6
|
+
@cid = "abcde"
|
7
|
+
end
|
8
|
+
|
9
|
+
describe "cli" do
|
10
|
+
it "should rsync once and quit" do
|
11
|
+
out = execute("bin/docksync rsync #{@cid} #{@args}")
|
12
|
+
expect(out).to include("Done rsyncing to container #{@cid}")
|
13
|
+
end
|
14
|
+
|
15
|
+
it "should watch files and keep rysncing" do
|
16
|
+
out = execute("bin/docksync watch #{@cid} #{@args}")
|
17
|
+
expect(out).to include("Watching dir")
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Docksync::Rsync::Install do
|
4
|
+
before(:all) do
|
5
|
+
@install = Docksync::Rsync::Install.new(
|
6
|
+
cid: 'abcde',
|
7
|
+
mute: true,
|
8
|
+
cwd: 'spec/fixtures/project'
|
9
|
+
)
|
10
|
+
end
|
11
|
+
|
12
|
+
describe "install" do
|
13
|
+
# internal methods
|
14
|
+
it "should build container_copy_command" do
|
15
|
+
allow(@install).to receive(:docker_inspect).and_return("abcde")
|
16
|
+
command = @install.container_copy_command('src')
|
17
|
+
expect(command).to eq(%Q|boot2docker ssh "cp src /var/lib/docker/aufs/mnt/abcde/tmp/"|)
|
18
|
+
end
|
19
|
+
|
20
|
+
it "should read WORKDIR from Dockerfile" do
|
21
|
+
app_root = @install.app_root
|
22
|
+
expect(app_root).to eq("/app")
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Docksync::Rsync::Sync do
|
4
|
+
before(:all) do
|
5
|
+
@sync = Docksync::Rsync::Sync.new(
|
6
|
+
cid: 'abcde',
|
7
|
+
mute: true,
|
8
|
+
cwd: 'spec/fixtures/project'
|
9
|
+
)
|
10
|
+
end
|
11
|
+
|
12
|
+
describe "sync" do
|
13
|
+
it "should build command" do
|
14
|
+
allow(@sync).to receive(:dockerhost).and_return("192.168.59.103")
|
15
|
+
allow(@sync).to receive(:dockerport).and_return("49123")
|
16
|
+
# puts @sync.command
|
17
|
+
expect(@sync.command).to match %r{rsync://192.168.59.103:49123}
|
18
|
+
end
|
19
|
+
|
20
|
+
it "should find exposed port" do
|
21
|
+
ps_out = 'Up 41 seconds 0.0.0.0:48001->3000/tcp, 0.0.0.0:49164->873/tcp cms_web_1'
|
22
|
+
allow(@sync).to receive(:docker_ps_for_port).and_return(ps_out)
|
23
|
+
expect(@sync.dockerport).to eq "49164"
|
24
|
+
end
|
25
|
+
|
26
|
+
it "should give message if exposed port not found" do
|
27
|
+
ps_out = 'Up 41 seconds 0.0.0.0:48001->3000/tcp, 0.0.0.0:49164->800/tcp cms_web_1'
|
28
|
+
allow(@sync).to receive(:leave)
|
29
|
+
allow(@sync).to receive(:docker_ps_for_port).and_return(ps_out)
|
30
|
+
expect(@sync.dockerport).to match /Could not find expose port 873/
|
31
|
+
end
|
32
|
+
|
33
|
+
it "should get excludes from .gitignore" do
|
34
|
+
exclude = @sync.get_excludes('.gitignore')
|
35
|
+
expect(exclude).to include "*.dump"
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Docksync::Rsync do
|
4
|
+
before(:all) do
|
5
|
+
@rsync = Docksync::Rsync.new(
|
6
|
+
cid: 'abcde',
|
7
|
+
noop: true,
|
8
|
+
mute: true
|
9
|
+
)
|
10
|
+
end
|
11
|
+
|
12
|
+
describe "docksync" do
|
13
|
+
it "should install and run rsync" do
|
14
|
+
out = @rsync.run # mainly to check syntax of rsync class
|
15
|
+
expect(out).to eq "Done rsyncing to container abcde"
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
19
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
ENV['TEST'] = '1'
|
2
|
+
|
3
|
+
require "pp"
|
4
|
+
|
5
|
+
root = File.expand_path('../../', __FILE__)
|
6
|
+
require "#{root}/lib/docksync"
|
7
|
+
|
8
|
+
module Helpers
|
9
|
+
def execute(cmd)
|
10
|
+
puts "Running: #{cmd}" if ENV['DEBUG']
|
11
|
+
out = `#{cmd}`
|
12
|
+
puts out if ENV['DEBUG']
|
13
|
+
out
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
RSpec.configure do |c|
|
18
|
+
c.include Helpers
|
19
|
+
end
|
metadata
ADDED
@@ -0,0 +1,175 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: docksync
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Tung Nguyen
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-01-05 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: thor
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: hashie
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: colorize
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: filewatcher
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: bundler
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '1.3'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '1.3'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: rspec
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: rake
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
111
|
+
description: Rsync files from your macosx machine to the docker container
|
112
|
+
email:
|
113
|
+
- tongueroo@gmail.com
|
114
|
+
executables:
|
115
|
+
- docksync
|
116
|
+
extensions: []
|
117
|
+
extra_rdoc_files: []
|
118
|
+
files:
|
119
|
+
- ".gitignore"
|
120
|
+
- ".travis.yml"
|
121
|
+
- Gemfile
|
122
|
+
- Guardfile
|
123
|
+
- LICENSE.txt
|
124
|
+
- README.md
|
125
|
+
- Rakefile
|
126
|
+
- bin/docksync
|
127
|
+
- docksync.gemspec
|
128
|
+
- lib/docksync.rb
|
129
|
+
- lib/docksync/bash/install-rsync.sh
|
130
|
+
- lib/docksync/cli.rb
|
131
|
+
- lib/docksync/cli/help.rb
|
132
|
+
- lib/docksync/rsync.rb
|
133
|
+
- lib/docksync/rsync/install.rb
|
134
|
+
- lib/docksync/rsync/sync.rb
|
135
|
+
- lib/docksync/version.rb
|
136
|
+
- lib/docksync/watch.rb
|
137
|
+
- spec/fixtures/project/.gitignore
|
138
|
+
- spec/fixtures/project/Dockerfile
|
139
|
+
- spec/lib/cli_spec.rb
|
140
|
+
- spec/lib/rsync/install_spec.rb
|
141
|
+
- spec/lib/rsync/sync_spec.rb
|
142
|
+
- spec/lib/rsync_spec.rb
|
143
|
+
- spec/spec_helper.rb
|
144
|
+
homepage: ''
|
145
|
+
licenses:
|
146
|
+
- MIT
|
147
|
+
metadata: {}
|
148
|
+
post_install_message:
|
149
|
+
rdoc_options: []
|
150
|
+
require_paths:
|
151
|
+
- lib
|
152
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
153
|
+
requirements:
|
154
|
+
- - ">="
|
155
|
+
- !ruby/object:Gem::Version
|
156
|
+
version: '0'
|
157
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
158
|
+
requirements:
|
159
|
+
- - ">="
|
160
|
+
- !ruby/object:Gem::Version
|
161
|
+
version: '0'
|
162
|
+
requirements: []
|
163
|
+
rubyforge_project:
|
164
|
+
rubygems_version: 2.4.5
|
165
|
+
signing_key:
|
166
|
+
specification_version: 4
|
167
|
+
summary: Rsync files from your macosx machine to the docker container
|
168
|
+
test_files:
|
169
|
+
- spec/fixtures/project/.gitignore
|
170
|
+
- spec/fixtures/project/Dockerfile
|
171
|
+
- spec/lib/cli_spec.rb
|
172
|
+
- spec/lib/rsync/install_spec.rb
|
173
|
+
- spec/lib/rsync/sync_spec.rb
|
174
|
+
- spec/lib/rsync_spec.rb
|
175
|
+
- spec/spec_helper.rb
|