minke 1.0.0 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- ODY0MTRkNGJkNjIzNWVjZWExZGI3YzEzZTg5NWU2NmY1MTNjN2Q3NQ==
4
+ MzBmMDVmMWY5ZTI1ODNlMGFhZWM1MGJhNWViODdhNGI3ZDU3NGY5Yw==
5
5
  data.tar.gz: !binary |-
6
- NjU0M2JjMjMzNDUyNGFlOTg5ODE3ZTE3NzYyM2E5NDhhNDBlOGJjNA==
6
+ NDgxZDY1MTBkZDgyY2ZiNjVkM2I5ODM3MTdlZjExZjc0ODk1OWU1MQ==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- NWY0NjJiZmIxYmI3NGNkMDk3ZDIzNTEwZTc1M2NjNGJjMjA3OTVmNTNhMTlj
10
- YzVmZjFmMTRlNDI5ZGMyYTk1NDY4Yzg4Y2E0ZmQwZTE2Mjk1Njg3ZGY1OWQ2
11
- NDc1N2NmMGI4NzNiNDFlZWQ4YWVjNjMyYmI1OGI5Y2ZjMzBkNjc=
9
+ ODkwMzE5NTU3ODg5YjJhNGUwYWI3NDNiZWNkYWRiNTdmNmIxOWVkY2YxYzll
10
+ NTYzMjE1NWU2ZGYzZDU5Y2M5YzczZTZkM2NjMDdmZjBmYWRjOTA4NDM1YWM5
11
+ NmM3N2NiNzAyOGIyZTQzMGY4YzdiMGVlYjU4YmY5MjdlMDRhM2E=
12
12
  data.tar.gz: !binary |-
13
- MzVhM2U2Njc3OWVjMDc4MTY4ZjJiMDIxNzNhZjcyZGVlNDQzZWZkMGU1MjY5
14
- YWNhZGIxZjg0ZDNjYTk1ZTk1ZmRlN2NmYWI2MzM3Yzc2MTEyMDU0YjI4ODM4
15
- NTAwMDhmZmZkNWE4NzNiOTBjOGU1ZjZkMWVhNmM1ZGE2MGQ5Y2E=
13
+ YzVlMzdhNTQ5Y2YzNjFkY2Y1YTI3MTYwNjllNzIxN2Y0ZTI2MTI0YmI2NjQx
14
+ YTE4ODFhOWIyNmU3ZmNlZjkwMDM0NTUxNGM5ZTg2ZGU3N2FmZTViODI4MTBm
15
+ YjBhMzQ3MjMwMzQxNDIwMjUxYTRiZmQyNzg3ODUyYTdmMDcxYjA=
data/README.md CHANGED
@@ -7,13 +7,19 @@ Version 1 is pretty much a complete rewrite which supports new generator plugins
7
7
 
8
8
  Version 1.0 is not compatible with previous versions of minke however upgrading is not so painful, full instructions will be updated shortly. In the mean time please continue to use the previous stable 0.1.5 [https://github.com/nicholasjackson/minke/tree/0.1.5](https://github.com/nicholasjackson/minke/tree/0.1.5).
9
9
 
10
- **Version 1.0**
11
- [![Build Status](https://travis-ci.org/nicholasjackson/minke.svg?branch=master)](https://travis-ci.org/nicholasjackson/minke)
10
+ **Version 1.0.1**
11
+ [![Build Status](https://travis-ci.org/nicholasjackson/minke.svg?branch=master)](https://travis-ci.org/nicholasjackson/minke)
12
+
13
+ [![Code Climate](https://codeclimate.com/github/nicholasjackson/minke/badges/gpa.svg)](https://codeclimate.com/github/nicholasjackson/minke)
14
+
15
+ [![Test Coverage](https://codeclimate.com/github/nicholasjackson/minke/badges/coverage.svg)](https://codeclimate.com/github/nicholasjackson/minke/coverage)
16
+
17
+ [![Issue Count](https://codeclimate.com/github/nicholasjackson/minke/badges/issue_count.svg)](https://codeclimate.com/github/nicholasjackson/minke)
12
18
 
13
19
  Minke is an opinionated build system for Microservices and Docker, like a little envelope of quality it scaffolds the build, run and test (unit test and functional tests) phases of your microservice project allowing you to simply run and test your images using Docker Compose. Currently supporting Google's Go, and experimental support for Swift, extensions are planned for Node.js or HTML / Javascript sites with Grunt or Gulp based builds.
14
20
 
15
21
  ## Generators
16
- - Go - Go Microservice Template
22
+ - Go - [Go Microservice Template](https://github.com/nicholasjackson/minke-generator-go)
17
23
  - Java - Spring Boot
18
24
  - Swift - Kitura (Coming Soon)
19
25
  - Node - ExpressJS (Coming Soon)
data/bin/minke CHANGED
@@ -36,7 +36,7 @@ variables = Minke::Generators::ConfigVariables.new.tap do |v|
36
36
  v.namespace = options[:namespace]
37
37
  v.src_root = File.expand_path(options[:output]) unless options[:output] == nil
38
38
  end
39
- processor = Minke::Generators::Processor.new variables
39
+ processor = Minke::Generators::Processor.new variables, Minke::Docker::DockerRunner.new
40
40
  processor.load_generators
41
41
 
42
42
 
@@ -48,6 +48,10 @@ module Minke
48
48
  def create_and_run_container image, volumes, environment, working_directory, cmd
49
49
  # update the timeout for the Excon Http Client
50
50
  # set the chunk size to enable streaming of log files
51
+ #puts working_directory
52
+ puts volumes
53
+ #puts environment
54
+
51
55
  ::Docker.options = {:chunk_size => 1, :read_timeout => 3600}
52
56
  container = ::Docker::Container.create(
53
57
  'Image' => image,
@@ -4,8 +4,9 @@ module Minke
4
4
  # Process handles the creation of new projects from a generator template.
5
5
  class Processor
6
6
 
7
- def initialize variables
7
+ def initialize variables, docker_runner
8
8
  @variables = variables
9
+ @docker_runner = docker_runner
9
10
  end
10
11
 
11
12
  def process generator_name, output_folder
@@ -19,43 +20,38 @@ module Minke
19
20
  process_directory generator.template_location, '**/.*', output_folder, @variables.application_name
20
21
 
21
22
  # run generate command if present
22
- if generator.generate_settings != nil && generator.generate_settings.command
23
- build_image unless generator.generate_settings.command.docker_file == nil
24
- fetch_image unless generator.generate_settings.command.docker_image == nil
23
+ puts generator.inspect
24
+ if generator.generate_settings != nil && generator.generate_settings.command != nil
25
+ image = build_image generator.generate_settings.docker_file unless generator.generate_settings.docker_file == nil
26
+ image = fetch_image generator.generate_settings.docker_image unless generator.generate_settings.docker_image == nil
25
27
 
26
- #run_command_in_container
28
+ run_command_in_container image, generator.generate_settings.command unless generator.generate_settings.command == nil
27
29
  end
28
30
  end
29
31
 
30
- def build_image
32
+ def build_image docker_file
31
33
  puts "## Building custom docker image"
32
34
 
33
- image_name = APPLICATION_NAME + "-buildimage"
34
- Docker.options = {:read_timeout => 6200}
35
- image = Docker::Image.build_from_dir generator.generate_command_docker_file, {:t => image}
35
+ image_name = @variables.application_name + "-buildimage"
36
+ puts @docker_runner.build_image docker_file, image_name
36
37
  end
37
38
 
38
- def fetch_image
39
- Minke::Docker.pull_image generator.generate_command_docker_image unless Minke::Docker.find_image generator.generate_command_docker_image
40
- image_name = generator.generate_command_docker_image
39
+ def fetch_image docker_image
40
+ @docker_runner.pull_image docker_image unless @docker_runner.find_image docker_image
41
+ docker_image
41
42
  end
42
43
 
43
- def run_command_in_container
44
+ def run_command_in_container build_image, command
45
+ puts command
44
46
  begin
45
- config = {
46
- :build_config => {
47
- :docker => {
48
- :image => image_name,
49
- :binds => ["#{File.expand_path(options[:output])}:/src"],
50
- :working_directory => "/src"
51
- }
52
- }
53
- }
47
+ container, success = @docker_runner.create_and_run_container build_image, ["#{File.expand_path(@variables.src_root)}:/src"], nil, '/src', command
54
48
 
49
+ # throw exception if failed
50
+ @helper.fatal_error "Unable to run command #{command}" unless success
55
51
  #command = Minke::Helpers.replace_vars_in_section generator.generate_command, '##SERVICE_NAME##', APPLICATION_NAME
56
52
  #container, ret = Minke::Docker.create_and_run_container config, command
57
53
  ensure
58
- # Minke::Docker.delete_container container
54
+ @docker_runner.delete_container container
59
55
  end
60
56
  end
61
57
 
@@ -12,7 +12,7 @@ module Minke
12
12
  Dir.mkdir directory unless Dir.exist? to
13
13
  FileUtils.cp from, to
14
14
  end
15
-
15
+
16
16
  ##
17
17
  # invoke a rake task
18
18
  def invoke_task task
@@ -37,7 +37,7 @@ module Minke
37
37
 
38
38
  ##
39
39
  # waits until a 200 response is received from the given url
40
- def wait_for_HTTPOK url, count, successes = 0
40
+ def wait_for_HTTPOK url, count, successes = 3
41
41
  begin
42
42
  response = RestClient.send("get", url)
43
43
  rescue
@@ -3,36 +3,51 @@ namespace :app do
3
3
  desc "fetch dependent packages"
4
4
  task :fetch => ['config:set_docker_env', 'docker:fetch_images'] do
5
5
  create_dependencies
6
- runner = Minke::Tasks::Fetch.new @config, :fetch, @generator_config, @docker_runner, @docker_compose_factory, @logger, @helper
7
- runner.run
6
+
7
+ if @config.fetch != nil
8
+ runner = Minke::Tasks::Fetch.new @config, :fetch, @generator_config, @docker_runner, @docker_compose_factory, @logger, @helper
9
+ runner.run
10
+ end
8
11
  end
9
12
 
10
13
  desc "build application"
11
14
  task :build => [:fetch] do
12
15
  create_dependencies
13
- runner = Minke::Tasks::Build.new @config, :build, @generator_config, @docker_runner, @docker_compose_factory, @logger, @helper
14
- runner.run
16
+
17
+ if @config.build != nil
18
+ runner = Minke::Tasks::Build.new @config, :build, @generator_config, @docker_runner, @docker_compose_factory, @logger, @helper
19
+ runner.run
20
+ end
15
21
  end
16
22
 
17
23
  desc "run unit tests"
18
24
  task :test => [:build] do
19
25
  create_dependencies
20
- runner = Minke::Tasks::Test.new @config, :test, @generator_config, @docker_runner, @docker_compose_factory, @logger, @helper
21
- runner.run
26
+
27
+ if @config.test != nil
28
+ runner = Minke::Tasks::Test.new @config, :test, @generator_config, @docker_runner, @docker_compose_factory, @logger, @helper
29
+ runner.run
30
+ end
22
31
  end
23
32
 
24
33
  desc "build Docker image for application"
25
34
  task :build_image => [:test] do
26
35
  create_dependencies
27
- runner = Minke::Tasks::BuildImage.new @config, :test, @generator_config, @docker_runner, @docker_compose_factory, @logger, @helper
28
- runner.run
36
+
37
+ if @config.build != nil
38
+ runner = Minke::Tasks::BuildImage.new @config, :build, @generator_config, @docker_runner, @docker_compose_factory, @logger, @helper
39
+ runner.run
40
+ end
29
41
  end
30
42
 
31
43
  desc "run application with Docker Compose"
32
44
  task :run => ['config:set_docker_env'] do
33
45
  create_dependencies
34
- runner = Minke::Tasks::Run.new @config, :run, @generator_config, @docker_runner, @docker_compose_factory, @logger, @helper
35
- runner.run
46
+
47
+ if @config.run != nil
48
+ runner = Minke::Tasks::Run.new @config, :run, @generator_config, @docker_runner, @docker_compose_factory, @logger, @helper
49
+ runner.run
50
+ end
36
51
  end
37
52
 
38
53
  desc "build and run application with Docker Compose"
@@ -41,8 +56,11 @@ namespace :app do
41
56
  desc "run end to end Cucumber tests USAGE: rake app:cucumber[@tag]"
42
57
  task :cucumber, [:feature] => ['config:set_docker_env'] do |t, args|
43
58
  create_dependencies
44
- runner = Minke::Tasks::Cucumber.new @config, :cucumber, @generator_config, @docker_runner, @docker_compose_factory, @logger, @helper
45
- runner.run
59
+
60
+ if @config.cucumber != nil
61
+ runner = Minke::Tasks::Cucumber.new @config, :cucumber, @generator_config, @docker_runner, @docker_compose_factory, @logger, @helper
62
+ runner.run
63
+ end
46
64
  end
47
65
 
48
66
  desc "push built image to Docker registry"
@@ -55,6 +73,7 @@ namespace :app do
55
73
  def create_dependencies
56
74
  @system_runner = Minke::Docker::SystemRunner.new
57
75
  @docker_compose_factory ||= Minke::Docker::DockerComposeFactory.new @system_runner
76
+ @docker_runner ||= Minke::Docker::DockerRunner.new
58
77
 
59
78
  if @config == nil
60
79
  reader = Minke::Config::Reader.new
@@ -65,15 +84,14 @@ namespace :app do
65
84
  variables = Minke::Generators::ConfigVariables.new.tap do |v|
66
85
  v.application_name = @config.application_name
67
86
  v.namespace = @config.namespace
68
- v.src_root = File.expand_path('../', __FILE__)
87
+ v.src_root = File.expand_path('../')
69
88
  end
70
89
 
71
- processor = Minke::Generators::Processor.new variables
90
+ processor = Minke::Generators::Processor.new variables, @docker_runner
72
91
  processor.load_generators
73
92
  @generator_config = processor.get_generator @config.generator_name
74
93
  end
75
94
 
76
- @docker_runner ||= Minke::Docker::DockerRunner.new
77
95
  @logger ||= Logger.new(STDOUT)
78
96
  @helper ||= Minke::Helpers::Helper.new
79
97
  end
@@ -6,7 +6,7 @@ module Minke
6
6
  puts "## Build application"
7
7
  run_with_block do
8
8
  @generator_settings.build_settings.build_commands.build.each do |command|
9
- puts command
9
+ puts command.to_s
10
10
  run_command_in_container command
11
11
  end
12
12
  end
@@ -57,7 +57,7 @@ module Minke
57
57
  end
58
58
 
59
59
  def wait_for_health_check url
60
- @helper.wait_for_HTTPOK build_address(url), 3, 0
60
+ @helper.wait_for_HTTPOK build_address(url), 0, 3
61
61
  end
62
62
 
63
63
  def copy_assets assets
data/lib/minke/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Minke
2
- VERSION = "1.0.0"
2
+ VERSION = "1.0.1"
3
3
  end
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.0.0
4
+ version: 1.0.1
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-05-19 00:00:00.000000000 Z
11
+ date: 2016-05-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler