docker-provider 0.0.1

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.
Files changed (52) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +19 -0
  3. data/.rspec +2 -0
  4. data/.travis.yml +8 -0
  5. data/CHANGELOG.md +3 -0
  6. data/Gemfile +21 -0
  7. data/Gemfile.lock +125 -0
  8. data/Guardfile +6 -0
  9. data/LICENSE.txt +22 -0
  10. data/README.md +134 -0
  11. data/Rakefile +20 -0
  12. data/boxes/dummy/README.md +17 -0
  13. data/boxes/dummy/metadata.json +3 -0
  14. data/boxes/nginx/.gitignore +1 -0
  15. data/boxes/nginx/Dockerfile +4 -0
  16. data/boxes/nginx/README.md +25 -0
  17. data/boxes/nginx/Vagrantfile.sample +6 -0
  18. data/boxes/nginx/metadata.json +3 -0
  19. data/boxes/nginx/start +5 -0
  20. data/boxes/precise/.gitignore +1 -0
  21. data/boxes/precise/Dockerfile +42 -0
  22. data/boxes/precise/README.md +18 -0
  23. data/boxes/precise/Vagrantfile.sample +6 -0
  24. data/boxes/precise/metadata.json +3 -0
  25. data/development/Vagrantfile +91 -0
  26. data/docker-provider.gemspec +25 -0
  27. data/example/Vagrantfile +36 -0
  28. data/lib/docker-provider.rb +1 -0
  29. data/lib/docker-provider/action.rb +161 -0
  30. data/lib/docker-provider/action/check_running.rb +25 -0
  31. data/lib/docker-provider/action/create.rb +56 -0
  32. data/lib/docker-provider/action/created.rb +18 -0
  33. data/lib/docker-provider/action/destroy.rb +24 -0
  34. data/lib/docker-provider/action/forward_ports.rb +54 -0
  35. data/lib/docker-provider/action/is_running.rb +20 -0
  36. data/lib/docker-provider/action/message.rb +23 -0
  37. data/lib/docker-provider/action/share_folders.rb +63 -0
  38. data/lib/docker-provider/action/start.rb +18 -0
  39. data/lib/docker-provider/action/stop.rb +21 -0
  40. data/lib/docker-provider/config.rb +28 -0
  41. data/lib/docker-provider/driver.rb +114 -0
  42. data/lib/docker-provider/plugin.rb +24 -0
  43. data/lib/docker-provider/provider.rb +59 -0
  44. data/lib/docker-provider/version.rb +5 -0
  45. data/locales/en.yml +21 -0
  46. data/spec/acceptance/Vagrantfile +25 -0
  47. data/spec/acceptance/vagrant_ssh.bats +34 -0
  48. data/spec/acceptance/vagrant_up.bats +35 -0
  49. data/spec/spec_helper.rb +19 -0
  50. data/spec/support/unit_example_group.rb +39 -0
  51. data/spec/unit/driver_spec.rb +143 -0
  52. metadata +142 -0
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 4ecc63749fe1c7951f04eecbcedc6579fcec0db7
4
+ data.tar.gz: fbdb3556de90b576e1b3613e4de96791599963fc
5
+ SHA512:
6
+ metadata.gz: 575626e4f52623abc118e4feee9df5faa2f4a82c1adacd449b2c657b38e1a07ecd233f24bfd381d8a9c64259675425f66adbf82dbe4e33b35bd1026043e1eee1
7
+ data.tar.gz: 8f457fe8e793b59ad56c8e575cb7d2497a65d96a5545f23390e5c5e8ac053bbbc9e35cbd09b04e30a894965dd4b050c6757d0692d67aa9aae16311b92fe39c50
@@ -0,0 +1,19 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ InstalledFiles
7
+ _yardoc
8
+ coverage
9
+ doc/
10
+ lib/bundler/man
11
+ pkg
12
+ rdoc
13
+ spec/reports
14
+ test/tmp
15
+ test/version_tmp
16
+ tmp
17
+ /development/.vagrant
18
+ /example/.vagrant
19
+ /spec/acceptance/.vagrant
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --format progress
@@ -0,0 +1,8 @@
1
+ language: ruby
2
+ rvm:
3
+ - 1.9.3
4
+ - 2.0.0
5
+ matrix:
6
+ allow_failures:
7
+ - rvm: 2.0.0
8
+ script: "bundle exec rake spec:unit"
@@ -0,0 +1,3 @@
1
+ ## 0.0.1 (November 5, 2013)
2
+
3
+ - Initial public release.
data/Gemfile ADDED
@@ -0,0 +1,21 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in docker-provider.gemspec
4
+ gemspec
5
+
6
+ group :development, :test do
7
+ gem 'vagrant', github: 'mitchellh/vagrant'
8
+ end
9
+
10
+ group :development do
11
+ gem 'guard'
12
+ gem 'guard-rspec'
13
+ gem 'rb-inotify'
14
+
15
+ gem 'vagrant-notify', github: 'fgrehm/vagrant-notify'
16
+ gem 'vagrant-cachier', github: 'fgrehm/vagrant-cachier'
17
+ gem 'vagrant-pristine', github: 'fgrehm/vagrant-pristine'
18
+ gem 'vagrant-lxc', github: 'fgrehm/vagrant-lxc'
19
+ gem 'vagrant-global-status', github: 'fgrehm/vagrant-global-status'
20
+ gem 'ventriloquist', github: 'fgrehm/ventriloquist'
21
+ end
@@ -0,0 +1,125 @@
1
+ GIT
2
+ remote: git://github.com/fgrehm/vagrant-cachier.git
3
+ revision: 536ca7ad54b3096644993f91f363df8a884d4600
4
+ specs:
5
+ vagrant-cachier (0.4.2.dev)
6
+
7
+ GIT
8
+ remote: git://github.com/fgrehm/vagrant-global-status.git
9
+ revision: a0295400a0e47756cbcb8f97ed9f4449b1fb6b56
10
+ specs:
11
+ vagrant-global-status (0.1.1)
12
+
13
+ GIT
14
+ remote: git://github.com/fgrehm/vagrant-lxc.git
15
+ revision: 4ca375ec5049fd2e50773b486df84ecd14f0dc4f
16
+ specs:
17
+ vagrant-lxc (0.6.5.dev)
18
+
19
+ GIT
20
+ remote: git://github.com/fgrehm/vagrant-notify.git
21
+ revision: 4fd0040dc63ac88094aaa52c21496badebe1f938
22
+ specs:
23
+ vagrant-notify (0.3.0)
24
+
25
+ GIT
26
+ remote: git://github.com/fgrehm/vagrant-pristine.git
27
+ revision: 4638491786943bfbf6f115b1fc379f069963fe46
28
+ specs:
29
+ vagrant-pristine (0.3.0)
30
+
31
+ GIT
32
+ remote: git://github.com/fgrehm/ventriloquist.git
33
+ revision: 0eadf36c67417b13890715bc365b858b8adcd959
34
+ specs:
35
+ ventriloquist (0.3.3.dev)
36
+ vocker (~> 0.3.3)
37
+
38
+ GIT
39
+ remote: git://github.com/mitchellh/vagrant.git
40
+ revision: a92e03cf4ce936243d3959b7b5603262a234a58d
41
+ specs:
42
+ vagrant (1.3.6.dev)
43
+ childprocess (~> 0.3.7)
44
+ erubis (~> 2.7.0)
45
+ i18n (~> 0.6.0)
46
+ log4r (~> 1.1.9)
47
+ net-scp (~> 1.1.0)
48
+ net-ssh (~> 2.6.6)
49
+
50
+ PATH
51
+ remote: .
52
+ specs:
53
+ docker-provider (0.0.1)
54
+
55
+ GEM
56
+ remote: https://rubygems.org/
57
+ specs:
58
+ celluloid (0.15.2)
59
+ timers (~> 1.1.0)
60
+ childprocess (0.3.9)
61
+ ffi (~> 1.0, >= 1.0.11)
62
+ coderay (1.0.9)
63
+ diff-lcs (1.2.4)
64
+ erubis (2.7.0)
65
+ ffi (1.9.3)
66
+ formatador (0.2.4)
67
+ guard (2.2.2)
68
+ formatador (>= 0.2.4)
69
+ listen (~> 2.1)
70
+ lumberjack (~> 1.0)
71
+ pry (>= 0.9.12)
72
+ thor (>= 0.18.1)
73
+ guard-rspec (4.0.3)
74
+ guard (>= 2.1.1)
75
+ rspec (~> 2.14)
76
+ i18n (0.6.5)
77
+ listen (2.2.0)
78
+ celluloid (>= 0.15.2)
79
+ rb-fsevent (>= 0.9.3)
80
+ rb-inotify (>= 0.9)
81
+ log4r (1.1.10)
82
+ lumberjack (1.0.4)
83
+ method_source (0.8.2)
84
+ net-scp (1.1.2)
85
+ net-ssh (>= 2.6.5)
86
+ net-ssh (2.6.8)
87
+ pry (0.9.12.2)
88
+ coderay (~> 1.0.5)
89
+ method_source (~> 0.8)
90
+ slop (~> 3.4)
91
+ rake (10.1.0)
92
+ rb-fsevent (0.9.3)
93
+ rb-inotify (0.9.2)
94
+ ffi (>= 0.5.0)
95
+ rspec (2.14.1)
96
+ rspec-core (~> 2.14.0)
97
+ rspec-expectations (~> 2.14.0)
98
+ rspec-mocks (~> 2.14.0)
99
+ rspec-core (2.14.7)
100
+ rspec-expectations (2.14.3)
101
+ diff-lcs (>= 1.1.3, < 2.0)
102
+ rspec-mocks (2.14.4)
103
+ slop (3.4.6)
104
+ thor (0.18.1)
105
+ timers (1.1.0)
106
+ vocker (0.3.3)
107
+
108
+ PLATFORMS
109
+ ruby
110
+
111
+ DEPENDENCIES
112
+ bundler (~> 1.3)
113
+ docker-provider!
114
+ guard
115
+ guard-rspec
116
+ rake
117
+ rb-inotify
118
+ rspec
119
+ vagrant!
120
+ vagrant-cachier!
121
+ vagrant-global-status!
122
+ vagrant-lxc!
123
+ vagrant-notify!
124
+ vagrant-pristine!
125
+ ventriloquist!
@@ -0,0 +1,6 @@
1
+ guard 'rspec', :spec_paths => ["spec/unit"] do
2
+ watch(%r{^spec/unit/.+_spec\.rb$})
3
+ watch(%r{^lib/docker-provider/(.+)\.rb$}) { |m| "spec/unit/#{m[1]}_spec.rb" }
4
+ watch('spec/spec_helper.rb') { "spec/unit" }
5
+ watch(%r{^spec/support/(.+)\.rb$}) { "spec/unit" }
6
+ end
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 Fabio Rehm
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.
@@ -0,0 +1,134 @@
1
+ # docker-provider
2
+
3
+ A spike on a [Docker](http://www.docker.io/) provider for [Vagrant](http://www.vagrantup.com/)
4
+ 1.3+.
5
+
6
+
7
+ ## Warning
8
+
9
+ This is highly experimental and is just 8 [tomatoes](http://pomodorotechnique.com/)
10
+ worth of development / testing.
11
+
12
+
13
+ ## Requirements
14
+
15
+ * Vagrant 1.3+
16
+ * Docker 0.6.5+
17
+
18
+
19
+ ## Features
20
+
21
+ * Support for Vagrant's `up`, `destroy`, `halt`, `reload` and `ssh` commands
22
+ * Port forwarding
23
+ * Synced / shared folders support
24
+ * Set container hostnames from Vagrantfiles
25
+ * Provision Docker containers with any built-in Vagrant provider
26
+
27
+
28
+ ## Getting started
29
+
30
+ If you are on a Mac / Windows machine, please fire up a x64 VM with Docker +
31
+ Vagrant installed or use [this Vagrantfile](https://gist.github.com/fgrehm/fc48fb51ec7df64439e4)
32
+ and follow the instructions from there.
33
+
34
+ The plugin is not very user friendly at the moment, so please download the base
35
+ Docker image manually with `docker pull fgrehm/vagrant-ubuntu:precise` in order
36
+ to have some feedback about the download process.
37
+
38
+ Assuming you have Vagrant 1.3+ and Docker 0.6.5+ installed just sing that same
39
+ old song:
40
+
41
+ ```
42
+ vagrant plugin install docker-provider
43
+ vagrant box add precise http://bit.ly/vagrant-docker-precise
44
+ vagrant init precise
45
+ vagrant up --provider=docker
46
+ ```
47
+
48
+
49
+ ## Using custom images
50
+
51
+ If you want to use a custom Docker image without creating a Vagrant base box,
52
+ you can use a "dummy" box:
53
+
54
+ ```
55
+ vagrant box add dummy http://bit.ly/vagrant-docker-dummy
56
+ ```
57
+
58
+ And configure things from your `Vagrantfile` like in [vagrant-digitalocean](https://github.com/smdahlen/vagrant-digitalocean#configure)
59
+ or [vagrant-aws](https://github.com/mitchellh/vagrant-aws#quick-start):
60
+
61
+ ```ruby
62
+ Vagrant.configure("2") do |config|
63
+ config.vm.box = "dummy"
64
+ config.vm.provider :docker do |docker|
65
+ docker.image = "your/image:tag"
66
+ docker.cmd = ["/path/to/your", "command"]
67
+ end
68
+ end
69
+ ```
70
+
71
+
72
+ ## Limitations
73
+
74
+ There's probably a whole lot of limitations right now but during these early days
75
+ of the plugin I can tell you for sure that some things are probably not going to
76
+ work as you might expect. For instance forwarded ports, synced folders and containers'
77
+ hostnames will not be reconfigured on `vagrant reload`s if they have changed and
78
+ the plugin **_will not give you any kind of warning or message_**. Forwarded ports
79
+ automatic collision handling is **_not supported as well_**.
80
+
81
+ The plugin also requires Docker's executable to be available on current user's `PATH`
82
+ and that the current user has been added to the `docker` group since we are not
83
+ using `sudo` when interacting with Docker's CLI. For more information on setting
84
+ this up please check [this page](http://docs.docker.io/en/latest/use/basics/#why-sudo).
85
+
86
+ Another thing to keep in mind is that Docker is all about _application containers_
87
+ and not _machine containers_. I failed to boot a Docker container in what people
88
+ have been calling "[machine mode](https://github.com/dotcloud/docker/issues/2170#issuecomment-26118964)"
89
+ and some hacking will be required in order to run multiple processes on the
90
+ container as described below. For more information about the issues related to
91
+ it, please search Docker's issue tracker for `/sbin/init` and / or "machine mode".
92
+
93
+
94
+ ## Box format
95
+
96
+ Every provider in Vagrant must introduce a custom box format. This provider introduces
97
+ `docker` boxes and you can view some examples in the [`boxes`](boxes) directory.
98
+ That directory also contains instructions on how to build them.
99
+
100
+ The box format is basically just the required `metadata.json` file along with a
101
+ `Vagrantfile` that does default settings for the provider-specific configuration
102
+ for this provider.
103
+
104
+
105
+ ## Running multiple processes on the container
106
+
107
+ Unless you are able to run the container in "machine mode", you'll need to create
108
+ a custom command / script that starts the processes you need prior to firing up
109
+ the SSH server. An example can be found at the [`boxes/nginx`](boxes/nginx)
110
+ folder of this repo.
111
+
112
+ On a side note, if you really need your Docker containers to behave like machines
113
+ with Vagrant and you can't get it to work that way like me, you might want to use
114
+ [vagrant-lxc](https://github.com/fgrehm/vagrant-lxc) as an alternative.
115
+
116
+
117
+ ## Got feedback?
118
+
119
+ Please keep in mind that this is a spike and I'm not sure if / how the project
120
+ will evolve. I'm planning to write about why I built this at some point but
121
+ in case you have any feedback feel free to open up an [issue here on GitHub](https://github.com/fgrehm/docker-provider/issues),
122
+ shoot a tweet to [@fgrehm](https://twitter.com/fgrehm) or send a mail to the
123
+ address available on my GitHub profile.
124
+
125
+
126
+ ## Contributing
127
+
128
+ 1. Fork it
129
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
130
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
131
+ 4. Push to the branch (`git push origin my-new-feature`)
132
+ 5. Create new Pull Request
133
+
134
+ [![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/fgrehm/docker-provider/trend.png)](https://bitdeli.com/free "Bitdeli Badge")
@@ -0,0 +1,20 @@
1
+ require "bundler/gem_tasks"
2
+ require 'rspec/core/rake_task'
3
+
4
+ namespace :spec do
5
+ desc 'Run acceptance specs using Bats'
6
+ task :acceptance do
7
+ sh 'bats spec/acceptance'
8
+ end
9
+
10
+ require 'rspec/core/rake_task'
11
+ desc "Run unit specs using RSpec"
12
+ RSpec::Core::RakeTask.new('unit') do |t|
13
+ t.pattern = "./unit/**/*_spec.rb"
14
+ end
15
+ end
16
+
17
+ desc 'Run all specs'
18
+ task :spec => ['spec:unit', 'spec:acceptance']
19
+
20
+ task :default => 'spec'
@@ -0,0 +1,17 @@
1
+ # Dummy box
2
+
3
+ Vagrant providers each require a custom provider-specific box format. This folder
4
+ contains a "dummy" box that allows you to use the plugin without the need to create
5
+ a custom base box.
6
+
7
+ To turn this into a "box", run:
8
+
9
+ ```
10
+ tar cvzf dummy.box ./metadata.json
11
+ ```
12
+
13
+ By using this box you'll need to specify a Docker image on your `Vagrantfile`
14
+ [as described](README.md#using-custom-images) on the README.
15
+
16
+ For "real world" examples please check out [`boxes/precise`](boxes/precise) and
17
+ [`boxes/nginx`](boxes/nginx).
@@ -0,0 +1,3 @@
1
+ {
2
+ "provider": "docker"
3
+ }
@@ -0,0 +1 @@
1
+ Vagrantfile
@@ -0,0 +1,4 @@
1
+ # Start with a docker-provider ready image
2
+ FROM fgrehm/vagrant-ubuntu:precise
3
+ RUN apt-get update && apt-get install nginx -y
4
+ ADD ./start /bin/start-container
@@ -0,0 +1,25 @@
1
+ # Nginx base box example
2
+
3
+ This folder contains an example of a box that is able to run multiple processes.
4
+ With the provided `Dockerfile` you'll be able to build a base box that runs both
5
+ nginx and a SSH server that is required by Vagrant to do its "magic".
6
+
7
+
8
+ ```
9
+ docker build -t myuser/vagrant-nginx .
10
+ docker push myuser/vagrant-nginx
11
+ sed 's/IMAGE/myuser\/vagrant-nginx/' Vagrantfile.sample > Vagrantfile
12
+ tar cvzf nginx.box ./metadata.json ./Vagrantfile
13
+ ```
14
+
15
+ In order to reach the nginx server running on the container you'll need to
16
+ forward the ports with a `Vagrantfile` like the one below:
17
+
18
+ ```ruby
19
+ Vagrant.configure("2") do |config|
20
+ # Replace with the name of the box you used when adding
21
+ config.vm.box = "nginx"
22
+ # This makes nginx accessible from the host from http://localhost:8080
23
+ config.vm.network "forwarded_port", guest: 80, host: 8080
24
+ end
25
+ ```
@@ -0,0 +1,6 @@
1
+ Vagrant.configure("2") do |config|
2
+ config.vm.provider :docker do |docker|
3
+ docker.image = "IMAGE"
4
+ docker.cmd = ["/bin/start-container"]
5
+ end
6
+ end