minke 1.13.20 → 1.14.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +2 -2
- data/bin/minke +3 -0
- data/docker/Gemfile +1 -1
- data/lib/minke/command.rb +14 -7
- data/lib/minke/config/config.rb +7 -0
- data/lib/minke/config/reader.rb +2 -0
- data/lib/minke/docker/docker_runner.rb +39 -5
- data/lib/minke/tasks/shell.rb +31 -0
- data/lib/minke/tasks/task.rb +7 -2
- data/lib/minke/version.rb +1 -1
- data/lib/minke.rb +2 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a75b7d20dfa4be64d0c2624adce3b9f9e25ec3ea
|
4
|
+
data.tar.gz: 681b7ff115b1b9c411cae5cd893f1d627f11c531
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 40f40d0ad96bb89401230a08b99001e98993accb2cfd72c899ba27bf86f506efedec85d6de500186a52b5994801875df6eb719c2d82e849f72f0a4eb197795f1
|
7
|
+
data.tar.gz: ec4dd302f0844486acbc3d816d377bb03e7a2470a5390f03244046ba36c14322d31e65dfd8ac3adc820a63871cf3c7f6e9999c815eb1411cf910e012f4164420
|
data/.travis.yml
CHANGED
@@ -30,7 +30,7 @@ after_deploy:
|
|
30
30
|
docker build -t nicholasjackson/minke --build-arg BUILD_DATE=`date -u +"%Y-%m-%dT%H:%M:%SZ"` --build-arg VCS_REF=`git rev-parse --short HEAD` .;
|
31
31
|
docker login -e="$DOCKER_EMAIL" -u="$DOCKER_USERNAME" -p="$DOCKER_PASSWORD";
|
32
32
|
docker push nicholasjackson/minke:latest;
|
33
|
-
docker tag nicholasjackson/minke nicholasjackson/minke:1.
|
34
|
-
docker push nicholasjackson/minke:1.
|
33
|
+
docker tag nicholasjackson/minke nicholasjackson/minke:1.14.0;
|
34
|
+
docker push nicholasjackson/minke:1.14.0;
|
35
35
|
curl https://hooks.microbadger.com/images/nicholasjackson/minke/tkpohfdrYPE0B0TL5NzLcOap4k0=;
|
36
36
|
fi
|
data/bin/minke
CHANGED
@@ -39,6 +39,7 @@ Commonly used command are:
|
|
39
39
|
build_image : build a docker image
|
40
40
|
push : push built image to the registry
|
41
41
|
encrypt : encrypt secrets with a private key
|
42
|
+
shell : start a shell session inside the build container
|
42
43
|
See 'minke COMMAND --help' for more information on a specific command.
|
43
44
|
HELP
|
44
45
|
|
@@ -155,6 +156,8 @@ when "run"
|
|
155
156
|
doCommand(:run, options[:verbose], options[:config])
|
156
157
|
when "push"
|
157
158
|
doCommand(:push, options[:verbose], options[:config])
|
159
|
+
when "shell"
|
160
|
+
doCommand(:shell, options[:verbose], options[:config])
|
158
161
|
when "generate"
|
159
162
|
if options[:generator] == nil || options[:output] == nil || options[:name] == nil || options[:namespace] == nil
|
160
163
|
puts "Please specify options use: minke generate --help for help on command line options"
|
data/docker/Gemfile
CHANGED
data/lib/minke/command.rb
CHANGED
@@ -18,12 +18,12 @@ module Minke
|
|
18
18
|
logger = Minke::Logging.create_logger(self.verbose)
|
19
19
|
shell = Minke::Helpers::Shell.new(logger)
|
20
20
|
|
21
|
-
variables = Minke::Generators::ConfigVariables.new.tap do |v|
|
22
|
-
v.application_name = @config.application_name
|
23
|
-
v.namespace = @config.namespace
|
24
|
-
v.src_root = File.expand_path('../')
|
25
|
-
end
|
26
|
-
|
21
|
+
# variables = Minke::Generators::ConfigVariables.new.tap do |v|
|
22
|
+
# v.application_name = @config.application_name
|
23
|
+
# v.namespace = @config.namespace
|
24
|
+
# v.src_root = File.expand_path('../')
|
25
|
+
# end
|
26
|
+
|
27
27
|
task_runner = Minke::Tasks::TaskRunner.new ({
|
28
28
|
:ruby_helper => Minke::Helpers::Ruby.new,
|
29
29
|
:copy_helper => Minke::Helpers::Copy.new,
|
@@ -74,7 +74,8 @@ module Minke
|
|
74
74
|
:run => Minke::Tasks::Run.new(dependencies),
|
75
75
|
:build_image => Minke::Tasks::BuildImage.new(dependencies),
|
76
76
|
:cucumber => Minke::Tasks::Cucumber.new(dependencies),
|
77
|
-
:push => Minke::Tasks::Push.new(dependencies)
|
77
|
+
:push => Minke::Tasks::Push.new(dependencies),
|
78
|
+
:shell => Minke::Tasks::Shell.new(dependencies)
|
78
79
|
}
|
79
80
|
end
|
80
81
|
|
@@ -128,5 +129,11 @@ module Minke
|
|
128
129
|
tasks[:push].run
|
129
130
|
end
|
130
131
|
|
132
|
+
def shell
|
133
|
+
if config.shell != nil
|
134
|
+
tasks = create_tasks :shell
|
135
|
+
tasks[:shell].run
|
136
|
+
end
|
137
|
+
end
|
131
138
|
end
|
132
139
|
end
|
data/lib/minke/config/config.rb
CHANGED
@@ -70,6 +70,13 @@ module Minke
|
|
70
70
|
# [Optional] if not provided the cucumber commands will not be executed
|
71
71
|
attr_accessor :cucumber
|
72
72
|
|
73
|
+
##
|
74
|
+
# Settings for the build shell phase
|
75
|
+
# instance of Minke::Config::Task
|
76
|
+
#
|
77
|
+
# [Optional] if not provided the shell commands will not be executed
|
78
|
+
attr_accessor :shell
|
79
|
+
|
73
80
|
##
|
74
81
|
# Returns the docker_compose file for the given section,
|
75
82
|
# if the section overrides application_compose_file then this is returned
|
data/lib/minke/config/reader.rb
CHANGED
@@ -31,6 +31,8 @@ module Minke
|
|
31
31
|
config.run = read_task_section file['run'], config.docker unless file['run'] == nil
|
32
32
|
config.cucumber = read_task_section file['cucumber'], config.docker unless file['cucumber'] == nil
|
33
33
|
|
34
|
+
config.shell = read_task_section file['shell'], config.docker unless file['shell'] == nil
|
35
|
+
|
34
36
|
return config
|
35
37
|
end
|
36
38
|
|
@@ -76,7 +76,7 @@ module Minke
|
|
76
76
|
"Env" => args[:environment],
|
77
77
|
'WorkingDir' => args[:working_directory],
|
78
78
|
'NetworkMode' => @network,
|
79
|
-
'name'
|
79
|
+
'name' => args[:name],
|
80
80
|
'PublishAllPorts' => true
|
81
81
|
)
|
82
82
|
|
@@ -97,14 +97,48 @@ module Minke
|
|
97
97
|
end
|
98
98
|
end
|
99
99
|
|
100
|
-
|
101
|
-
|
102
100
|
container.start
|
103
|
-
|
104
101
|
thread.join unless args[:deamon] == true
|
105
102
|
|
106
103
|
success = (container.json['State']['ExitCode'] == 0) ? true: false
|
107
|
-
|
104
|
+
@logger.error(output) unless success
|
105
|
+
|
106
|
+
return container, success
|
107
|
+
end
|
108
|
+
|
109
|
+
#
|
110
|
+
# create_and_run_blocking_container starts a conatainer of the given image name and executes a command, this method blocks until the container exits
|
111
|
+
#
|
112
|
+
# Returns:
|
113
|
+
# - Docker::Container
|
114
|
+
# - sucess (true if command succeded without error)
|
115
|
+
def create_and_run_blocking_container args
|
116
|
+
# update the timeout for the Excon Http Client
|
117
|
+
# set the chunk size to enable streaming of log files
|
118
|
+
::Docker.options = {:chunk_size => 1, :read_timeout => 3600}
|
119
|
+
container = ::Docker::Container.create(
|
120
|
+
'Image' => args[:image],
|
121
|
+
'Cmd' => args[:command],
|
122
|
+
"Binds" => args[:volumes],
|
123
|
+
"Env" => args[:environment],
|
124
|
+
'WorkingDir' => args[:working_directory],
|
125
|
+
'name' => args[:name],
|
126
|
+
'NetworkMode' => @network,
|
127
|
+
"OpenStdin" => true,
|
128
|
+
"StdinOnce" => true,
|
129
|
+
"Tty" => true,
|
130
|
+
'PublishAllPorts' => true
|
131
|
+
)
|
132
|
+
|
133
|
+
container.start
|
134
|
+
|
135
|
+
STDIN.raw do |stdin|
|
136
|
+
container.attach(stdin: stdin, tty: true) do |chunk|
|
137
|
+
print chunk
|
138
|
+
end
|
139
|
+
end
|
140
|
+
|
141
|
+
success = (container.json['State']['ExitCode'] == 0) ? true: false
|
108
142
|
@logger.error(output) unless success
|
109
143
|
|
110
144
|
return container, success
|
@@ -0,0 +1,31 @@
|
|
1
|
+
module Minke
|
2
|
+
module Tasks
|
3
|
+
class Shell < Task
|
4
|
+
|
5
|
+
def run args = nil
|
6
|
+
@logger.info "## Run shell"
|
7
|
+
@logger.info "## Run application with docker compose"
|
8
|
+
|
9
|
+
compose_file = @config.compose_file_for(@task_name)
|
10
|
+
compose_file = File.expand_path(compose_file)
|
11
|
+
compose = @docker_compose_factory.create compose_file unless compose_file == nil
|
12
|
+
|
13
|
+
run_with_block do |pre_tasks, post_tasks|
|
14
|
+
begin
|
15
|
+
compose.up
|
16
|
+
pre_tasks.call
|
17
|
+
@logger.info "## Shell open to build container"
|
18
|
+
run_command_in_container('/bin/sh', true)
|
19
|
+
rescue SystemExit, Interrupt
|
20
|
+
@logger.info "Stopping...."
|
21
|
+
raise SystemExit
|
22
|
+
ensure
|
23
|
+
compose.down
|
24
|
+
post_tasks.call
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
data/lib/minke/tasks/task.rb
CHANGED
@@ -63,7 +63,7 @@ module Minke
|
|
63
63
|
|
64
64
|
##
|
65
65
|
# runs the given command in a docker container
|
66
|
-
def run_command_in_container command
|
66
|
+
def run_command_in_container command, blocking = false
|
67
67
|
begin
|
68
68
|
@logger.info "Running command: #{command}"
|
69
69
|
settings = @generator_config.build_settings.docker_settings
|
@@ -85,7 +85,12 @@ module Minke
|
|
85
85
|
:environment => environment,
|
86
86
|
:working_directory => working_directory
|
87
87
|
}
|
88
|
-
|
88
|
+
|
89
|
+
if blocking == false
|
90
|
+
container, success = @docker_runner.create_and_run_container args
|
91
|
+
else
|
92
|
+
container, success = @docker_runner.create_and_run_blocking_container args
|
93
|
+
end
|
89
94
|
|
90
95
|
# throw exception if failed
|
91
96
|
raise "Unable to run command #{command}" unless success
|
data/lib/minke/version.rb
CHANGED
data/lib/minke.rb
CHANGED
@@ -16,6 +16,7 @@ require 'securerandom'
|
|
16
16
|
require 'sshkey'
|
17
17
|
require 'mkmf'
|
18
18
|
require 'open3'
|
19
|
+
require "io/console"
|
19
20
|
|
20
21
|
require 'minke/version'
|
21
22
|
require 'minke/command'
|
@@ -45,6 +46,7 @@ require 'minke/tasks/push'
|
|
45
46
|
require 'minke/tasks/run'
|
46
47
|
require 'minke/tasks/test'
|
47
48
|
require 'minke/tasks/build_image'
|
49
|
+
require 'minke/tasks/shell'
|
48
50
|
|
49
51
|
require 'minke/generators/config'
|
50
52
|
require 'minke/generators/config_processor'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: minke
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.14.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nic Jackson
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-02
|
11
|
+
date: 2017-03-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -279,6 +279,7 @@ files:
|
|
279
279
|
- lib/minke/tasks/fetch.rb
|
280
280
|
- lib/minke/tasks/push.rb
|
281
281
|
- lib/minke/tasks/run.rb
|
282
|
+
- lib/minke/tasks/shell.rb
|
282
283
|
- lib/minke/tasks/task.rb
|
283
284
|
- lib/minke/tasks/task_runner.rb
|
284
285
|
- lib/minke/tasks/test.rb
|