wocker 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +4 -0
- data/Gemfile.lock +1 -1
- data/lib/wocker/cli/build_command.rb +6 -2
- data/lib/wocker/cli/exec_command.rb +9 -1
- data/lib/wocker/cli/init_command.rb +11 -0
- data/lib/wocker/cli/port_command.rb +1 -1
- data/lib/wocker/cli/ps_command.rb +1 -1
- data/lib/wocker/cli/restart_command.rb +1 -1
- data/lib/wocker/cli/rm_command.rb +1 -1
- data/lib/wocker/cli/root_command.rb +1 -0
- data/lib/wocker/cli/start_command.rb +1 -1
- data/lib/wocker/cli/stop_command.rb +1 -1
- data/lib/wocker/cli.rb +1 -0
- data/lib/wocker/vagrant.rb +31 -0
- data/lib/wocker/vagrantfile.rb +16 -60
- data/lib/wocker/vagrantfile_template.rb +10 -0
- data/lib/wocker/version.rb +1 -1
- data/lib/wocker/wockerfile.rb +31 -10
- data/lib/wocker.rb +10 -0
- data/{install-chocolatey.ps1 → scripts/wocker-install-chocolatey.ps1} +0 -1
- data/templates/Vagrantfile +5 -1
- metadata +6 -15
- data/.vagrant/machines/wocker/virtualbox/action_provision +0 -1
- data/.vagrant/machines/wocker/virtualbox/action_set_name +0 -1
- data/.vagrant/machines/wocker/virtualbox/box_meta +0 -1
- data/.vagrant/machines/wocker/virtualbox/creator_uid +0 -1
- data/.vagrant/machines/wocker/virtualbox/id +0 -1
- data/.vagrant/machines/wocker/virtualbox/index_uuid +0 -1
- data/.vagrant/machines/wocker/virtualbox/synced_folders +0 -1
- data/.vagrant/machines/wocker/virtualbox/vagrant_cwd +0 -1
- data/.vagrant/rgloader/loader.rb +0 -9
- data/Vagrantfile +0 -55
- data/Wockerfile +0 -8
- data/lib/dockerfile_parser.rb +0 -60
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 38dcece4d9f2ed8dd4e5af61d2b53d4a3f7e51fe9ee5f81cc387d18f2c1cfc8f
|
4
|
+
data.tar.gz: e8a352a9dc447a79d84d44037ecae40097be8ca3c67b6a050b89f09320c93612
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1bfe5f0b3eb772eebeddb8d0e29b6baf257554985b5e13ecc7627748f5ec9de137874b7c07bd8c6cb9aa453c22d5b45c378908270b8a75a2a504aba4e72bfb4e
|
7
|
+
data.tar.gz: 36797d42577056e749c41d06a911fe24480949c2b83bc1f4135bc0db155022965b76f5af913e80ce480b7cfdd4a43895c6f5fc3f8ba4c764d10e309061b0b159
|
data/.gitignore
CHANGED
data/Gemfile.lock
CHANGED
@@ -4,10 +4,14 @@ module Wocker
|
|
4
4
|
module Cli
|
5
5
|
class BuildCommand < Clamp::Command
|
6
6
|
option "--interface", "INTERFACE", "network interface"
|
7
|
+
option "--choco", :flag, "install chocolatey"
|
7
8
|
|
8
9
|
def execute
|
9
|
-
Wocker::Vagrantfile.
|
10
|
-
|
10
|
+
v = Wocker::Vagrantfile.new interface: interface, choco: choco?
|
11
|
+
v.create_from_wockerfile!
|
12
|
+
|
13
|
+
Wocker::Vagrant.run "destroy", "-f"
|
14
|
+
Wocker::Vagrant.run "up"
|
11
15
|
end
|
12
16
|
end
|
13
17
|
end
|
@@ -6,8 +6,16 @@ module Wocker
|
|
6
6
|
parameter "COMMAND ...", "command"
|
7
7
|
|
8
8
|
def execute
|
9
|
+
command_list.insert 0, "cd"
|
10
|
+
workdir = if Wockerfile.workdir
|
11
|
+
Wockerfile.workdir
|
12
|
+
else
|
13
|
+
"/vagrant"
|
14
|
+
end
|
15
|
+
command_list.insert 1, "#{workdir};"
|
16
|
+
|
9
17
|
cmd = command_list.join " "
|
10
|
-
Wocker::
|
18
|
+
Wocker::Vagrant.run "winrm", "-c", cmd
|
11
19
|
end
|
12
20
|
end
|
13
21
|
end
|
data/lib/wocker/cli.rb
CHANGED
@@ -0,0 +1,31 @@
|
|
1
|
+
require 'pty'
|
2
|
+
|
3
|
+
module Wocker
|
4
|
+
module Vagrant
|
5
|
+
def self.run(*args)
|
6
|
+
stderr_reader, stderr_writer = IO.pipe
|
7
|
+
|
8
|
+
stdout,stdin,pid = PTY.spawn("vagrant", *args, err: stderr_writer.fileno)
|
9
|
+
stderr_writer.close
|
10
|
+
stdin_thr = Thread.new do
|
11
|
+
stdin.close
|
12
|
+
end
|
13
|
+
|
14
|
+
stdout_thr = Thread.new do
|
15
|
+
while line = stdout.gets
|
16
|
+
print line
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
stderr_thr = Thread.new do
|
21
|
+
while line = stderr_reader.gets
|
22
|
+
print line
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
stdin_thr.join
|
27
|
+
stdout_thr.join
|
28
|
+
stderr_thr.join
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
data/lib/wocker/vagrantfile.rb
CHANGED
@@ -1,69 +1,25 @@
|
|
1
|
-
require '
|
2
|
-
require 'erb'
|
1
|
+
require 'fileutils'
|
3
2
|
|
4
3
|
module Wocker
|
5
|
-
|
6
|
-
def
|
7
|
-
|
8
|
-
|
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
|
4
|
+
class Vagrantfile
|
5
|
+
def initialize(interface: nil, choco: false)
|
6
|
+
@interface = interface
|
7
|
+
@choco = choco
|
43
8
|
end
|
44
9
|
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
10
|
+
def create_from_wockerfile! *args
|
11
|
+
v = VagrantfileTemplate.new
|
12
|
+
v.wocker_from = Wockerfile.from
|
13
|
+
v.wocker_runs = Wockerfile.runs
|
14
|
+
v.wocker_ports = Wockerfile.ports
|
15
|
+
v.wocker_interface = @interface
|
16
|
+
v.wocker_installs = []
|
51
17
|
|
52
|
-
|
53
|
-
File.join(
|
54
|
-
|
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
|
18
|
+
if @choco
|
19
|
+
v.wocker_installs << File.join(Wocker.gem_root_path, "scripts", "wocker-install-chocolatey.ps1")
|
20
|
+
end
|
63
21
|
|
64
|
-
|
65
|
-
return if ENV["WOCKER_VAGRANTFILE_KEEP"] == "yes"
|
66
|
-
File.unlink "Vagrantfile"
|
22
|
+
File.write "Vagrantfile", v.render(File.read(File.join(Wocker.gem_root_path, "templates", "Vagrantfile")))
|
67
23
|
end
|
68
24
|
end
|
69
25
|
end
|
data/lib/wocker/version.rb
CHANGED
data/lib/wocker/wockerfile.rb
CHANGED
@@ -1,23 +1,44 @@
|
|
1
|
-
|
1
|
+
require "yaml"
|
2
2
|
|
3
3
|
module Wocker
|
4
|
-
|
5
|
-
|
6
|
-
|
4
|
+
module Wockerfile
|
5
|
+
@@ports = []
|
6
|
+
@@runs = []
|
7
|
+
@@from = nil
|
8
|
+
@@workdir = nil
|
9
|
+
|
10
|
+
def self.ports
|
11
|
+
parse
|
12
|
+
@@ports
|
13
|
+
end
|
14
|
+
def self.runs
|
15
|
+
parse
|
16
|
+
@@runs
|
17
|
+
end
|
18
|
+
def self.from
|
19
|
+
parse
|
20
|
+
@@from
|
21
|
+
end
|
22
|
+
def self.workdir
|
23
|
+
parse
|
24
|
+
@@workdir
|
7
25
|
end
|
8
26
|
|
9
|
-
|
10
|
-
|
27
|
+
private
|
28
|
+
def self.parse
|
29
|
+
contents = File.read "Wockerfile"
|
11
30
|
parsed = YAML.load contents
|
12
|
-
|
31
|
+
@@runs = parsed["runs"]
|
32
|
+
@@from = parsed["from"]
|
33
|
+
@@workdir = parsed["workdir"]
|
34
|
+
|
35
|
+
@@ports = if parsed["ports"]
|
13
36
|
ports_split = []
|
14
37
|
parsed["ports"].each do |port|
|
15
38
|
ports_split << port.split(":")
|
16
39
|
end
|
17
|
-
|
18
|
-
parsed["ports"] = ports_split
|
40
|
+
ports_split
|
19
41
|
end
|
20
|
-
parsed
|
21
42
|
end
|
22
43
|
end
|
23
44
|
end
|
data/lib/wocker.rb
CHANGED
@@ -1,6 +1,16 @@
|
|
1
1
|
module Wocker
|
2
|
+
def self.gem_root_path
|
3
|
+
File.expand_path(
|
4
|
+
File.join(
|
5
|
+
__dir__,
|
6
|
+
".."
|
7
|
+
)
|
8
|
+
)
|
9
|
+
end
|
2
10
|
end
|
3
11
|
|
4
12
|
require_relative "wocker/version"
|
5
13
|
require_relative "wocker/wockerfile"
|
14
|
+
require_relative "wocker/vagrant"
|
6
15
|
require_relative "wocker/vagrantfile"
|
16
|
+
require_relative "wocker/vagrantfile_template"
|
data/templates/Vagrantfile
CHANGED
@@ -9,7 +9,7 @@ Vagrant.configure("2") do |config|
|
|
9
9
|
config.vm.network "public_network", bridge: "<%= @wocker_interface %>"
|
10
10
|
<% end %>
|
11
11
|
<% @wocker_ports.each do |wocker_port| %>
|
12
|
-
|
12
|
+
config.vm.network :forwarded_port, guest: <%= wocker_port[0] %>, host: <%= wocker_port[1] %>
|
13
13
|
<% end %>
|
14
14
|
config.vm.provider "virtualbox" do |vb|
|
15
15
|
vb.gui = true
|
@@ -35,6 +35,10 @@ Vagrant.configure("2") do |config|
|
|
35
35
|
|
36
36
|
config.vm.provision "shell", inline: '&netsh "advfirewall" "set" "allprofiles" "state" "off"'
|
37
37
|
|
38
|
+
<% @wocker_installs.each do |wocker_install| %>
|
39
|
+
config.vm.provision "shell", path: "<%= wocker_install %>"
|
40
|
+
<% end %>
|
41
|
+
|
38
42
|
<% @wocker_runs.each do |wocker_run| %>
|
39
43
|
<% if wocker_run["inline"] %>
|
40
44
|
config.vm.provision "shell", inline: '<%= wocker_run["inline"] %>'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: wocker
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Matti Paksula
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-12-
|
11
|
+
date: 2018-12-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: clamp
|
@@ -79,31 +79,19 @@ files:
|
|
79
79
|
- ".ruby-gemset"
|
80
80
|
- ".ruby-version"
|
81
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
82
|
- Gemfile
|
92
83
|
- Gemfile.lock
|
93
84
|
- LICENSE.txt
|
94
85
|
- README.md
|
95
86
|
- Rakefile
|
96
|
-
- Vagrantfile
|
97
|
-
- Wockerfile
|
98
87
|
- bin/console
|
99
88
|
- bin/setup
|
100
89
|
- exe/wocker
|
101
|
-
- install-chocolatey.ps1
|
102
|
-
- lib/dockerfile_parser.rb
|
103
90
|
- lib/wocker.rb
|
104
91
|
- lib/wocker/cli.rb
|
105
92
|
- lib/wocker/cli/build_command.rb
|
106
93
|
- lib/wocker/cli/exec_command.rb
|
94
|
+
- lib/wocker/cli/init_command.rb
|
107
95
|
- lib/wocker/cli/port_command.rb
|
108
96
|
- lib/wocker/cli/ps_command.rb
|
109
97
|
- lib/wocker/cli/restart_command.rb
|
@@ -112,9 +100,12 @@ files:
|
|
112
100
|
- lib/wocker/cli/start_command.rb
|
113
101
|
- lib/wocker/cli/stop_command.rb
|
114
102
|
- lib/wocker/cli/version_command.rb
|
103
|
+
- lib/wocker/vagrant.rb
|
115
104
|
- lib/wocker/vagrantfile.rb
|
105
|
+
- lib/wocker/vagrantfile_template.rb
|
116
106
|
- lib/wocker/version.rb
|
117
107
|
- lib/wocker/wockerfile.rb
|
108
|
+
- scripts/wocker-install-chocolatey.ps1
|
118
109
|
- templates/Vagrantfile
|
119
110
|
- wocker.gemspec
|
120
111
|
homepage: https://github.com/matti/wocker
|
@@ -1 +0,0 @@
|
|
1
|
-
1.5:994104c6-3a87-4002-b0fe-95636fdc3e4d
|
@@ -1 +0,0 @@
|
|
1
|
-
1544907743
|
@@ -1 +0,0 @@
|
|
1
|
-
{"name":"StefanScherer/windows_2019","version":"2018.11.22","provider":"virtualbox","directory":"boxes/StefanScherer-VAGRANTSLASH-windows_2019/2018.11.22/virtualbox"}
|
@@ -1 +0,0 @@
|
|
1
|
-
501
|
@@ -1 +0,0 @@
|
|
1
|
-
994104c6-3a87-4002-b0fe-95636fdc3e4d
|
@@ -1 +0,0 @@
|
|
1
|
-
8f81c9755061455d8d2494f4d5972017
|
@@ -1 +0,0 @@
|
|
1
|
-
{"virtualbox":{"/vagrant":{"guestpath":"/vagrant","hostpath":"/Users/mpa/Library/Mobile Documents/com~apple~CloudDocs/Documents/dev/wocker","disabled":false,"__vagrantfile":true}}}
|
@@ -1 +0,0 @@
|
|
1
|
-
/Users/mpa/Library/Mobile Documents/com~apple~CloudDocs/Documents/dev/wocker
|
data/.vagrant/rgloader/loader.rb
DELETED
@@ -1,9 +0,0 @@
|
|
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/Vagrantfile
DELETED
@@ -1,55 +0,0 @@
|
|
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
DELETED
data/lib/dockerfile_parser.rb
DELETED
@@ -1,60 +0,0 @@
|
|
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
|