minke 0.14.0 → 0.15.0

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
- ZGVkNzVjMzRlODMyYjM5OGRmODZhZTI0NTlmYjVlZGEzYzBjNjk1ZQ==
4
+ OWY2ZDAwNmYxNDYxYWI0ZDlhMzE5NTEzN2JkMWI3NDljMDQ0YjM2NQ==
5
5
  data.tar.gz: !binary |-
6
- NWM5YWE2NTYyYzk2ODg4MjkxOTNiMjE0MzZkOTZmOTc5MzM5YjMzYg==
6
+ NDEzMTg4M2IyMGQxM2VjNDk1ZGU1MmE1ZGNlYmRkNjgyZTQ0MmNlMQ==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- ZTE4YmUwYzE2MjZiYzllNWMzNjJhZTQ5MjZkYmQzMjEwN2U2YWVkNWVkNjdi
10
- NTZjMTRhODkyMjFiYmFiZTkyYmJmOWQ0NzUyZjg5ZTY1NDQ2NTc5MjFmMjE3
11
- ZDcyNGY1N2MxNzRiMGMxYmViODM2OTE1NjU5NjcwMmNmYTY5OGM=
9
+ ZjNmNTZiOTM3ZmQzZGVlZGY2MDEyMDFkYTgxYzUzYmRkYTIwMWRlMGUzM2Y2
10
+ YjQ1YjJjZTZiZmZmYWI1YzA5M2JmYjliMzRmNTFiZTdjYTIxMjE3OWZiN2Mx
11
+ MmFhMmY0ZDc0Y2MwYTM4MTE2YmJiMTAzN2NmMGY2YzI1ZGNlNmI=
12
12
  data.tar.gz: !binary |-
13
- YjI3MmEzOTExZjdmNzg3MGY3MjlkZTVjZGQzYmIxMGVmNTQ1MTVlNDIyZDkx
14
- ZGM2MmMyNDIwZDBhMTUzZWVkZDU5NWU2OTVlNGNmMzZlMDRiYTAxZWRlNDJm
15
- ZDg0M2RkZjVmYjczZTRjODRmODFhNDdmOTYwODhiMzBmOTY4MDU=
13
+ OTRhYTBhOGI2ZDQwOWUyOGU2Y2EwYTU5NjcwMWMzNzJkYWVmOTc3MzY4ZDIx
14
+ ODQ4NDAyMGFhMmY0NjhhNzFmYzBjN2JlMjQyZDIxMWU5MDgzOTMxZTFkYjcz
15
+ ZDlkMGJmMWRkMTBiYjI0NmYxYWY2MzJiNzQyMmVmM2U1ZGYwNTQ=
data/README.md CHANGED
@@ -8,6 +8,14 @@ Version 0.13.0 of the gem introduces breaking changes to the configuration files
8
8
 
9
9
  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.
10
10
 
11
+ ## Supported languages
12
+ - Go
13
+ - Swift
14
+
15
+ ## Languages coming soon
16
+ - Node
17
+ - Java
18
+
11
19
  ## Installation
12
20
 
13
21
  Add this line to your application's Gemfile:
@@ -32,6 +40,12 @@ You need to have docker, docker-machine, and docker-compose installed on your bu
32
40
  eval "$(docker-machine env default)"
33
41
  ```
34
42
 
43
+ ## Not for Docker for Mac Beta users
44
+ If you use docker for mac please set the environment variable, this will auto resolve once Docker for mac exits beta.
45
+ ```
46
+ DOCKER_IP=[your docker vm ip]
47
+ ```
48
+
35
49
  ## Usage
36
50
  Include the rake tasks in your Rakefile
37
51
  ```ruby
@@ -80,6 +94,9 @@ docker_registry:
80
94
  docker:
81
95
  docker_file: './dockerfiles/event-sauce/Dockerfile'
82
96
  compose_file: './dockercompose/event-sauce/docker-compose.yml'
97
+ build:
98
+ image: [optional]
99
+ docker_file: [optional]
83
100
  after_build:
84
101
  copy_assets:
85
102
  -
@@ -131,7 +148,10 @@ An array of elements with the following parameters:
131
148
  #### docker:
132
149
  This section contains configuration for the Docker build and run process.
133
150
  **docker_file:** path to the folder containing your Dockerfile used by the build_server task.
134
- **compose_file:** path to your docker-compose file for run and cucumber tasks.
151
+ **compose_file:** path to your docker-compose file for run and cucumber tasks.
152
+ **build:** This section allows you to override the language default used for building your application code.
153
+ - **image [optional]:** specify a different image from your registry or local machine to use for building the application.
154
+ - **docker_file [optional]:** specify a dockerfile which will be built into an image and then used for building the application.
135
155
 
136
156
  #### run:
137
157
  The run section defines config for running your microservice with Docker Compose.
@@ -4,9 +4,9 @@ module Minke
4
4
  def commands config
5
5
  {
6
6
  :build => {
7
- :get => ['go','get','-t','-v','-d','./...'],
8
- :build => ['go','build','-a','-installsuffix','cgo','-ldflags','\'-s\'','-o', "#{config['application_name']}"],
9
- :test => ['go','test','./...']
7
+ :get => [['go','get','-t','-v','-d','./...']],
8
+ :build => [['go','build','-a','-installsuffix','cgo','-ldflags','\'-s\'','-o', "#{config['application_name']}"]],
9
+ :test => [['go','test','./...']]
10
10
  },
11
11
  :docker => {
12
12
  :image => 'golang:latest',
@@ -4,8 +4,16 @@ module Minke
4
4
  def commands config
5
5
  {
6
6
  :build => {
7
- :build => ['swift', 'build', '-Xcc', '-fblocks'],
8
- :test => ['ls', '-ls'],
7
+ :get => [
8
+ ['swift', 'build', '--fetch'],
9
+ # ['bash','-c', "find /src/Packages/ -type d -name Tests -exec echo {} && rm -rf {} \\;"]
10
+ ['bash','-c', "find /src/Packages/ -type d -name Tests | xargs rm -rf"]
11
+ ],
12
+ :build => [
13
+ ['rm', '-rf', '.build'],
14
+ ['swift', 'build', '-Xcc', '-fblocks']
15
+ ],
16
+ :test => [['swift', 'test']],
9
17
  },
10
18
  :docker => {
11
19
  :image => 'ibmcom/kitura-ubuntu:latest',
data/lib/minke/docker.rb CHANGED
@@ -1,15 +1,17 @@
1
1
  module Minke
2
2
  class Docker
3
3
  def self.get_docker_ip_address
4
- if !ENV['DOCKER_HOST']
5
- return "127.0.0.1"
6
- else
4
+ if ENV['DOCKER_HOST']
7
5
  # dockerhost set
8
6
  host = ENV['DOCKER_HOST'].dup
9
7
  host.gsub!(/tcp:\/\//, '')
10
8
  host.gsub!(/:\d+/,'')
11
9
 
12
10
  return host
11
+ elsif ENV['DOCKER_IP']
12
+ return ENV['DOCKER_IP']
13
+ else
14
+ throw "Please set the environment variable DOCKER_HOST or DOCKER_IP with the ip address of your docker instance."
13
15
  end
14
16
  end
15
17
 
@@ -20,7 +20,7 @@ module Minke
20
20
  end
21
21
 
22
22
  def logs
23
- execute "docker-compose -f #{@compose_file} logs"
23
+ execute "docker-compose -f #{@compose_file} logs -f"
24
24
  end
25
25
 
26
26
  private
data/lib/minke/helpers.rb CHANGED
@@ -7,7 +7,7 @@ module Minke
7
7
 
8
8
  @config = nil
9
9
 
10
- def self.wait_until_server_running server, count
10
+ def self.wait_until_server_running server, count, successes = 0
11
11
  begin
12
12
  response = RestClient.send("get", server)
13
13
  rescue
@@ -22,6 +22,14 @@ module Minke
22
22
  else
23
23
  raise 'Server failed to start'
24
24
  end
25
+ else
26
+ if successes > 0
27
+ puts "Server: #{server} passed health check, #{successes} checks to go..."
28
+ sleep 1
29
+ self.wait_until_server_running server, count + 1, successes - 1
30
+ else
31
+ puts "Server: #{server} healthy"
32
+ end
25
33
  end
26
34
  end
27
35
 
@@ -1,47 +1,88 @@
1
1
  namespace :app do
2
- desc "run unit tests"
3
- task :test => ['config:set_docker_env', 'config:load_config', 'docker:fetch_images'] do
2
+
3
+ desc "get dependent packages"
4
+ task :get => ['config:set_docker_env', 'config:load_config', 'docker:fetch_images'] do
4
5
  config = Minke::Helpers.config
5
6
 
6
7
  if config[:build_config][:build][:get] != nil
8
+ puts "## Get dependent packages"
9
+ config[:build_config][:build][:get].each do |command|
10
+ begin
11
+ container, ret = Minke::Docker.create_and_run_container config, command
12
+ ensure
13
+ Minke::Docker.delete_container container
14
+ end
15
+ end
16
+ puts ""
17
+ end
18
+ end
19
+
20
+ desc "build application"
21
+ task :build => [:get] do
22
+ puts "## Build for Linux"
23
+ config = Minke::Helpers.config
24
+
25
+ # do we need to build a custom build container
26
+ if config['docker']['build'] && config['docker']['build']['docker_file'] != nil
27
+ puts "## Building custom docker image"
28
+
29
+ docker_file = config['docker']['build']['docker_file']
30
+ image_name = config['application_name'] + "-buildimage"
31
+
32
+ Docker.options = {:read_timeout => 6200}
33
+ image = Docker::Image.build_from_dir docker_file, {:t => image_name}
34
+ config[:build_config][:docker][:image] = image_name
35
+ end
36
+
37
+ if config['docker']['build'] && config['docker']['build']['image'] != nil
38
+ config[:build_config][:docker][:image] = config['docker']['build']['image']
39
+ end
40
+
41
+ if config['build'] != nil && config['build']['before'] != nil
42
+ config['build']['before'].each do |task|
43
+ puts "## Running before build task: #{task}"
44
+ Rake::Task[task].invoke
45
+
46
+ puts ""
47
+ end
48
+ end
49
+
50
+ config[:build_config][:build][:build].each do |command|
7
51
  begin
8
- # Get go packages
9
- puts "## Get dependent packages"
10
- container, ret = Minke::Docker.create_and_run_container config, config[:build_config][:build][:get]
52
+ # Build application
53
+ container, ret = Minke::Docker.create_and_run_container config, command
54
+ raise Exception, 'Error running command' unless ret == 0
11
55
  ensure
12
56
  Minke::Docker.delete_container container
13
57
  end
14
-
15
- puts ""
16
58
  end
17
59
 
18
- begin
19
- # Test application
20
- puts "## Test application"
21
- container, ret = Minke::Docker.create_and_run_container config, config[:build_config][:build][:test]
22
-
23
- raise Exception, 'Error running command' unless ret == 0
24
- ensure
25
- Minke::Docker.delete_container container
26
- end
27
-
28
60
  puts ""
29
61
  end
30
62
 
31
- desc "build and test application"
32
- task :build => [:test] do
33
- puts "## Build for Linux"
34
-
63
+ desc "run unit tests"
64
+ task :test => [:build] do
35
65
  config = Minke::Helpers.config
36
66
 
37
- begin
38
- # Build go server
39
- container, ret = Minke::Docker.create_and_run_container config, config[:build_config][:build][:build]
67
+ if config['test'] != nil && config['test']['before'] != nil
68
+ config['test']['before'].each do |task|
69
+ puts "## Running before test task: #{task}"
70
+ Rake::Task[task].invoke
40
71
 
41
- raise Exception, 'Error running command' unless ret == 0
42
- ensure
43
- Minke::Docker.delete_container container
44
- end
72
+ puts ""
73
+ end
74
+ end
75
+
76
+ puts "## Test application"
77
+ config[:build_config][:build][:test].each do |command|
78
+ begin
79
+ # Test application
80
+ container, ret = Minke::Docker.create_and_run_container config, command
81
+ raise Exception, 'Error running command' unless ret == 0
82
+ ensure
83
+ Minke::Docker.delete_container container
84
+ end
85
+ end
45
86
 
46
87
  puts ""
47
88
  end
@@ -59,7 +100,7 @@ namespace :app do
59
100
  end
60
101
 
61
102
  desc "build Docker image for application"
62
- task :build_server => [:build, :copy_assets] do
103
+ task :build_server => [:test, :copy_assets] do
63
104
  config = Minke::Helpers.config
64
105
 
65
106
  puts "## Building Docker image"
@@ -146,8 +187,13 @@ namespace :app do
146
187
  if config['cucumber']['after_start'] != nil
147
188
  config['cucumber']['after_start'].each do |task|
148
189
  puts "## Running after_start task: #{task}"
149
- Rake::Task[task].invoke
150
190
 
191
+ begin
192
+ Rake::Task[task].invoke
193
+ rescue Exception => msg
194
+ puts "Error running rake task: #{msg}"
195
+ raise msg
196
+ end
151
197
  puts ""
152
198
  end
153
199
  end
@@ -159,7 +205,7 @@ namespace :app do
159
205
  end
160
206
 
161
207
  if config['cucumber']['health_check']['enabled']
162
- Minke::Helpers.wait_until_server_running config['cucumber']['health_check']['url'], 0
208
+ Minke::Helpers.wait_until_server_running config['cucumber']['health_check']['url'], 0, 3
163
209
  end
164
210
 
165
211
  sh "cucumber --color -f pretty #{feature}"
data/lib/minke/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Minke
2
- VERSION = "0.14.0"
2
+ VERSION = "0.15.0"
3
3
  end
data/lib/minke.rb CHANGED
@@ -3,7 +3,8 @@ require 'yaml'
3
3
  require 'rest-client'
4
4
  require 'consul_loader'
5
5
  require 'rake'
6
- require "erb"
6
+ require 'erb'
7
+ require 'resolv'
7
8
 
8
9
  require 'minke/version'
9
10
  require 'minke/docker'
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: 0.14.0
4
+ version: 0.15.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nic Jackson
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-03-21 00:00:00.000000000 Z
11
+ date: 2016-04-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler