minke 1.12.9 → 1.13.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -13
- data/.travis.yml +2 -2
- data/README.md +10 -3
- data/bin/minke +106 -1
- data/docker/Gemfile +1 -1
- data/lib/minke/command.rb +124 -0
- data/lib/minke/config/reader.rb +10 -3
- data/lib/minke/docker/consul.rb +10 -7
- data/lib/minke/docker/docker_runner.rb +15 -14
- data/lib/minke/docker/health_check.rb +6 -5
- data/lib/minke/generators/processor.rb +10 -10
- data/lib/minke/generators/register.rb +1 -2
- data/lib/minke/generators/shell_script.rb +1 -1
- data/lib/minke/helpers/error.rb +1 -1
- data/lib/minke/helpers/shell.rb +18 -2
- data/lib/minke/scripts/{minke.sh → minke} +2 -2
- data/lib/minke/tasks/build.rb +3 -2
- data/lib/minke/tasks/build_image.rb +1 -1
- data/lib/minke/tasks/bundle.rb +3 -2
- data/lib/minke/tasks/cucumber.rb +1 -1
- data/lib/minke/tasks/fetch.rb +1 -1
- data/lib/minke/tasks/push.rb +1 -1
- data/lib/minke/tasks/run.rb +2 -2
- data/lib/minke/tasks/task.rb +3 -4
- data/lib/minke/tasks/test.rb +1 -1
- data/lib/minke/version.rb +1 -1
- data/lib/minke.rb +33 -1
- metadata +39 -40
- data/lib/minke/helpers/logger.rb +0 -17
- data/lib/minke/rake/app.rake +0 -124
checksums.yaml
CHANGED
@@ -1,15 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
|
5
|
-
data.tar.gz: !binary |-
|
6
|
-
ZjY5ZmI1OWVjNDVhNjAzN2ZlMzE1MjExYWMwMDQ3ZWUwMGE4NjI3NA==
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: a8a968e0c1571582674fa98f092560407ae4ca50
|
4
|
+
data.tar.gz: 0f81d735278d8c5580b475a916572354504dbf9d
|
7
5
|
SHA512:
|
8
|
-
metadata.gz:
|
9
|
-
|
10
|
-
MmI2MjNiODdkZWJlMmViZmZkMmFjMGQxYmM1NjU3YmJlN2FkODZhZjBiMGMw
|
11
|
-
NGQzMTAxZDVkZjE0MTI4N2IyMDIzMjM4N2MxYzg0NjAxZDljMmQ=
|
12
|
-
data.tar.gz: !binary |-
|
13
|
-
N2RkMTE2M2YyNGNjNDdhYWIwYzI0MjQxZjk0NzljMzM1ZTJjODQzMDZlOTE4
|
14
|
-
ZDVhMmZjN2Q2MzU4MjBjM2NkZWMxNTY2YzViZDk5NDUxNjczMzA1OWE1YTg0
|
15
|
-
MDVlM2EwYTBiZGNhZTk5NWI3NTlkZTEzN2Y3YWI1YTZlNTgxZDk=
|
6
|
+
metadata.gz: 1262da8729c6d2fe0060ebe3f24f737c1d2822fedf4435b1ce5a274b7aeff1627e8a36183ec52abbaecebdff07f1b31733a1614d4552d2c9dafd13655e5fd456
|
7
|
+
data.tar.gz: 2b8d1055d0554c843b015aae2d80209019a388bc17f12cf81c89866cd4dd21580b303c17a4cc274fea2b1f8b208e3bdeafa1ad7e2bb3e3dbaa012556812204af
|
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.13.0;
|
34
|
+
docker push nicholasjackson/minke:1.13.0;
|
35
35
|
curl https://hooks.microbadger.com/images/nicholasjackson/minke/tkpohfdrYPE0B0TL5NzLcOap4k0=;
|
36
36
|
fi
|
data/README.md
CHANGED
@@ -1,10 +1,14 @@
|
|
1
|
-
[![Stories in Ready](https://badge.waffle.io/nicholasjackson/minke.png?label=ready&title=Ready)](https://waffle.io/nicholasjackson/minke)
|
2
1
|
# Minke
|
3
2
|
|
4
|
-
|
3
|
+
| | |
|
4
|
+
|-----|-----|
|
5
|
+
| Stories Ready: | [![Stories in Ready](https://badge.waffle.io/nicholasjackson/minke.png?label=ready&title=Ready)](https://waffle.io/nicholasjackson/minke) |
|
6
|
+
| Test Coverage: | [![Test Coverage](https://codeclimate.com/github/nicholasjackson/minke/badges/coverage.svg)](https://codeclimate.com/github/nicholasjackson/minke/coverage) |
|
7
|
+
| Build Status: | [![Build Status](https://travis-ci.org/nicholasjackson/minke.svg?branch=master)](https://travis-ci.org/nicholasjackson/minke) |
|
8
|
+
| Chat: | [![Join the chat at https://gitter.im/nicholasjackson/minke](https://badges.gitter.im/nicholasjackson/minke.svg)](https://gitter.im/nicholasjackson/minke?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) |
|
5
9
|
|
6
10
|
# Documentation and Tutorial
|
7
|
-
[
|
11
|
+
[https://minke.rocks/index.html](http://minke.rocks/index.html)
|
8
12
|
|
9
13
|
# Quick Start
|
10
14
|
Minke is an opinionated build system for μServices and Docker, it uses generator templates to create working source code, Dockerfiles, and anything else you may need to build and deploy a working microservice.
|
@@ -54,3 +58,6 @@ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERN
|
|
54
58
|
## License
|
55
59
|
|
56
60
|
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
61
|
+
|
62
|
+
|
63
|
+
|
data/bin/minke
CHANGED
@@ -24,7 +24,112 @@ Minke::Generators::Processor.load_generators
|
|
24
24
|
puts ""
|
25
25
|
puts ""
|
26
26
|
|
27
|
-
options = {
|
27
|
+
options = {
|
28
|
+
:config => './config.yml'
|
29
|
+
}
|
30
|
+
|
31
|
+
subtext = <<HELP
|
32
|
+
Commonly used command are:
|
33
|
+
generate : generate a new template
|
34
|
+
fetch : fetch dependent packages
|
35
|
+
build : build template
|
36
|
+
test : run unit tests
|
37
|
+
cucumber : run cucumber tests
|
38
|
+
run : start the application
|
39
|
+
build_image : build a docker image
|
40
|
+
push : push built image to the registry
|
41
|
+
See 'minke COMMAND --help' for more information on a specific command.
|
42
|
+
HELP
|
43
|
+
|
44
|
+
global = OptionParser.new do |opts|
|
45
|
+
opts.banner = "Usage: minke [options] [subcommand [options]]"
|
46
|
+
opts.on("-v", "--[no-]verbose", "Run verbosely") { |v| options[:verbose] = true }
|
47
|
+
opts.separator ""
|
48
|
+
opts.separator subtext
|
49
|
+
end
|
50
|
+
|
51
|
+
subcommands = {
|
52
|
+
'generate' => OptionParser.new do |opts|
|
53
|
+
# ...
|
54
|
+
end,
|
55
|
+
|
56
|
+
'build' => OptionParser.new do |opts|
|
57
|
+
# ...
|
58
|
+
end,
|
59
|
+
|
60
|
+
'test' => OptionParser.new do |opts|
|
61
|
+
opts.banner = "Usage: minke test [options]"
|
62
|
+
|
63
|
+
opts.on("-c", "--config", "Load config file at given path") { |c| options[:config] = c }
|
64
|
+
end
|
65
|
+
}
|
66
|
+
|
67
|
+
global.order!
|
68
|
+
command = ARGV.shift
|
69
|
+
subcommands[command].order!
|
70
|
+
|
71
|
+
def load_config options
|
72
|
+
reader = Minke::Config::Reader.new Minke::Logging.create_logger(options[:verbose])
|
73
|
+
config = reader.read options[:config]
|
74
|
+
variables = Minke::Generators::ConfigVariables.new.tap do |v|
|
75
|
+
v.application_name = config.application_name
|
76
|
+
v.namespace = config.namespace
|
77
|
+
v.src_root = File.expand_path('../')
|
78
|
+
end
|
79
|
+
processor = Minke::Generators::Processor.new variables, nil, Minke::Logging.create_logger(options[:verbose])
|
80
|
+
generator_config = processor.get_generator config.generator_name
|
81
|
+
return config, generator_config
|
82
|
+
end
|
83
|
+
|
84
|
+
config, generator_config = load_config options
|
85
|
+
|
86
|
+
case command
|
87
|
+
when "test"
|
88
|
+
Minke::Command.new(
|
89
|
+
config,
|
90
|
+
generator_config,
|
91
|
+
options[:verbose]
|
92
|
+
).test
|
93
|
+
when "build"
|
94
|
+
Minke::Command.new(
|
95
|
+
config,
|
96
|
+
generator_config,
|
97
|
+
options[:verbose]
|
98
|
+
).build
|
99
|
+
when "fetch"
|
100
|
+
Minke::Command.new(
|
101
|
+
config,
|
102
|
+
generator_config,
|
103
|
+
options[:verbose]
|
104
|
+
).fetch
|
105
|
+
when "cucumber"
|
106
|
+
Minke::Command.new(
|
107
|
+
config,
|
108
|
+
generator_config,
|
109
|
+
options[:verbose]
|
110
|
+
).cucumber
|
111
|
+
when "build_image"
|
112
|
+
Minke::Command.new(
|
113
|
+
config,
|
114
|
+
generator_config,
|
115
|
+
options[:verbose]
|
116
|
+
).build_image
|
117
|
+
when "run"
|
118
|
+
Minke::Command.new(
|
119
|
+
config,
|
120
|
+
generator_config,
|
121
|
+
options[:verbose]
|
122
|
+
).run
|
123
|
+
when "push"
|
124
|
+
Minke::Command.new(
|
125
|
+
config,
|
126
|
+
generator_config,
|
127
|
+
options[:verbose]
|
128
|
+
).run
|
129
|
+
end
|
130
|
+
|
131
|
+
exit 0
|
132
|
+
|
28
133
|
OptionParser.new do |opts|
|
29
134
|
opts.banner = "Usage: minke [options]"
|
30
135
|
|
data/docker/Gemfile
CHANGED
@@ -0,0 +1,124 @@
|
|
1
|
+
module Minke
|
2
|
+
class Command
|
3
|
+
attr_accessor :config, :generator_config, :verbose
|
4
|
+
|
5
|
+
def initialize(config, generator_config, verbose)
|
6
|
+
self.config = config
|
7
|
+
self.generator_config = generator_config
|
8
|
+
self.verbose = verbose
|
9
|
+
end
|
10
|
+
|
11
|
+
# Creates dependencies for minke
|
12
|
+
def create_dependencies task
|
13
|
+
project_name = "minke#{SecureRandom.urlsafe_base64(12)}".downcase.gsub(/[^0-9a-z ]/i, '')
|
14
|
+
network_name = ENV['DOCKER_NETWORK'] ||= "#{project_name}_default"
|
15
|
+
ENV['DOCKER_PROJECT'] = project_name
|
16
|
+
ENV['DOCKER_NETWORK'] = network_name
|
17
|
+
|
18
|
+
logger = Minke::Logging.create_logger(self.verbose)
|
19
|
+
shell = Minke::Helpers::Shell.new(logger)
|
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
|
+
|
27
|
+
task_runner = Minke::Tasks::TaskRunner.new ({
|
28
|
+
:rake_helper => Minke::Helpers::Rake.new,
|
29
|
+
:copy_helper => Minke::Helpers::Copy.new,
|
30
|
+
:service_discovery => Minke::Docker::ServiceDiscovery.new(project_name, Minke::Docker::DockerRunner.new(logger), network_name)
|
31
|
+
})
|
32
|
+
|
33
|
+
consul = Minke::Docker::Consul.new(
|
34
|
+
{
|
35
|
+
:health_check => Minke::Docker::HealthCheck.new(logger),
|
36
|
+
:service_discovery => Minke::Docker::ServiceDiscovery.new( project_name, Minke::Docker::DockerRunner.new(logger, network_name), network_name),
|
37
|
+
:consul_loader => ConsulLoader::Loader.new(ConsulLoader::ConfigParser.new),
|
38
|
+
:docker_runner => Minke::Docker::DockerRunner.new(logger, network_name),
|
39
|
+
:network => network_name,
|
40
|
+
:project_name => project_name,
|
41
|
+
:logger_helper => logger
|
42
|
+
}
|
43
|
+
)
|
44
|
+
|
45
|
+
network = Minke::Docker::Network.new(
|
46
|
+
network_name,
|
47
|
+
shell
|
48
|
+
)
|
49
|
+
|
50
|
+
return {
|
51
|
+
:config => @config,
|
52
|
+
:task_name => task,
|
53
|
+
:docker_runner => Minke::Docker::DockerRunner.new(logger, network_name),
|
54
|
+
:task_runner => task_runner,
|
55
|
+
:error_helper => Minke::Helpers::Error.new,
|
56
|
+
:shell_helper => shell,
|
57
|
+
:logger_helper => logger,
|
58
|
+
:generator_config => generator_config,
|
59
|
+
:docker_compose_factory => Minke::Docker::DockerComposeFactory.new(shell, project_name, network_name),
|
60
|
+
:consul => consul,
|
61
|
+
:docker_network => network,
|
62
|
+
:health_check => Minke::Docker::HealthCheck.new(logger),
|
63
|
+
:service_discovery => Minke::Docker::ServiceDiscovery.new(project_name, Minke::Docker::DockerRunner.new(logger), network_name)
|
64
|
+
}
|
65
|
+
end
|
66
|
+
|
67
|
+
def create_tasks task
|
68
|
+
return {
|
69
|
+
:bundler => Minke::Tasks::Bundle.new(create_dependencies(task)),
|
70
|
+
:fetch => Minke::Tasks::Fetch.new(create_dependencies(task)),
|
71
|
+
:build => Minke::Tasks::Build.new(create_dependencies(task)),
|
72
|
+
:test => Minke::Tasks::Test.new(create_dependencies(task)),
|
73
|
+
:build_image => Minke::Tasks::BuildImage.new(create_dependencies(task)),
|
74
|
+
:cucumber => Minke::Tasks::Cucumber.new(create_dependencies(task)),
|
75
|
+
:push => Minke::Tasks::Push.new(create_dependencies(task))
|
76
|
+
}
|
77
|
+
end
|
78
|
+
|
79
|
+
def fetch
|
80
|
+
if config.fetch != nil
|
81
|
+
tasks = create_tasks :fetch
|
82
|
+
tasks[:bundler].run
|
83
|
+
tasks[:fetch].run
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
def build
|
88
|
+
if config.build != nil
|
89
|
+
fetch
|
90
|
+
tasks = create_tasks :build
|
91
|
+
tasks[:build].run
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
def test
|
96
|
+
if config.test != nil
|
97
|
+
build
|
98
|
+
tasks = create_tasks :test
|
99
|
+
tasks[:test].run
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
103
|
+
def build_image
|
104
|
+
if config.test != nil
|
105
|
+
test
|
106
|
+
tasks = create_tasks :build
|
107
|
+
tasks[:build_image].run
|
108
|
+
end
|
109
|
+
end
|
110
|
+
|
111
|
+
def cucumber
|
112
|
+
if config.cucumber != nil
|
113
|
+
tasks = create_tasks :cucumber
|
114
|
+
tasks[:cucumber].run
|
115
|
+
end
|
116
|
+
end
|
117
|
+
|
118
|
+
def push
|
119
|
+
tasks = create_tasks :push
|
120
|
+
tasks[:push].run
|
121
|
+
end
|
122
|
+
|
123
|
+
end
|
124
|
+
end
|
data/lib/minke/config/reader.rb
CHANGED
@@ -3,6 +3,12 @@ module Minke
|
|
3
3
|
##
|
4
4
|
# Reader reads a yaml based configuration and processes it into a Minke::Config::Config instance
|
5
5
|
class Reader
|
6
|
+
|
7
|
+
def initialize logger
|
8
|
+
@logger = logger
|
9
|
+
end
|
10
|
+
|
11
|
+
|
6
12
|
##
|
7
13
|
# read yaml config file and return Minke::Config::Config instance
|
8
14
|
def read config_file
|
@@ -93,7 +99,7 @@ module Minke
|
|
93
99
|
def read_secure hash
|
94
100
|
key_path = ENV['SSL_KEY_PATH'].to_s == '' ? "#{ENV['HOME']}/.ssh" : ENV['SSL_KEY_PATH']
|
95
101
|
unless Dir.exists? key_path
|
96
|
-
|
102
|
+
@logger.error "Unable to find SSH keys to decrypt secrets, please set environment variable SSL_KEY_PATH or place the keys in ~/.ssh"
|
97
103
|
return
|
98
104
|
end
|
99
105
|
|
@@ -103,9 +109,10 @@ module Minke
|
|
103
109
|
locator = Minke::Encryption::KeyLocator.new key_path
|
104
110
|
key_path = locator.locate_key fingerprint
|
105
111
|
|
106
|
-
|
112
|
+
@logger.debug key_path
|
113
|
+
|
107
114
|
if key_path.to_s.empty?
|
108
|
-
|
115
|
+
@logger.error "Unable to find SSL key matching fingerprint if your SSL keys are not in ~/.ssh you can set the environment variable SSL_KEY_PATH to point to the correct directory.", :error
|
109
116
|
return
|
110
117
|
end
|
111
118
|
|
data/lib/minke/docker/consul.rb
CHANGED
@@ -1,18 +1,20 @@
|
|
1
1
|
module Minke
|
2
2
|
module Docker
|
3
3
|
class Consul
|
4
|
-
def initialize
|
5
|
-
@health_check = health_check
|
6
|
-
@service_discovery = service_discovery
|
7
|
-
@consul_loader = consul_loader
|
8
|
-
@docker_runner = docker_runner
|
9
|
-
@network = network
|
10
|
-
@project_name = project_name
|
4
|
+
def initialize args
|
5
|
+
@health_check = args[:health_check]
|
6
|
+
@service_discovery = args[:service_discovery]
|
7
|
+
@consul_loader = args[:consul_loader]
|
8
|
+
@docker_runner = args[:docker_runner]
|
9
|
+
@network = args[:network]
|
10
|
+
@project_name = args[:project_name]
|
11
|
+
@logger = args[:logger_helper]
|
11
12
|
end
|
12
13
|
|
13
14
|
##
|
14
15
|
# start_and_load_data config
|
15
16
|
def start_and_load_data consul_config
|
17
|
+
@logger.info "Starting Consul"
|
16
18
|
start
|
17
19
|
wait_for_startup consul_config.url
|
18
20
|
load_data consul_config.url, consul_config.config_file
|
@@ -21,6 +23,7 @@ module Minke
|
|
21
23
|
##
|
22
24
|
# stop consul
|
23
25
|
def stop
|
26
|
+
@logger.info "Stopping Consul"
|
24
27
|
@docker_runner.stop_container @container
|
25
28
|
@docker_runner.delete_container @container
|
26
29
|
end
|
@@ -1,8 +1,9 @@
|
|
1
1
|
module Minke
|
2
2
|
module Docker
|
3
3
|
class DockerRunner
|
4
|
-
def initialize network = nil
|
4
|
+
def initialize logger, network = nil
|
5
5
|
@network = network ||= 'bridge'
|
6
|
+
@logger = logger
|
6
7
|
end
|
7
8
|
|
8
9
|
##
|
@@ -43,7 +44,7 @@ module Minke
|
|
43
44
|
##
|
44
45
|
# pull_image pulls a new copy of the given image from the registry
|
45
46
|
def pull_image image_name
|
46
|
-
|
47
|
+
@logger.debug "Pulling Image: #{image_name}"
|
47
48
|
::Docker.options = {:chunk_size => 1, :read_timeout => 3600}
|
48
49
|
::Docker::Image.create('fromImage' => image_name)
|
49
50
|
end
|
@@ -79,19 +80,18 @@ module Minke
|
|
79
80
|
'PublishAllPorts' => true
|
80
81
|
)
|
81
82
|
|
82
|
-
|
83
|
+
output = ''
|
83
84
|
|
84
85
|
unless args[:deamon] == true
|
85
86
|
thread = Thread.new do
|
86
87
|
container.attach(:stream => true, :stdin => nil, :stdout => true, :stderr => true, :logs => false, :tty => false) do
|
87
88
|
|stream, chunk|
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
if stream.to_s == "stderr"
|
92
|
-
success = false
|
89
|
+
if chunk.index('[ERROR]') != nil # deal with hidden characters
|
90
|
+
@logger.error chunk.gsub!(/\[.*\]/,'')
|
93
91
|
else
|
94
|
-
|
92
|
+
output += chunk.gsub!(/\[.*\]/,'') if output == ''
|
93
|
+
output += chunk.gsub!(/\[.*\]/,'').prepend(" ") unless output == ''
|
94
|
+
@logger.debug chunk.gsub!(/\[.*\]/,'')
|
95
95
|
end
|
96
96
|
end
|
97
97
|
end
|
@@ -100,6 +100,9 @@ module Minke
|
|
100
100
|
container.start
|
101
101
|
|
102
102
|
thread.join unless args[:deamon] == true
|
103
|
+
success = (container.json['State']['ExitCode'] == 0) ? true: false
|
104
|
+
|
105
|
+
@logger.error(output) unless success
|
103
106
|
|
104
107
|
return container, success
|
105
108
|
end
|
@@ -107,8 +110,6 @@ module Minke
|
|
107
110
|
##
|
108
111
|
# build_image creates a new image from the given Dockerfile and name
|
109
112
|
def build_image dockerfile_dir, name
|
110
|
-
puts dockerfile_dir
|
111
|
-
puts name
|
112
113
|
::Docker.options = {:read_timeout => 6200}
|
113
114
|
begin
|
114
115
|
::Docker::Image.build_from_dir(dockerfile_dir, {:t => name}) do |v|
|
@@ -117,9 +118,9 @@ module Minke
|
|
117
118
|
$stdout.puts data unless data == nil
|
118
119
|
end
|
119
120
|
rescue => e
|
120
|
-
|
121
|
+
@logger.error e
|
121
122
|
message = /.*{"message":"(.*?)"}/.match(e.to_s)
|
122
|
-
|
123
|
+
@logger.error "Error: #{message[1]}" unless message == nil || message.length < 1
|
123
124
|
end
|
124
125
|
end
|
125
126
|
|
@@ -132,7 +133,7 @@ module Minke
|
|
132
133
|
begin
|
133
134
|
container.delete()
|
134
135
|
rescue => e
|
135
|
-
|
136
|
+
@logger.error "Error: Unable to delete container: #{e}"
|
136
137
|
end
|
137
138
|
end
|
138
139
|
end
|
@@ -4,21 +4,22 @@ module Minke
|
|
4
4
|
# HealthCheck checks health of a running container
|
5
5
|
class HealthCheck
|
6
6
|
|
7
|
-
def initialize count=nil, pause=nil
|
7
|
+
def initialize logger, count=nil, pause=nil
|
8
8
|
@count = count ||= 180
|
9
9
|
@pause = pause ||= 1
|
10
10
|
@successes = 2
|
11
|
+
@logger = logger
|
11
12
|
end
|
12
13
|
|
13
14
|
##
|
14
15
|
# waits until a 200 response is received from the given url
|
15
16
|
def wait_for_HTTPOK url
|
16
|
-
|
17
|
+
@logger.debug "Waiting for server #{url} to start #{@count} attempts left"
|
17
18
|
|
18
19
|
begin
|
19
20
|
response = RestClient.send('get', url)
|
20
21
|
rescue
|
21
|
-
|
22
|
+
@logger.error 'Invalid response from server'
|
22
23
|
end
|
23
24
|
|
24
25
|
check_response response, url
|
@@ -46,13 +47,13 @@ module Minke
|
|
46
47
|
|
47
48
|
def check_success url
|
48
49
|
if @successes > 0
|
49
|
-
|
50
|
+
@logger.debug "Server: #{url} passed health check, #{@successes} checks to go..."
|
50
51
|
|
51
52
|
@successes -= 1
|
52
53
|
sleep @pause
|
53
54
|
wait_for_HTTPOK url
|
54
55
|
else
|
55
|
-
|
56
|
+
@logger.debug "Server: #{url} healthy"
|
56
57
|
end
|
57
58
|
end
|
58
59
|
|
@@ -5,7 +5,6 @@ module Minke
|
|
5
5
|
class Processor
|
6
6
|
|
7
7
|
def self.load_generators
|
8
|
-
puts '# Loading installed generators'
|
9
8
|
Gem::Specification.find_all.each do |spec|
|
10
9
|
if spec.metadata != nil && spec.metadata['entrypoint'] != nil
|
11
10
|
require spec.metadata['entrypoint']
|
@@ -13,7 +12,8 @@ module Minke
|
|
13
12
|
end
|
14
13
|
end
|
15
14
|
|
16
|
-
def initialize variables, docker_runner
|
15
|
+
def initialize variables, docker_runner, logger
|
16
|
+
@logger = logger
|
17
17
|
@variables = variables
|
18
18
|
@docker_runner = docker_runner
|
19
19
|
end
|
@@ -22,8 +22,8 @@ module Minke
|
|
22
22
|
generator = get_generator generator_name
|
23
23
|
|
24
24
|
# process the files
|
25
|
-
|
26
|
-
|
25
|
+
@logger.info '# Modifiying templates'
|
26
|
+
@logger.debug "#{generator.template_location}"
|
27
27
|
|
28
28
|
process_directory generator.template_location, '**/*', output_folder, @variables.application_name
|
29
29
|
process_directory generator.template_location, '**/.*', output_folder, @variables.application_name
|
@@ -37,15 +37,15 @@ module Minke
|
|
37
37
|
end
|
38
38
|
|
39
39
|
# write the shell script
|
40
|
-
Minke::Generators::write_bash_script output_folder + "/_build/minke
|
40
|
+
Minke::Generators::write_bash_script output_folder + "/_build/minke"
|
41
41
|
Minke::Generators::create_rvm_files output_folder + "/_build/", @variables.application_name
|
42
42
|
end
|
43
43
|
|
44
44
|
def build_image docker_file
|
45
|
-
|
45
|
+
@logger.info "## Building custom docker image"
|
46
46
|
|
47
47
|
image_name = @variables.application_name + "-buildimage"
|
48
|
-
|
48
|
+
@docker_runner.build_image docker_file, image_name
|
49
49
|
end
|
50
50
|
|
51
51
|
def fetch_image docker_image
|
@@ -54,12 +54,12 @@ module Minke
|
|
54
54
|
end
|
55
55
|
|
56
56
|
def run_command_in_container build_image, command
|
57
|
-
|
57
|
+
@logger.debug command
|
58
58
|
begin
|
59
59
|
container, success = @docker_runner.create_and_run_container build_image, ["#{File.expand_path(@variables.src_root)}:/src"], nil, '/src', command
|
60
60
|
|
61
61
|
# throw exception if failed
|
62
|
-
@helper.fatal_error "
|
62
|
+
@helper.fatal_error " #{command}" unless success
|
63
63
|
#command = Minke::Helpers.replace_vars_in_section generator.generate_command, '##SERVICE_NAME##', APPLICATION_NAME
|
64
64
|
#container, ret = Minke::Docker.create_and_run_container config, command
|
65
65
|
ensure
|
@@ -69,7 +69,7 @@ module Minke
|
|
69
69
|
|
70
70
|
def process_directory template_location, folder, output_folder, service_name
|
71
71
|
Dir.glob("#{template_location}/#{folder}").each do |file_name|
|
72
|
-
|
72
|
+
@logger.debug "## Processing #{file_name}"
|
73
73
|
process_file template_location, file_name, output_folder, service_name
|
74
74
|
end
|
75
75
|
end
|
data/lib/minke/helpers/error.rb
CHANGED
data/lib/minke/helpers/shell.rb
CHANGED
@@ -1,11 +1,27 @@
|
|
1
1
|
module Minke
|
2
2
|
module Helpers
|
3
3
|
class Shell
|
4
|
+
def initialize logger
|
5
|
+
@logger = logger
|
6
|
+
end
|
7
|
+
|
4
8
|
##
|
5
9
|
# Executes a shell command and returns the return status
|
6
10
|
def execute command
|
7
|
-
|
8
|
-
|
11
|
+
@logger.debug command
|
12
|
+
|
13
|
+
require 'open3'
|
14
|
+
cmd = 'ping www.google.com'
|
15
|
+
Open3.popen3(command) do |stdin, stdout, stderr, wait_thr|
|
16
|
+
while line = stdout.gets
|
17
|
+
@logger.debug line
|
18
|
+
end
|
19
|
+
|
20
|
+
exit_status = wait_thr.value
|
21
|
+
unless exit_status.success?
|
22
|
+
abort "FAILED !!! #{cmd}"
|
23
|
+
end
|
24
|
+
end
|
9
25
|
end
|
10
26
|
|
11
27
|
def execute_and_return command
|
@@ -1,6 +1,6 @@
|
|
1
1
|
#!/bin/bash
|
2
|
-
MINKE_VERSION="1.
|
3
|
-
ERROR="Please specify a command e.g. ./minke
|
2
|
+
MINKE_VERSION="1.13.0"
|
3
|
+
ERROR="Please specify a command e.g. ./minke test"
|
4
4
|
|
5
5
|
DOCKER_SOCK="/var/run/docker.sock:/var/run/docker.sock"
|
6
6
|
NEW_UUID=$(base64 /dev/urandom | tr -d '/+' | head -c 32 | tr '[:upper:]' '[:lower:]')
|
data/lib/minke/tasks/build.rb
CHANGED
@@ -3,11 +3,12 @@ module Minke
|
|
3
3
|
class Build < Task
|
4
4
|
|
5
5
|
def run args = nil
|
6
|
-
|
6
|
+
@logger.info "## Build application"
|
7
|
+
|
7
8
|
if @generator_config.build_settings.build_commands.build != nil
|
8
9
|
run_with_block do
|
9
10
|
@generator_config.build_settings.build_commands.build.each do |command|
|
10
|
-
|
11
|
+
@logger.debug command.to_s
|
11
12
|
run_command_in_container command
|
12
13
|
end
|
13
14
|
end
|
data/lib/minke/tasks/bundle.rb
CHANGED
@@ -4,10 +4,11 @@ module Minke
|
|
4
4
|
|
5
5
|
def initialize args
|
6
6
|
@shell_helper = args[:shell_helper]
|
7
|
+
@logger = args[:logger_helper]
|
7
8
|
end
|
8
9
|
|
9
10
|
def run args = nil
|
10
|
-
|
11
|
+
@logger.info '### Install gems'
|
11
12
|
rvm = "#{ENV['HOME']}/.rvm/scripts/rvm"
|
12
13
|
rvm_root = '/usr/local/rvm/scripts/rvm'
|
13
14
|
|
@@ -16,7 +17,7 @@ module Minke
|
|
16
17
|
|
17
18
|
gemset = @shell_helper.read_file '.ruby-gemset'
|
18
19
|
|
19
|
-
|
20
|
+
@logger.info "Using gemset #{gemset}"
|
20
21
|
|
21
22
|
rvm_command = "source #{rvm} && rvm gemset use #{gemset} --create && " if rvm_installed
|
22
23
|
rvm_command = "source #{rvm_root} && rvm gemset use #{gemset} --create && " if rvm_root_installed
|
data/lib/minke/tasks/cucumber.rb
CHANGED
data/lib/minke/tasks/fetch.rb
CHANGED
data/lib/minke/tasks/push.rb
CHANGED
data/lib/minke/tasks/run.rb
CHANGED
@@ -3,7 +3,7 @@ module Minke
|
|
3
3
|
class Run < Task
|
4
4
|
|
5
5
|
def run args = nil
|
6
|
-
|
6
|
+
@logger.info "## Run application with docker compose"
|
7
7
|
|
8
8
|
compose_file = @config.compose_file_for(@task_name)
|
9
9
|
compose_file = File.expand_path(compose_file)
|
@@ -14,7 +14,7 @@ module Minke
|
|
14
14
|
compose.up
|
15
15
|
compose.logs
|
16
16
|
rescue SystemExit, Interrupt
|
17
|
-
|
17
|
+
@logger.info "Stopping...."
|
18
18
|
raise SystemExit
|
19
19
|
ensure
|
20
20
|
compose.down
|
data/lib/minke/tasks/task.rb
CHANGED
@@ -11,7 +11,7 @@ module Minke
|
|
11
11
|
@task_runner = args[:task_runner]
|
12
12
|
@error_helper = args[:error_helper]
|
13
13
|
@shell_helper = args[:shell_helper]
|
14
|
-
@
|
14
|
+
@logger = args[:logger_helper]
|
15
15
|
@generator_config = args[:generator_config]
|
16
16
|
@docker_compose_factory = args[:docker_compose_factory]
|
17
17
|
@consul = args[:consul]
|
@@ -25,7 +25,6 @@ module Minke
|
|
25
25
|
# run_with_config executes the task steps for the given
|
26
26
|
# - block containing custom actions
|
27
27
|
def run_with_block
|
28
|
-
puts "Starting Consul"
|
29
28
|
begin
|
30
29
|
@docker_network.create
|
31
30
|
@consul.start_and_load_data @task_settings.consul_loader unless @task_settings.consul_loader == nil
|
@@ -35,7 +34,6 @@ module Minke
|
|
35
34
|
|
36
35
|
@task_runner.run_steps(@task_settings.post) unless @task_settings == nil || @task_settings.post == nil
|
37
36
|
ensure
|
38
|
-
puts "Stopping Consul"
|
39
37
|
@consul.stop unless @task_settings.consul_loader == nil
|
40
38
|
@docker_network.remove
|
41
39
|
end
|
@@ -45,6 +43,8 @@ module Minke
|
|
45
43
|
# runs the given command in a docker container
|
46
44
|
def run_command_in_container command
|
47
45
|
begin
|
46
|
+
@logger.info "Running command: #{command}"
|
47
|
+
|
48
48
|
settings = @generator_config.build_settings.docker_settings
|
49
49
|
build_image = create_container_image
|
50
50
|
|
@@ -77,7 +77,6 @@ module Minke
|
|
77
77
|
build_image = "#{@config.application_name}-buildimage"
|
78
78
|
@docker_runner.build_image build_file, build_image
|
79
79
|
else
|
80
|
-
puts build_image
|
81
80
|
@docker_runner.pull_image build_image unless @docker_runner.find_image build_image
|
82
81
|
end
|
83
82
|
|
data/lib/minke/tasks/test.rb
CHANGED
data/lib/minke/version.rb
CHANGED
data/lib/minke.rb
CHANGED
@@ -17,10 +17,10 @@ require 'sshkey'
|
|
17
17
|
require 'mkmf'
|
18
18
|
|
19
19
|
require 'minke/version'
|
20
|
+
require 'minke/command'
|
20
21
|
|
21
22
|
require 'minke/helpers/copy'
|
22
23
|
require 'minke/helpers/error'
|
23
|
-
require 'minke/helpers/logger'
|
24
24
|
require 'minke/helpers/rake'
|
25
25
|
require 'minke/helpers/shell'
|
26
26
|
|
@@ -54,3 +54,35 @@ require 'minke/generators/shell_script'
|
|
54
54
|
|
55
55
|
require 'minke/encryption/encryption'
|
56
56
|
require 'minke/encryption/key_locator'
|
57
|
+
|
58
|
+
module Minke
|
59
|
+
class Logging
|
60
|
+
@@debug = false
|
61
|
+
@@ret = "\n"
|
62
|
+
|
63
|
+
def self.create_logger verbose = false
|
64
|
+
Logger.new(STDOUT).tap do |l|
|
65
|
+
l.datetime_format = ''
|
66
|
+
l.formatter = proc do |severity, datetime, progname, msg|
|
67
|
+
case severity
|
68
|
+
when 'ERROR'
|
69
|
+
s = "#{@@ret if @@debug}#{'ERROR'.colorize(:red)}: #{msg.chomp('')}\n"
|
70
|
+
@@debug = false
|
71
|
+
s
|
72
|
+
when 'INFO'
|
73
|
+
s = "#{@@ret if @@debug}#{'INFO'.colorize(:green)}: #{msg.chomp('')}\n"
|
74
|
+
@@debug = false
|
75
|
+
s
|
76
|
+
when 'DEBUG'
|
77
|
+
if verbose == true
|
78
|
+
"#{'DEBUG'.colorize(:yellow)}: #{msg.chomp('')}\n"
|
79
|
+
else
|
80
|
+
@@debug = true
|
81
|
+
"#{'.'.colorize(:yellow)}"
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
metadata
CHANGED
@@ -1,195 +1,195 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: minke
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.13.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: 2016-08-
|
11
|
+
date: 2016-08-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - ~>
|
17
|
+
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '1.10'
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - ~>
|
24
|
+
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '1.10'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rspec
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- -
|
31
|
+
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: '0'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- -
|
38
|
+
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: guard
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- -
|
45
|
+
- - ">="
|
46
46
|
- !ruby/object:Gem::Version
|
47
47
|
version: '0'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- -
|
52
|
+
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: guard-rspec
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- -
|
59
|
+
- - ">="
|
60
60
|
- !ruby/object:Gem::Version
|
61
61
|
version: '0'
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
|
-
- -
|
66
|
+
- - ">="
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '0'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: webmock
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
|
-
- -
|
73
|
+
- - ">="
|
74
74
|
- !ruby/object:Gem::Version
|
75
75
|
version: '0'
|
76
76
|
type: :development
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
|
-
- -
|
80
|
+
- - ">="
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '0'
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
84
|
name: sshkey
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|
87
|
-
- -
|
87
|
+
- - ">="
|
88
88
|
- !ruby/object:Gem::Version
|
89
89
|
version: '0'
|
90
90
|
type: :runtime
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
|
-
- -
|
94
|
+
- - ">="
|
95
95
|
- !ruby/object:Gem::Version
|
96
96
|
version: '0'
|
97
97
|
- !ruby/object:Gem::Dependency
|
98
98
|
name: colorize
|
99
99
|
requirement: !ruby/object:Gem::Requirement
|
100
100
|
requirements:
|
101
|
-
- -
|
101
|
+
- - ">="
|
102
102
|
- !ruby/object:Gem::Version
|
103
103
|
version: '0'
|
104
104
|
type: :runtime
|
105
105
|
prerelease: false
|
106
106
|
version_requirements: !ruby/object:Gem::Requirement
|
107
107
|
requirements:
|
108
|
-
- -
|
108
|
+
- - ">="
|
109
109
|
- !ruby/object:Gem::Version
|
110
110
|
version: '0'
|
111
111
|
- !ruby/object:Gem::Dependency
|
112
112
|
name: cucumber
|
113
113
|
requirement: !ruby/object:Gem::Requirement
|
114
114
|
requirements:
|
115
|
-
- -
|
115
|
+
- - ">="
|
116
116
|
- !ruby/object:Gem::Version
|
117
117
|
version: '0'
|
118
118
|
type: :runtime
|
119
119
|
prerelease: false
|
120
120
|
version_requirements: !ruby/object:Gem::Requirement
|
121
121
|
requirements:
|
122
|
-
- -
|
122
|
+
- - ">="
|
123
123
|
- !ruby/object:Gem::Version
|
124
124
|
version: '0'
|
125
125
|
- !ruby/object:Gem::Dependency
|
126
126
|
name: rake
|
127
127
|
requirement: !ruby/object:Gem::Requirement
|
128
128
|
requirements:
|
129
|
-
- - ~>
|
129
|
+
- - "~>"
|
130
130
|
- !ruby/object:Gem::Version
|
131
131
|
version: '10.0'
|
132
132
|
type: :runtime
|
133
133
|
prerelease: false
|
134
134
|
version_requirements: !ruby/object:Gem::Requirement
|
135
135
|
requirements:
|
136
|
-
- - ~>
|
136
|
+
- - "~>"
|
137
137
|
- !ruby/object:Gem::Version
|
138
138
|
version: '10.0'
|
139
139
|
- !ruby/object:Gem::Dependency
|
140
140
|
name: docker-api
|
141
141
|
requirement: !ruby/object:Gem::Requirement
|
142
142
|
requirements:
|
143
|
-
- -
|
143
|
+
- - ">="
|
144
144
|
- !ruby/object:Gem::Version
|
145
145
|
version: '0'
|
146
146
|
type: :runtime
|
147
147
|
prerelease: false
|
148
148
|
version_requirements: !ruby/object:Gem::Requirement
|
149
149
|
requirements:
|
150
|
-
- -
|
150
|
+
- - ">="
|
151
151
|
- !ruby/object:Gem::Version
|
152
152
|
version: '0'
|
153
153
|
- !ruby/object:Gem::Dependency
|
154
154
|
name: rest-client
|
155
155
|
requirement: !ruby/object:Gem::Requirement
|
156
156
|
requirements:
|
157
|
-
- - ~>
|
157
|
+
- - "~>"
|
158
158
|
- !ruby/object:Gem::Version
|
159
159
|
version: '1.8'
|
160
160
|
type: :runtime
|
161
161
|
prerelease: false
|
162
162
|
version_requirements: !ruby/object:Gem::Requirement
|
163
163
|
requirements:
|
164
|
-
- - ~>
|
164
|
+
- - "~>"
|
165
165
|
- !ruby/object:Gem::Version
|
166
166
|
version: '1.8'
|
167
167
|
- !ruby/object:Gem::Dependency
|
168
168
|
name: consul_loader
|
169
169
|
requirement: !ruby/object:Gem::Requirement
|
170
170
|
requirements:
|
171
|
-
- - ~>
|
171
|
+
- - "~>"
|
172
172
|
- !ruby/object:Gem::Version
|
173
173
|
version: '1.0'
|
174
174
|
type: :runtime
|
175
175
|
prerelease: false
|
176
176
|
version_requirements: !ruby/object:Gem::Requirement
|
177
177
|
requirements:
|
178
|
-
- - ~>
|
178
|
+
- - "~>"
|
179
179
|
- !ruby/object:Gem::Version
|
180
180
|
version: '1.0'
|
181
181
|
- !ruby/object:Gem::Dependency
|
182
182
|
name: multi_json
|
183
183
|
requirement: !ruby/object:Gem::Requirement
|
184
184
|
requirements:
|
185
|
-
- -
|
185
|
+
- - ">="
|
186
186
|
- !ruby/object:Gem::Version
|
187
187
|
version: '0'
|
188
188
|
type: :runtime
|
189
189
|
prerelease: false
|
190
190
|
version_requirements: !ruby/object:Gem::Requirement
|
191
191
|
requirements:
|
192
|
-
- -
|
192
|
+
- - ">="
|
193
193
|
- !ruby/object:Gem::Version
|
194
194
|
version: '0'
|
195
195
|
description:
|
@@ -200,12 +200,12 @@ executables:
|
|
200
200
|
extensions: []
|
201
201
|
extra_rdoc_files: []
|
202
202
|
files:
|
203
|
-
- .codeclimate.yml
|
204
|
-
- .gitignore
|
205
|
-
- .rspec
|
206
|
-
- .ruby-gemset
|
207
|
-
- .ruby-version
|
208
|
-
- .travis.yml
|
203
|
+
- ".codeclimate.yml"
|
204
|
+
- ".gitignore"
|
205
|
+
- ".rspec"
|
206
|
+
- ".ruby-gemset"
|
207
|
+
- ".ruby-version"
|
208
|
+
- ".travis.yml"
|
209
209
|
- CODE_OF_CONDUCT.md
|
210
210
|
- Gemfile
|
211
211
|
- Guardfile
|
@@ -221,6 +221,7 @@ files:
|
|
221
221
|
- examples/config_go.yml
|
222
222
|
- examples/config_swift.yml
|
223
223
|
- lib/minke.rb
|
224
|
+
- lib/minke/command.rb
|
224
225
|
- lib/minke/config/config.rb
|
225
226
|
- lib/minke/config/reader.rb
|
226
227
|
- lib/minke/docker/consul.rb
|
@@ -239,11 +240,9 @@ files:
|
|
239
240
|
- lib/minke/generators/shell_script.rb
|
240
241
|
- lib/minke/helpers/copy.rb
|
241
242
|
- lib/minke/helpers/error.rb
|
242
|
-
- lib/minke/helpers/logger.rb
|
243
243
|
- lib/minke/helpers/rake.rb
|
244
244
|
- lib/minke/helpers/shell.rb
|
245
|
-
- lib/minke/
|
246
|
-
- lib/minke/scripts/minke.sh
|
245
|
+
- lib/minke/scripts/minke
|
247
246
|
- lib/minke/tasks/build.rb
|
248
247
|
- lib/minke/tasks/build_image.rb
|
249
248
|
- lib/minke/tasks/bundle.rb
|
@@ -266,17 +265,17 @@ require_paths:
|
|
266
265
|
- lib
|
267
266
|
required_ruby_version: !ruby/object:Gem::Requirement
|
268
267
|
requirements:
|
269
|
-
- -
|
268
|
+
- - ">="
|
270
269
|
- !ruby/object:Gem::Version
|
271
270
|
version: '0'
|
272
271
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
273
272
|
requirements:
|
274
|
-
- -
|
273
|
+
- - ">="
|
275
274
|
- !ruby/object:Gem::Version
|
276
275
|
version: '0'
|
277
276
|
requirements: []
|
278
277
|
rubyforge_project:
|
279
|
-
rubygems_version: 2.4.
|
278
|
+
rubygems_version: 2.4.8
|
280
279
|
signing_key:
|
281
280
|
specification_version: 4
|
282
281
|
summary: Minke is a suite of rake tasks for building and testing microservices with
|
data/lib/minke/helpers/logger.rb
DELETED
@@ -1,17 +0,0 @@
|
|
1
|
-
module Minke
|
2
|
-
module Helpers
|
3
|
-
class Logger
|
4
|
-
def log message, level
|
5
|
-
## implement logger implementation
|
6
|
-
case level
|
7
|
-
when :error
|
8
|
-
@logger.error message
|
9
|
-
when :info
|
10
|
-
@logger.info message
|
11
|
-
when :debug
|
12
|
-
@logger.debug message
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
data/lib/minke/rake/app.rake
DELETED
@@ -1,124 +0,0 @@
|
|
1
|
-
require 'minke'
|
2
|
-
|
3
|
-
reader = Minke::Config::Reader.new
|
4
|
-
@config = reader.read './config.yml'
|
5
|
-
|
6
|
-
DOCKER_IP = Minke::Docker::DockerRunner.new(nil).get_docker_ip_address
|
7
|
-
ENV['DOCKER_IP'] = DOCKER_IP
|
8
|
-
|
9
|
-
namespace :app do
|
10
|
-
desc "fetch dependent packages"
|
11
|
-
task :fetch do
|
12
|
-
if @config.fetch != nil
|
13
|
-
puts 'run fetch'
|
14
|
-
runner = Minke::Tasks::Bundle.new({:shell_helper => Minke::Helpers::Shell.new})
|
15
|
-
runner.run
|
16
|
-
|
17
|
-
runner = Minke::Tasks::Fetch.new create_dependencies :fetch
|
18
|
-
runner.run
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
desc "build application"
|
23
|
-
task :build => [:fetch] do
|
24
|
-
if @config.build != nil
|
25
|
-
runner = Minke::Tasks::Build.new create_dependencies :build
|
26
|
-
runner.run
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
desc "run unit tests"
|
31
|
-
task :test => [:build] do
|
32
|
-
if @config.test != nil
|
33
|
-
runner = Minke::Tasks::Test.new create_dependencies :test
|
34
|
-
runner.run
|
35
|
-
end
|
36
|
-
end
|
37
|
-
|
38
|
-
desc "build Docker image for application"
|
39
|
-
task :build_image => [:test] do
|
40
|
-
if @config.build != nil
|
41
|
-
runner = Minke::Tasks::BuildImage.new create_dependencies :build
|
42
|
-
runner.run
|
43
|
-
end
|
44
|
-
end
|
45
|
-
|
46
|
-
desc "run application with Docker Compose"
|
47
|
-
task :run do
|
48
|
-
if @config.run != nil
|
49
|
-
runner = Minke::Tasks::Run.new create_dependencies :run
|
50
|
-
runner.run
|
51
|
-
end
|
52
|
-
end
|
53
|
-
|
54
|
-
desc "build and run application with Docker Compose"
|
55
|
-
task :build_and_run => [:build_image, :run]
|
56
|
-
|
57
|
-
desc "run end to end Cucumber tests USAGE: rake app:cucumber[@tag]"
|
58
|
-
task :cucumber, [:feature] do |t, args|
|
59
|
-
if @config.cucumber != nil
|
60
|
-
runner = Minke::Tasks::Cucumber.new create_dependencies :cucumber
|
61
|
-
runner.run
|
62
|
-
end
|
63
|
-
end
|
64
|
-
|
65
|
-
desc "push built image to Docker registry"
|
66
|
-
task :push do
|
67
|
-
runner = Minke::Tasks::Push.new create_dependencies :push
|
68
|
-
runner.run
|
69
|
-
end
|
70
|
-
|
71
|
-
def create_dependencies task
|
72
|
-
project_name = "minke#{SecureRandom.urlsafe_base64(12)}".downcase.gsub(/[^0-9a-z ]/i, '')
|
73
|
-
network_name = ENV['DOCKER_NETWORK'] ||= "#{project_name}_default"
|
74
|
-
ENV['DOCKER_PROJECT'] = project_name
|
75
|
-
ENV['DOCKER_NETWORK'] = network_name
|
76
|
-
|
77
|
-
variables = Minke::Generators::ConfigVariables.new.tap do |v|
|
78
|
-
v.application_name = @config.application_name
|
79
|
-
v.namespace = @config.namespace
|
80
|
-
v.src_root = File.expand_path('../')
|
81
|
-
end
|
82
|
-
|
83
|
-
Minke::Generators::Processor.load_generators
|
84
|
-
processor = Minke::Generators::Processor.new variables, @docker_runner
|
85
|
-
|
86
|
-
generator_config = processor.get_generator @config.generator_name
|
87
|
-
|
88
|
-
task_runner = Minke::Tasks::TaskRunner.new ({
|
89
|
-
:rake_helper => Minke::Helpers::Rake.new,
|
90
|
-
:copy_helper => Minke::Helpers::Copy.new,
|
91
|
-
:service_discovery => Minke::Docker::ServiceDiscovery.new(project_name, Minke::Docker::DockerRunner.new, network_name)
|
92
|
-
})
|
93
|
-
|
94
|
-
consul = Minke::Docker::Consul.new(
|
95
|
-
Minke::Docker::HealthCheck.new,
|
96
|
-
Minke::Docker::ServiceDiscovery.new( project_name, Minke::Docker::DockerRunner.new(network_name), network_name),
|
97
|
-
ConsulLoader::Loader.new(ConsulLoader::ConfigParser.new),
|
98
|
-
Minke::Docker::DockerRunner.new(network_name),
|
99
|
-
network_name,
|
100
|
-
project_name
|
101
|
-
)
|
102
|
-
|
103
|
-
network = Minke::Docker::Network.new(
|
104
|
-
network_name,
|
105
|
-
Minke::Helpers::Shell.new
|
106
|
-
)
|
107
|
-
|
108
|
-
return {
|
109
|
-
:config => @config,
|
110
|
-
:task_name => task,
|
111
|
-
:docker_runner => Minke::Docker::DockerRunner.new(network_name),
|
112
|
-
:task_runner => task_runner,
|
113
|
-
:error_helper => Minke::Helpers::Error.new,
|
114
|
-
:shell_helper => Minke::Helpers::Shell.new,
|
115
|
-
:logger_helper => Minke::Helpers::Logger.new,
|
116
|
-
:generator_config => generator_config,
|
117
|
-
:docker_compose_factory => Minke::Docker::DockerComposeFactory.new(Minke::Helpers::Shell.new, project_name, network_name),
|
118
|
-
:consul => consul,
|
119
|
-
:docker_network => network,
|
120
|
-
:health_check => Minke::Docker::HealthCheck.new,
|
121
|
-
:service_discovery => Minke::Docker::ServiceDiscovery.new(project_name, Minke::Docker::DockerRunner.new, network_name)
|
122
|
-
}
|
123
|
-
end
|
124
|
-
end
|