devkitkat 0.1.26 → 0.1.29
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +17 -1
- data/lib/devkitkat/command.rb +5 -0
- data/lib/devkitkat/service.rb +4 -0
- data/lib/devkitkat/service/driver/docker/container.rb +4 -2
- data/lib/devkitkat/service/executor.rb +7 -6
- data/lib/devkitkat/service/executor/variables.rb +7 -0
- data/lib/devkitkat/service/predefined_command/add_example.rb +4 -0
- data/lib/devkitkat/service/predefined_command/add_git_ignore.rb +4 -0
- data/lib/devkitkat/service/predefined_command/add_script.rb +4 -0
- data/lib/devkitkat/service/predefined_command/add_shared_script.rb +4 -0
- data/lib/devkitkat/service/predefined_command/base.rb +4 -0
- data/lib/devkitkat/service/predefined_command/clean.rb +4 -0
- data/lib/devkitkat/service/predefined_command/clone.rb +4 -0
- data/lib/devkitkat/service/predefined_command/pull.rb +4 -0
- data/lib/devkitkat/service/predefined_command/remove_containers.rb +21 -0
- data/lib/devkitkat/service/predefined_command/show_variables.rb +4 -0
- data/lib/devkitkat/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f91fde9edf9ce28487edc62750fa05a2b28eb47b873f210d604253228c54cdf8
|
4
|
+
data.tar.gz: 723f2f178357b49750fc8b16e04f648caf345a151ca8e0b393ae574237a78c12
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '0679b7c01e774727548d8628b34ac3263c398e32d7b1457d1cfdc43f7d045391afa1d936e97b61aaccd606c0e3b9f5786bbddaad3901eb6c80b1756b2fff1502'
|
7
|
+
data.tar.gz: b74a7d2df3304e3fbc5eb825c054590ee61e53b217e9a30da7df4da0073a8d9b95fd77affb808e70989e605f4ffa06935c9f7834b241275593036eab8c860ed8
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -46,6 +46,20 @@ download/prepare services. These are available keys.
|
|
46
46
|
|
47
47
|
There are pre-occupied special keys, please do not use these keys in your config file: `services:system`, `services:self`
|
48
48
|
|
49
|
+
### `machine:` key
|
50
|
+
|
51
|
+
|Key |Type |Required|Default|Description|
|
52
|
+
|--- |--- |--- |---|---|
|
53
|
+
|`machine:` |Hash |No |-|The machine to run the application|
|
54
|
+
|`machine:driver` |String |No |-|The driver name, one of `none` or `docker`. Default is `none`.|
|
55
|
+
|`machine:location` |String |No |-|The machine location, one of `local` or `remote`. Default is `local`.|
|
56
|
+
|`machine:image` |String |No |-|The docker image used as the machine image.|
|
57
|
+
|`machine:extra_hosts` |Array<String>|No |-|Extra hosts to be added to `/etc/hosts` in the machine|
|
58
|
+
|`machine:network_mode` |String |No |-|Docker Network Mode, one of `bridge`, `host`.|
|
59
|
+
|`machine:extra_write_accesses` |Array<String>|No |-|Extra write access to each service. By default, a service mounts only own directory as read-write and mounts the other service directories as read-only volume. To add extra write access, you specify `'<service-name>:to:<service-name>'`|
|
60
|
+
|
61
|
+
|
62
|
+
|
49
63
|
## Sample `.devkitkat.yml` that runs services in local environment
|
50
64
|
|
51
65
|
```yaml
|
@@ -60,7 +74,9 @@ services:
|
|
60
74
|
## Sample `.devkitkat.yml` that runs services in docker containers
|
61
75
|
|
62
76
|
```yaml
|
63
|
-
|
77
|
+
machine:
|
78
|
+
driver: docker
|
79
|
+
image: your-dev-machine-image:latest
|
64
80
|
|
65
81
|
services:
|
66
82
|
web:
|
data/lib/devkitkat/command.rb
CHANGED
@@ -46,6 +46,10 @@ module Devkitkat
|
|
46
46
|
opts.separator ""
|
47
47
|
opts.separator "Options:"
|
48
48
|
|
49
|
+
opts.on("-d", "--driver", "Machine Driver") do |v|
|
50
|
+
options[:driver] = v
|
51
|
+
end
|
52
|
+
|
49
53
|
opts.on("-d", "--debug", "Debug mode") do |v|
|
50
54
|
options[:debug] = v
|
51
55
|
end
|
@@ -94,6 +98,7 @@ module Devkitkat
|
|
94
98
|
opts.separator "clean - Clean the service dir"
|
95
99
|
opts.separator "poop - Poop"
|
96
100
|
opts.separator "show-variables - Show all variables via 'export' command"
|
101
|
+
opts.separator "remove-containers - Remove all related containers"
|
97
102
|
end
|
98
103
|
end
|
99
104
|
|
data/lib/devkitkat/service.rb
CHANGED
@@ -84,7 +84,8 @@ module Devkitkat
|
|
84
84
|
'Image' => image,
|
85
85
|
'name' => name,
|
86
86
|
'HostConfig' => {
|
87
|
-
'Binds' => all_mounts
|
87
|
+
'Binds' => all_mounts,
|
88
|
+
'Privileged' => true
|
88
89
|
}
|
89
90
|
}
|
90
91
|
|
@@ -121,7 +122,7 @@ module Devkitkat
|
|
121
122
|
else
|
122
123
|
"#{service.dir}:#{ROOT_IN_CONTAINER}/services/#{service.name}:ro"
|
123
124
|
end
|
124
|
-
end
|
125
|
+
end.append('/var/run/docker.sock:/var/run/docker.sock')
|
125
126
|
end
|
126
127
|
|
127
128
|
def allowed_by_extra_write_accesses?(service)
|
@@ -162,6 +163,7 @@ module Devkitkat
|
|
162
163
|
|
163
164
|
prepare!(['chown', "#{user_name}:#{user_name}", ROOT_IN_CONTAINER])
|
164
165
|
prepare!(['chown', '-R', "#{user_name}:#{user_name}", "#{ROOT_IN_CONTAINER}/services/#{service.name}"])
|
166
|
+
prepare!(['usermod', '-aG', 'docker', user_name])
|
165
167
|
end
|
166
168
|
|
167
169
|
def prepare!(cmds, params = {})
|
@@ -40,9 +40,11 @@ module Devkitkat
|
|
40
40
|
if File.exist?(service.script_path)
|
41
41
|
scripter.write(%Q{echo "INFO: This script is a custom script."})
|
42
42
|
scripter.write(service.script_path)
|
43
|
+
@machine_driver = command.options[:driver]
|
43
44
|
elsif predefined_command_available?
|
44
45
|
scripter.write(%Q{echo "INFO: This script is a predefined script in devkitkat."})
|
45
46
|
scripter.write(predefined_command.to_script)
|
47
|
+
@machine_driver = predefined_command.machine_driver
|
46
48
|
else
|
47
49
|
false
|
48
50
|
end
|
@@ -51,6 +53,7 @@ module Devkitkat
|
|
51
53
|
end
|
52
54
|
|
53
55
|
def execute!
|
56
|
+
driver = get_driver_klass.new(service)
|
54
57
|
driver.prepare
|
55
58
|
|
56
59
|
driver.execute(scripter.file_path).tap do |result|
|
@@ -60,10 +63,6 @@ module Devkitkat
|
|
60
63
|
driver.cleanup
|
61
64
|
end
|
62
65
|
|
63
|
-
def driver
|
64
|
-
@driver ||= driver_klass.new(service)
|
65
|
-
end
|
66
|
-
|
67
66
|
def scripter
|
68
67
|
@scripter ||= Scripter.new(service)
|
69
68
|
end
|
@@ -80,8 +79,10 @@ module Devkitkat
|
|
80
79
|
@predefined_command ||= predefined_command_klass.new(service)
|
81
80
|
end
|
82
81
|
|
83
|
-
def
|
84
|
-
|
82
|
+
def get_driver_klass
|
83
|
+
driver = @machine_driver || service.machine_driver || config.machine_driver
|
84
|
+
|
85
|
+
Object.const_get("Devkitkat::Service::Driver::#{driver.camelize}")
|
85
86
|
end
|
86
87
|
|
87
88
|
def predefined_command_klass
|
@@ -18,9 +18,12 @@ module Devkitkat
|
|
18
18
|
def predefined_global_variables
|
19
19
|
variables = []
|
20
20
|
variables << "export DK_ROOT_DIR=#{command.kit_root}"
|
21
|
+
variables << "export DK_COMMAND_TARGET=#{command.target}"
|
21
22
|
variables << "export DK_MACHINE_DRIVER=#{config.machine_driver.to_s}"
|
22
23
|
variables << "export DK_MACHINE_LOCATION=#{config.machine_location.to_s}"
|
23
24
|
variables << "export DK_MACHINE_IMAGE=#{config.machine_image.to_s}"
|
25
|
+
variables << "export DK_MACHINE_EXTRA_HOSTS=#{config.machine_extra_hosts.join(',').to_s}"
|
26
|
+
variables << "export DK_MACHINE_NETWORK_MODE=#{config.machine_network_mode.to_s}"
|
24
27
|
variables << "export DK_APPLICATION=#{config.application.to_s}"
|
25
28
|
variables
|
26
29
|
end
|
@@ -36,6 +39,8 @@ module Devkitkat
|
|
36
39
|
end
|
37
40
|
|
38
41
|
config.service_hash(service.name).each do |key, value|
|
42
|
+
next if value.is_a?(Hash)
|
43
|
+
|
39
44
|
variables << "export DK_#{service.name.upcase}_#{key.upcase}=#{value}"
|
40
45
|
end
|
41
46
|
|
@@ -65,6 +70,8 @@ module Devkitkat
|
|
65
70
|
|
66
71
|
def config_service_variables
|
67
72
|
config.service_hash(service.name).map do |key, value|
|
73
|
+
next if value.is_a?(Hash)
|
74
|
+
|
68
75
|
"export #{key}=#{value}"
|
69
76
|
end
|
70
77
|
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module Devkitkat
|
2
|
+
class Service
|
3
|
+
class PredefinedCommand
|
4
|
+
class RemoveContainers < Base
|
5
|
+
def to_script
|
6
|
+
<<~EOS
|
7
|
+
docker rm -f $(docker ps -a -f name=#{config.application}-* -q)
|
8
|
+
EOS
|
9
|
+
end
|
10
|
+
|
11
|
+
def available?
|
12
|
+
true
|
13
|
+
end
|
14
|
+
|
15
|
+
def machine_driver
|
16
|
+
'none'
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
data/lib/devkitkat/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: devkitkat
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.29
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Shinya Maeda
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-04-
|
11
|
+
date: 2020-04-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -228,6 +228,7 @@ files:
|
|
228
228
|
- lib/devkitkat/service/predefined_command/poop.rb
|
229
229
|
- lib/devkitkat/service/predefined_command/pull.rb
|
230
230
|
- lib/devkitkat/service/predefined_command/reconfigure.rb
|
231
|
+
- lib/devkitkat/service/predefined_command/remove_containers.rb
|
231
232
|
- lib/devkitkat/service/predefined_command/show_variables.rb
|
232
233
|
- lib/devkitkat/version.rb
|
233
234
|
homepage: https://gitlab.com/dosuken123/devkitkat
|