wocker 0.1.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 +7 -0
- data/.gitignore +11 -0
- data/.rspec +3 -0
- data/.ruby-gemset +1 -0
- data/.ruby-version +1 -0
- data/.travis.yml +7 -0
- data/.vagrant/machines/wocker/virtualbox/action_provision +1 -0
- data/.vagrant/machines/wocker/virtualbox/action_set_name +1 -0
- data/.vagrant/machines/wocker/virtualbox/box_meta +1 -0
- data/.vagrant/machines/wocker/virtualbox/creator_uid +1 -0
- data/.vagrant/machines/wocker/virtualbox/id +1 -0
- data/.vagrant/machines/wocker/virtualbox/index_uuid +1 -0
- data/.vagrant/machines/wocker/virtualbox/synced_folders +1 -0
- data/.vagrant/machines/wocker/virtualbox/vagrant_cwd +1 -0
- data/.vagrant/rgloader/loader.rb +9 -0
- data/Gemfile +6 -0
- data/Gemfile.lock +37 -0
- data/LICENSE.txt +21 -0
- data/README.md +35 -0
- data/Rakefile +6 -0
- data/Vagrantfile +55 -0
- data/Wockerfile +8 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/exe/wocker +14 -0
- data/install-chocolatey.ps1 +8 -0
- data/lib/dockerfile_parser.rb +60 -0
- data/lib/wocker/cli/build_command.rb +14 -0
- data/lib/wocker/cli/exec_command.rb +14 -0
- data/lib/wocker/cli/port_command.rb +11 -0
- data/lib/wocker/cli/ps_command.rb +11 -0
- data/lib/wocker/cli/restart_command.rb +11 -0
- data/lib/wocker/cli/rm_command.rb +11 -0
- data/lib/wocker/cli/root_command.rb +31 -0
- data/lib/wocker/cli/start_command.rb +11 -0
- data/lib/wocker/cli/stop_command.rb +11 -0
- data/lib/wocker/cli/version_command.rb +11 -0
- data/lib/wocker/cli.rb +19 -0
- data/lib/wocker/vagrantfile.rb +69 -0
- data/lib/wocker/version.rb +3 -0
- data/lib/wocker/wockerfile.rb +23 -0
- data/lib/wocker.rb +6 -0
- data/templates/Vagrantfile +49 -0
- data/wocker.gemspec +30 -0
- metadata +144 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: 72b6e3df2fabd741a403a07361c83895c354a6c4b0ddcd2d8ebd5f80648dfe76
|
|
4
|
+
data.tar.gz: 976484279f1e8c2991f7ba9d582fd237af6d76e46cc6dd6989c2198a60226bbd
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: 2a32898e6e82410df01e3964dfb73cd537cdf89f216606fb765cc660494074a957bb8180b348e3a0b9098a22d4bf796da48ef727beb4a09ec14ebfa4b18826e6
|
|
7
|
+
data.tar.gz: dac571860cfa31c102f073be8d3202f2299d6f5dea7a56ecf14768e3683a316c30df6eb1bb1d12875c1c6ce8452b53a4fd081fa2816b7de903a3f488171e3010
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.ruby-gemset
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
wocker
|
data/.ruby-version
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
2.5.3
|
data/.travis.yml
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
1.5:994104c6-3a87-4002-b0fe-95636fdc3e4d
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
1544907743
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"name":"StefanScherer/windows_2019","version":"2018.11.22","provider":"virtualbox","directory":"boxes/StefanScherer-VAGRANTSLASH-windows_2019/2018.11.22/virtualbox"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
501
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
994104c6-3a87-4002-b0fe-95636fdc3e4d
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
8f81c9755061455d8d2494f4d5972017
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"virtualbox":{"/vagrant":{"guestpath":"/vagrant","hostpath":"/Users/mpa/Library/Mobile Documents/com~apple~CloudDocs/Documents/dev/wocker","disabled":false,"__vagrantfile":true}}}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
/Users/mpa/Library/Mobile Documents/com~apple~CloudDocs/Documents/dev/wocker
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
# This file loads the proper rgloader/loader.rb file that comes packaged
|
|
2
|
+
# with Vagrant so that encoded files can properly run with Vagrant.
|
|
3
|
+
|
|
4
|
+
if ENV["VAGRANT_INSTALLER_EMBEDDED_DIR"]
|
|
5
|
+
require File.expand_path(
|
|
6
|
+
"rgloader/loader", ENV["VAGRANT_INSTALLER_EMBEDDED_DIR"])
|
|
7
|
+
else
|
|
8
|
+
raise "Encoded files can't be read outside of the Vagrant installer."
|
|
9
|
+
end
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
PATH
|
|
2
|
+
remote: .
|
|
3
|
+
specs:
|
|
4
|
+
wocker (0.1.0)
|
|
5
|
+
clamp
|
|
6
|
+
|
|
7
|
+
GEM
|
|
8
|
+
remote: https://rubygems.org/
|
|
9
|
+
specs:
|
|
10
|
+
clamp (1.3.0)
|
|
11
|
+
diff-lcs (1.3)
|
|
12
|
+
rake (10.5.0)
|
|
13
|
+
rspec (3.8.0)
|
|
14
|
+
rspec-core (~> 3.8.0)
|
|
15
|
+
rspec-expectations (~> 3.8.0)
|
|
16
|
+
rspec-mocks (~> 3.8.0)
|
|
17
|
+
rspec-core (3.8.0)
|
|
18
|
+
rspec-support (~> 3.8.0)
|
|
19
|
+
rspec-expectations (3.8.2)
|
|
20
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
|
21
|
+
rspec-support (~> 3.8.0)
|
|
22
|
+
rspec-mocks (3.8.0)
|
|
23
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
|
24
|
+
rspec-support (~> 3.8.0)
|
|
25
|
+
rspec-support (3.8.0)
|
|
26
|
+
|
|
27
|
+
PLATFORMS
|
|
28
|
+
ruby
|
|
29
|
+
|
|
30
|
+
DEPENDENCIES
|
|
31
|
+
bundler (~> 1.0)
|
|
32
|
+
rake (~> 10.0)
|
|
33
|
+
rspec (~> 3.0)
|
|
34
|
+
wocker!
|
|
35
|
+
|
|
36
|
+
BUNDLED WITH
|
|
37
|
+
1.16.6
|
data/LICENSE.txt
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2018 Matti Paksula
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
|
13
|
+
all copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
# wocker
|
|
2
|
+
|
|
3
|
+
Brewfile:
|
|
4
|
+
```
|
|
5
|
+
cask "virtualbox"
|
|
6
|
+
cask "virtualbox-extension-pack"
|
|
7
|
+
|
|
8
|
+
cask "vagrant"
|
|
9
|
+
|
|
10
|
+
brew "mas"
|
|
11
|
+
mas "Microsoft Remote Desktop", id: 1295203466
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
brew bundle
|
|
15
|
+
|
|
16
|
+
vagrant plugin install vagrant-reload
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
Wockerfile:
|
|
20
|
+
```
|
|
21
|
+
from: StefanScherer/windows_2019
|
|
22
|
+
|
|
23
|
+
runs:
|
|
24
|
+
- path: install-chocolatey.ps1
|
|
25
|
+
- inline: choco install -y ruby
|
|
26
|
+
- inline: choco install -y nircmd
|
|
27
|
+
ports:
|
|
28
|
+
- 9516:5555
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
wocker build --interface "en0: Wi-Fi (Wireless)"
|
|
32
|
+
wocker exec -- gem install delirium-driver
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
gem install wocker
|
data/Rakefile
ADDED
data/Vagrantfile
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
# https://github.com/StefanScherer/docker-windows-box/blob/master/Vagrantfile
|
|
2
|
+
Vagrant.configure("2") do |config|
|
|
3
|
+
config.vm.define "wocker"
|
|
4
|
+
config.vm.guest = "windows"
|
|
5
|
+
|
|
6
|
+
config.vm.box = "StefanScherer/windows_2019"
|
|
7
|
+
config.vm.communicator = "winrm"
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
config.vm.network :forwarded_port, guest: 9516, host: 5555
|
|
11
|
+
|
|
12
|
+
config.vm.provider "virtualbox" do |vb|
|
|
13
|
+
vb.gui = true
|
|
14
|
+
vb.linked_clone = true
|
|
15
|
+
|
|
16
|
+
vb.customize ["modifyvm", :id, "--memory", 2048]
|
|
17
|
+
vb.customize ["modifyvm", :id, "--cpus", 2]
|
|
18
|
+
vb.customize ["modifyvm", :id, "--vram", 128]
|
|
19
|
+
vb.customize ["modifyvm", :id, "--clipboard", "bidirectional"]
|
|
20
|
+
|
|
21
|
+
if false
|
|
22
|
+
vb.customize ["modifyvm", :id, "--accelerate3d", "on"]
|
|
23
|
+
vb.customize ["modifyvm", :id, "--accelerate2dvideo", "on"]
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
# Guest additions requires optical driver
|
|
27
|
+
vb.customize ["storageattach", :id,
|
|
28
|
+
"--storagectl", "IDE Controller",
|
|
29
|
+
"--port", "0", "--device", "1",
|
|
30
|
+
"--type", "dvddrive",
|
|
31
|
+
"--medium", "emptydrive"]
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
config.vm.provision "shell", inline: '&netsh "advfirewall" "set" "allprofiles" "state" "off"'
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
config.vm.provision "shell", path: 'install-chocolatey.ps1'
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
config.vm.provision "shell", inline: 'choco install -y ruby'
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
config.vm.provision "shell", inline: 'choco install -y nircmd'
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
config.vm.provision "shell", inline: 'gem install delirium-driver'
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
config.vm.provision :reload
|
|
55
|
+
end
|
data/Wockerfile
ADDED
data/bin/console
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
|
|
3
|
+
require "bundler/setup"
|
|
4
|
+
require "wocker"
|
|
5
|
+
|
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
|
8
|
+
|
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
|
10
|
+
# require "pry"
|
|
11
|
+
# Pry.start
|
|
12
|
+
|
|
13
|
+
require "irb"
|
|
14
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
data/exe/wocker
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
# frozen_string_literal: true
|
|
3
|
+
|
|
4
|
+
# add lib to libpath (only needed when running from the sources)
|
|
5
|
+
require 'pathname'
|
|
6
|
+
lib_path = File.expand_path('../../lib', Pathname.new(__FILE__).realpath)
|
|
7
|
+
$LOAD_PATH.unshift lib_path unless $LOAD_PATH.include?(lib_path)
|
|
8
|
+
|
|
9
|
+
STDOUT.sync = true
|
|
10
|
+
|
|
11
|
+
require 'wocker'
|
|
12
|
+
require 'wocker/cli'
|
|
13
|
+
|
|
14
|
+
Wocker::Cli::RootCommand.run
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
$ChocoInstallPath = "$env:SystemDrive\ProgramData\Chocolatey\bin"
|
|
2
|
+
|
|
3
|
+
if (!(Test-Path $ChocoInstallPath)) {
|
|
4
|
+
iex ((new-object net.webclient).DownloadString('https://chocolatey.org/install.ps1'))
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
choco feature disable --name showDownloadProgress
|
|
8
|
+
$env:Path += ";C:\ProgramData\Chocolatey\bin"
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
# Encoding: utf-8
|
|
2
|
+
# @author Nikolay Yurin <yurinnick@outlook.com>
|
|
3
|
+
|
|
4
|
+
require 'yaml'
|
|
5
|
+
|
|
6
|
+
# DockerfileParser main class
|
|
7
|
+
class DockerfileParser
|
|
8
|
+
@commands = %w(FROM MAINTAINER RUN CMD EXPOSE ENV ADD COPY ENTRYPOINT
|
|
9
|
+
VOLUME USER WORKDIR ONBUILD)
|
|
10
|
+
|
|
11
|
+
# Parse Dockerfile from specified path
|
|
12
|
+
# @return [Array<Hash>] parser Dockerfile
|
|
13
|
+
def self.load_file(path)
|
|
14
|
+
loads(File.read(path))
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def self.loads(s)
|
|
18
|
+
dockerfile_array = split_dockerfile(s)
|
|
19
|
+
parse_commands(dockerfile_array).each_cons(2).map do |item|
|
|
20
|
+
process_steps(dockerfile_array, item[0], item[1][:index])
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def self.split_dockerfile(str)
|
|
25
|
+
str.gsub(/(\s\\\s)+/i, '').gsub("\n", ' ').squeeze(' ').split(' ')
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def self.parse_commands(dockerfile_array)
|
|
29
|
+
dockerfile_array.each_with_index.map do |cmd, index|
|
|
30
|
+
{ index: index, command: cmd } if @commands.include?(cmd)
|
|
31
|
+
end.compact! << { index: dockerfile_array.length, command: 'EOF' }
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
def self.process_steps(dockerfile_array, step, next_cmd_index)
|
|
35
|
+
{ command: step[:command],
|
|
36
|
+
params: split_params(
|
|
37
|
+
step[:command],
|
|
38
|
+
dockerfile_array[step[:index] + 1..next_cmd_index - 1]
|
|
39
|
+
)
|
|
40
|
+
}
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
def self.split_params(cmd, params)
|
|
44
|
+
case cmd
|
|
45
|
+
when 'FROM' then params.join('').split(':')
|
|
46
|
+
when 'RUN' then params.join(' ').split(/\s(\&|\;)+\s/).map(&:strip)
|
|
47
|
+
when 'ENV' then
|
|
48
|
+
{ name: params[0], value: params[1..-1].join(' ') }
|
|
49
|
+
when 'COPY', 'ADD' then { src: params[0], dst: params[1] }
|
|
50
|
+
else
|
|
51
|
+
params = params.join(' ') if params.is_a?(Array)
|
|
52
|
+
YAML.load(params.to_s)
|
|
53
|
+
end
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
private_class_method :parse_commands
|
|
57
|
+
private_class_method :process_steps
|
|
58
|
+
private_class_method :split_params
|
|
59
|
+
private_class_method :split_dockerfile
|
|
60
|
+
end
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Wocker
|
|
4
|
+
module Cli
|
|
5
|
+
class BuildCommand < Clamp::Command
|
|
6
|
+
option "--interface", "INTERFACE", "network interface"
|
|
7
|
+
|
|
8
|
+
def execute
|
|
9
|
+
Wocker::Vagrantfile.run "destroy", "-f"
|
|
10
|
+
Wocker::Vagrantfile.run "up", interface: interface
|
|
11
|
+
end
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
end
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Wocker
|
|
4
|
+
module Cli
|
|
5
|
+
class ExecCommand < Clamp::Command
|
|
6
|
+
parameter "COMMAND ...", "command"
|
|
7
|
+
|
|
8
|
+
def execute
|
|
9
|
+
cmd = command_list.join " "
|
|
10
|
+
Wocker::Vagrantfile.run "winrm", "-c", cmd
|
|
11
|
+
end
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
end
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Wocker
|
|
4
|
+
module Cli
|
|
5
|
+
class RootCommand < Clamp::Command
|
|
6
|
+
banner "wocker 🐒"
|
|
7
|
+
|
|
8
|
+
option ['-v', '--version'], :flag, "Show version information" do
|
|
9
|
+
puts Wocker::VERSION
|
|
10
|
+
exit(0)
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
subcommand ["version"], "Show version information", VersionCommand
|
|
14
|
+
subcommand ["build"], "build", BuildCommand
|
|
15
|
+
subcommand ["exec"], "exec", ExecCommand
|
|
16
|
+
subcommand ["rm"], "rm", RmCommand
|
|
17
|
+
subcommand ["start"], "start", StartCommand
|
|
18
|
+
subcommand ["stop"], "stop", StopCommand
|
|
19
|
+
subcommand ["ps"], "ps", PsCommand
|
|
20
|
+
subcommand ["port"], "port", PortCommand
|
|
21
|
+
subcommand ["restart"], "restart", RestartCommand
|
|
22
|
+
|
|
23
|
+
def self.run
|
|
24
|
+
super
|
|
25
|
+
rescue StandardError => exc
|
|
26
|
+
warn exc.message
|
|
27
|
+
warn exc.backtrace.join("\n")
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
end
|
data/lib/wocker/cli.rb
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
require "clamp"
|
|
2
|
+
Clamp.allow_options_after_parameters = true
|
|
3
|
+
|
|
4
|
+
module Wocker
|
|
5
|
+
module Cli
|
|
6
|
+
end
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
require_relative "cli/version_command"
|
|
10
|
+
require_relative "cli/build_command"
|
|
11
|
+
require_relative "cli/exec_command"
|
|
12
|
+
require_relative "cli/rm_command"
|
|
13
|
+
require_relative "cli/restart_command"
|
|
14
|
+
require_relative "cli/start_command"
|
|
15
|
+
require_relative "cli/stop_command"
|
|
16
|
+
require_relative "cli/ps_command"
|
|
17
|
+
require_relative "cli/port_command"
|
|
18
|
+
|
|
19
|
+
require_relative "cli/root_command"
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
require 'open3'
|
|
2
|
+
require 'erb'
|
|
3
|
+
|
|
4
|
+
module Wocker
|
|
5
|
+
module Vagrantfile
|
|
6
|
+
def self.run *args, interface: nil
|
|
7
|
+
wockerfile = Wockerfile.new "Wockerfile"
|
|
8
|
+
instructions = wockerfile.parse
|
|
9
|
+
|
|
10
|
+
from = instructions["from"]
|
|
11
|
+
runs = instructions["runs"]
|
|
12
|
+
ports = instructions["ports"]
|
|
13
|
+
|
|
14
|
+
self.create from: from, runs: runs, ports: ports, interface: interface
|
|
15
|
+
|
|
16
|
+
require "pty"
|
|
17
|
+
|
|
18
|
+
stderr_reader, stderr_writer = IO.pipe
|
|
19
|
+
|
|
20
|
+
stdout,stdin,pid = PTY.spawn("vagrant", *args, err: stderr_writer.fileno)
|
|
21
|
+
stderr_writer.close
|
|
22
|
+
stdin_thr = Thread.new do
|
|
23
|
+
stdin.close
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
stdout_thr = Thread.new do
|
|
27
|
+
while line = stdout.gets
|
|
28
|
+
print line
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
stderr_thr = Thread.new do
|
|
33
|
+
while line = stderr_reader.gets
|
|
34
|
+
print line
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
stdin_thr.join
|
|
39
|
+
stdout_thr.join
|
|
40
|
+
stderr_thr.join
|
|
41
|
+
|
|
42
|
+
self.remove
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
private
|
|
46
|
+
def self.create(from:, runs:, ports:, interface: nil)
|
|
47
|
+
@wocker_from = from
|
|
48
|
+
@wocker_runs = runs
|
|
49
|
+
@wocker_ports = ports
|
|
50
|
+
@wocker_interface = interface
|
|
51
|
+
|
|
52
|
+
source_path = File.expand_path(
|
|
53
|
+
File.join(
|
|
54
|
+
__dir__,
|
|
55
|
+
"..","..",
|
|
56
|
+
"templates", "Vagrantfile"
|
|
57
|
+
))
|
|
58
|
+
vagrantfile_template = File.read source_path
|
|
59
|
+
vagrantfile_contents = ERB.new(vagrantfile_template).result(binding)
|
|
60
|
+
|
|
61
|
+
File.write "Vagrantfile", vagrantfile_contents
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
def self.remove
|
|
65
|
+
return if ENV["WOCKER_VAGRANTFILE_KEEP"] == "yes"
|
|
66
|
+
File.unlink "Vagrantfile"
|
|
67
|
+
end
|
|
68
|
+
end
|
|
69
|
+
end
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
require_relative '../dockerfile_parser'
|
|
2
|
+
|
|
3
|
+
module Wocker
|
|
4
|
+
class Wockerfile
|
|
5
|
+
def initialize(path)
|
|
6
|
+
@path = path
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
def parse
|
|
10
|
+
contents = File.read @path
|
|
11
|
+
parsed = YAML.load contents
|
|
12
|
+
if parsed["ports"]
|
|
13
|
+
ports_split = []
|
|
14
|
+
parsed["ports"].each do |port|
|
|
15
|
+
ports_split << port.split(":")
|
|
16
|
+
end
|
|
17
|
+
parsed.delete "ports"
|
|
18
|
+
parsed["ports"] = ports_split
|
|
19
|
+
end
|
|
20
|
+
parsed
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
data/lib/wocker.rb
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
# https://github.com/StefanScherer/docker-windows-box/blob/master/Vagrantfile
|
|
2
|
+
Vagrant.configure("2") do |config|
|
|
3
|
+
config.vm.define "wocker"
|
|
4
|
+
config.vm.guest = "windows"
|
|
5
|
+
|
|
6
|
+
config.vm.box = "<%= @wocker_from %>"
|
|
7
|
+
config.vm.communicator = "winrm"
|
|
8
|
+
<% if @wocker_interface %>
|
|
9
|
+
config.vm.network "public_network", bridge: "<%= @wocker_interface %>"
|
|
10
|
+
<% end %>
|
|
11
|
+
<% @wocker_ports.each do |wocker_port| %>
|
|
12
|
+
config.vm.network :forwarded_port, guest: <%= wocker_port[0] %>, host: <%= wocker_port[1] %>
|
|
13
|
+
<% end %>
|
|
14
|
+
config.vm.provider "virtualbox" do |vb|
|
|
15
|
+
vb.gui = true
|
|
16
|
+
vb.linked_clone = true
|
|
17
|
+
|
|
18
|
+
vb.customize ["modifyvm", :id, "--memory", 2048]
|
|
19
|
+
vb.customize ["modifyvm", :id, "--cpus", 2]
|
|
20
|
+
vb.customize ["modifyvm", :id, "--vram", 128]
|
|
21
|
+
vb.customize ["modifyvm", :id, "--clipboard", "bidirectional"]
|
|
22
|
+
|
|
23
|
+
if false
|
|
24
|
+
vb.customize ["modifyvm", :id, "--accelerate3d", "on"]
|
|
25
|
+
vb.customize ["modifyvm", :id, "--accelerate2dvideo", "on"]
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
# Guest additions requires optical driver
|
|
29
|
+
vb.customize ["storageattach", :id,
|
|
30
|
+
"--storagectl", "IDE Controller",
|
|
31
|
+
"--port", "0", "--device", "1",
|
|
32
|
+
"--type", "dvddrive",
|
|
33
|
+
"--medium", "emptydrive"]
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
config.vm.provision "shell", inline: '&netsh "advfirewall" "set" "allprofiles" "state" "off"'
|
|
37
|
+
|
|
38
|
+
<% @wocker_runs.each do |wocker_run| %>
|
|
39
|
+
<% if wocker_run["inline"] %>
|
|
40
|
+
config.vm.provision "shell", inline: '<%= wocker_run["inline"] %>'
|
|
41
|
+
<% elsif wocker_run["path"] %>
|
|
42
|
+
config.vm.provision "shell", path: '<%= wocker_run["path"] %>'
|
|
43
|
+
<% else %>
|
|
44
|
+
raise "unknown: #{wocker_run}"
|
|
45
|
+
<% end %>
|
|
46
|
+
<% end %>
|
|
47
|
+
|
|
48
|
+
config.vm.provision :reload
|
|
49
|
+
end
|
data/wocker.gemspec
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
|
|
2
|
+
lib = File.expand_path("../lib", __FILE__)
|
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
|
+
require "wocker/version"
|
|
5
|
+
|
|
6
|
+
Gem::Specification.new do |spec|
|
|
7
|
+
spec.name = "wocker"
|
|
8
|
+
spec.version = Wocker::VERSION
|
|
9
|
+
spec.authors = ["Matti Paksula"]
|
|
10
|
+
spec.email = ["matti.paksula@iki.fi"]
|
|
11
|
+
|
|
12
|
+
spec.summary = "vagrant windows workflow tool"
|
|
13
|
+
spec.homepage = "https://github.com/matti/wocker"
|
|
14
|
+
spec.license = "MIT"
|
|
15
|
+
|
|
16
|
+
# Specify which files should be added to the gem when it is released.
|
|
17
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
|
18
|
+
spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
|
|
19
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
|
20
|
+
end
|
|
21
|
+
spec.bindir = "exe"
|
|
22
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
|
23
|
+
spec.require_paths = ["lib"]
|
|
24
|
+
|
|
25
|
+
spec.add_dependency "clamp"
|
|
26
|
+
|
|
27
|
+
spec.add_development_dependency "bundler", "~> 1.0"
|
|
28
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
|
29
|
+
spec.add_development_dependency "rspec", "~> 3.0"
|
|
30
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: wocker
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.1.0
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Matti Paksula
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: exe
|
|
10
|
+
cert_chain: []
|
|
11
|
+
date: 2018-12-15 00:00:00.000000000 Z
|
|
12
|
+
dependencies:
|
|
13
|
+
- !ruby/object:Gem::Dependency
|
|
14
|
+
name: clamp
|
|
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: bundler
|
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
|
30
|
+
requirements:
|
|
31
|
+
- - "~>"
|
|
32
|
+
- !ruby/object:Gem::Version
|
|
33
|
+
version: '1.0'
|
|
34
|
+
type: :development
|
|
35
|
+
prerelease: false
|
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
37
|
+
requirements:
|
|
38
|
+
- - "~>"
|
|
39
|
+
- !ruby/object:Gem::Version
|
|
40
|
+
version: '1.0'
|
|
41
|
+
- !ruby/object:Gem::Dependency
|
|
42
|
+
name: rake
|
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
|
44
|
+
requirements:
|
|
45
|
+
- - "~>"
|
|
46
|
+
- !ruby/object:Gem::Version
|
|
47
|
+
version: '10.0'
|
|
48
|
+
type: :development
|
|
49
|
+
prerelease: false
|
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
51
|
+
requirements:
|
|
52
|
+
- - "~>"
|
|
53
|
+
- !ruby/object:Gem::Version
|
|
54
|
+
version: '10.0'
|
|
55
|
+
- !ruby/object:Gem::Dependency
|
|
56
|
+
name: rspec
|
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
|
58
|
+
requirements:
|
|
59
|
+
- - "~>"
|
|
60
|
+
- !ruby/object:Gem::Version
|
|
61
|
+
version: '3.0'
|
|
62
|
+
type: :development
|
|
63
|
+
prerelease: false
|
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
65
|
+
requirements:
|
|
66
|
+
- - "~>"
|
|
67
|
+
- !ruby/object:Gem::Version
|
|
68
|
+
version: '3.0'
|
|
69
|
+
description:
|
|
70
|
+
email:
|
|
71
|
+
- matti.paksula@iki.fi
|
|
72
|
+
executables:
|
|
73
|
+
- wocker
|
|
74
|
+
extensions: []
|
|
75
|
+
extra_rdoc_files: []
|
|
76
|
+
files:
|
|
77
|
+
- ".gitignore"
|
|
78
|
+
- ".rspec"
|
|
79
|
+
- ".ruby-gemset"
|
|
80
|
+
- ".ruby-version"
|
|
81
|
+
- ".travis.yml"
|
|
82
|
+
- ".vagrant/machines/wocker/virtualbox/action_provision"
|
|
83
|
+
- ".vagrant/machines/wocker/virtualbox/action_set_name"
|
|
84
|
+
- ".vagrant/machines/wocker/virtualbox/box_meta"
|
|
85
|
+
- ".vagrant/machines/wocker/virtualbox/creator_uid"
|
|
86
|
+
- ".vagrant/machines/wocker/virtualbox/id"
|
|
87
|
+
- ".vagrant/machines/wocker/virtualbox/index_uuid"
|
|
88
|
+
- ".vagrant/machines/wocker/virtualbox/synced_folders"
|
|
89
|
+
- ".vagrant/machines/wocker/virtualbox/vagrant_cwd"
|
|
90
|
+
- ".vagrant/rgloader/loader.rb"
|
|
91
|
+
- Gemfile
|
|
92
|
+
- Gemfile.lock
|
|
93
|
+
- LICENSE.txt
|
|
94
|
+
- README.md
|
|
95
|
+
- Rakefile
|
|
96
|
+
- Vagrantfile
|
|
97
|
+
- Wockerfile
|
|
98
|
+
- bin/console
|
|
99
|
+
- bin/setup
|
|
100
|
+
- exe/wocker
|
|
101
|
+
- install-chocolatey.ps1
|
|
102
|
+
- lib/dockerfile_parser.rb
|
|
103
|
+
- lib/wocker.rb
|
|
104
|
+
- lib/wocker/cli.rb
|
|
105
|
+
- lib/wocker/cli/build_command.rb
|
|
106
|
+
- lib/wocker/cli/exec_command.rb
|
|
107
|
+
- lib/wocker/cli/port_command.rb
|
|
108
|
+
- lib/wocker/cli/ps_command.rb
|
|
109
|
+
- lib/wocker/cli/restart_command.rb
|
|
110
|
+
- lib/wocker/cli/rm_command.rb
|
|
111
|
+
- lib/wocker/cli/root_command.rb
|
|
112
|
+
- lib/wocker/cli/start_command.rb
|
|
113
|
+
- lib/wocker/cli/stop_command.rb
|
|
114
|
+
- lib/wocker/cli/version_command.rb
|
|
115
|
+
- lib/wocker/vagrantfile.rb
|
|
116
|
+
- lib/wocker/version.rb
|
|
117
|
+
- lib/wocker/wockerfile.rb
|
|
118
|
+
- templates/Vagrantfile
|
|
119
|
+
- wocker.gemspec
|
|
120
|
+
homepage: https://github.com/matti/wocker
|
|
121
|
+
licenses:
|
|
122
|
+
- MIT
|
|
123
|
+
metadata: {}
|
|
124
|
+
post_install_message:
|
|
125
|
+
rdoc_options: []
|
|
126
|
+
require_paths:
|
|
127
|
+
- lib
|
|
128
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
129
|
+
requirements:
|
|
130
|
+
- - ">="
|
|
131
|
+
- !ruby/object:Gem::Version
|
|
132
|
+
version: '0'
|
|
133
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
134
|
+
requirements:
|
|
135
|
+
- - ">="
|
|
136
|
+
- !ruby/object:Gem::Version
|
|
137
|
+
version: '0'
|
|
138
|
+
requirements: []
|
|
139
|
+
rubyforge_project:
|
|
140
|
+
rubygems_version: 2.7.8
|
|
141
|
+
signing_key:
|
|
142
|
+
specification_version: 4
|
|
143
|
+
summary: vagrant windows workflow tool
|
|
144
|
+
test_files: []
|