minke 0.12.0 → 0.13.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
- NGUxM2QwNzc1ZmQ0MzcwYzYyMTk1ZTZlMzk3NWM0MzdkZTg4NDYwNw==
4
+ YTU3ZjAyMWE2ZGJiNzc4YjEyM2UyN2Q5YTE4NmZlYTc2MjhmMGUxYg==
5
5
  data.tar.gz: !binary |-
6
- MGFiM2IwN2IyZTgyNjg4MTdjZTlmNmM1ZDliY2U5ZWYzNDBmOGExZQ==
6
+ NzYwZTE3MjM5ZTI2YzRhYjU0YTczN2E4ZDM4ZDc1Mjk1NTRhY2JlZQ==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- ZDA2ZjYzNTJiNjUzYzJjOTZmNTIyZTkyNDNiMDU0NzhhN2IwNzBmNjg0NDg2
10
- ODBjNjk1YTJlNzVlZjkwOGUwMDc2YzhhODZkYWY5NTg2Nzg5MGVlMWI4ODgy
11
- MmFhMTk0ZjRhMTEzNWZiNzhiMTU0YTc1YjIwMDY4YzRmY2Y4YTc=
9
+ YWE2MzAwMTM2MmM3ZWVhYWNlZGRlZWQzZWNmMDQwMTg5MDcwMjBhNjU5MDM5
10
+ ODBjOGYyZTQ1M2ViMjI0MTUwOWEyMzVjMzQwNDYwOGRiNTY1OTIxNDJkMTk2
11
+ NTEzYWI3NzljZjg5Y2E4MWM1NWJiMjk1YTU5MjE5MTcyOTFjZGQ=
12
12
  data.tar.gz: !binary |-
13
- YzFjMGJhNDkyMDFmNGVkMGE0OWFhMWE2MmFhMGI2MjliZDQyYmUzZDc2ZDk0
14
- ODQ3NDVkZjdmYTQ2ZjI4YTZmODYzNWZlOWJkMGNkZGE4ZDY4OTY5ZDhmNDcy
15
- MzRhMjVjODEwNTc0MzI4NGEyMWI5MzE3MDA2MzhlMzcyOWI2YjE=
13
+ MGNiOTNjYjQ0ZmJiMGEyZGZhNGJjM2RmMzFmYmQ1ZDkxNGZlYTJkMjM4MWNm
14
+ ZTI0NjQwNTNlMjgxNzM4M2JhMjE4YjRmOTgxZGUxYTdiZjAyODExNGZmNzEy
15
+ M2I1MDA2YTQxNDgyY2M2NDg1OWExODRjZjA1NWVlNjc2YWJhNjg=
data/README.md CHANGED
@@ -1,7 +1,12 @@
1
1
  # Minke
2
+
3
+ ## NOTE:
4
+ Version 0.13.0 of the gem introduces breaking changes to the configuration files in order to support multiple language builds for swift and go. Please use version 0.12.0 or upgrade your config to the new specification shown below.
5
+
6
+ **Version 0.13.0**
2
7
  [![Build Status](https://travis-ci.org/nicholasjackson/minke.svg?branch=master)](https://travis-ci.org/nicholasjackson/minke)
3
8
 
4
- 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, extensions are planned for Node.js or HTML / Javascript sites with Grunt or Gulp based builds.
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.
5
10
 
6
11
  ## Installation
7
12
 
@@ -63,9 +68,9 @@ The config file config.yml is where you set the various configuration for the bu
63
68
 
64
69
  ### Example Config File
65
70
  ```yaml
66
- go:
67
- namespace: 'github.com/nicholasjackson'
68
- application_name: 'event-sauce'
71
+ namespace: 'github.com/nicholasjackson'
72
+ application_name: 'event-sauce'
73
+ language: go
69
74
  docker_registry:
70
75
  url: <%= ENV['DOCKER_REGISTRY_URL'] %>
71
76
  user: <%= ENV['DOCKER_REGISTRY_USER'] %>
@@ -73,18 +78,23 @@ docker_registry:
73
78
  email: <%= ENV['DOCKER_REGISTRY_EMAIL'] %>
74
79
  namespace: <%= ENV['DOCKER_NAMESPACE'] %>
75
80
  docker:
76
- docker_file: './'
77
- compose_file: './'
78
- build_args:
79
- image: 'golang:latest'
80
- env:
81
- - 'CGO_ENABLED=0' # used for alpine linux static linking
82
- working_directory: '/go/src/github.com/nicholasjackson/event-sauce'
81
+ docker_file: './dockerfiles/event-sauce/Dockerfile'
82
+ compose_file: './dockercompose/event-sauce/docker-compose.yml'
83
+ after_build:
84
+ copy_assets:
85
+ -
86
+ from: <%= "#{ENV['GOPATH']}/src/github.com/nicholasjackson/event-sauce/event-sauce" %>
87
+ to: './docker/event-sauce'
88
+ -
89
+ from: './swagger_spec/swagger.yml'
90
+ to: './dockerfile/event-sauce/swagger_spec/swagger.yml'
83
91
  run:
84
92
  consul_loader:
85
93
  enabled: true
86
94
  config_file: './config.yml'
87
95
  url: <%= "http://#{ENV['DOCKER_IP']}:9500" %>
96
+ docker:
97
+ compose_file: './dockercompose/event-sauce/docker-compose-alternate.yml'
88
98
  cucumber:
89
99
  consul_loader:
90
100
  enabled: true
@@ -95,20 +105,13 @@ cucumber:
95
105
  url: <%= "http://#{ENV['DOCKER_IP']}:8001/v1/health" %>
96
106
  after_start:
97
107
  - 'wait_for_elastic_search'
98
- after_build:
99
- copy_assets:
100
- -
101
- from: <%= "#{ENV['GOPATH']}/src/github.com/nicholasjackson/event-sauce/event-sauce" %>
102
- to: './docker/event-sauce'
103
- -
104
- from: './swagger_spec/swagger.yml'
105
- to: './dockerfile/event-sauce/swagger_spec/swagger.yml'
106
108
  ```
107
109
 
108
- #### go:
110
+ #### head:
109
111
  This section contains the configuration for the build process.
110
112
  **namespace:** namespace for your application code within your GOPATH, this is generally the same as your repository.
111
113
  **application_name:** name of the built binary.
114
+ **language** (go|swift) language type of the build swift is currently experimental and uses the v3 dev branch which is compatible with Kitura
112
115
 
113
116
  #### docker_registry:
114
117
  This section contains the configuration for the docker registry to push the image to. Images are pushed to the registry prefixed with the namespace and application_name, e.g. nicholasjackson/event-sauce:latest.
@@ -118,16 +121,38 @@ This section contains the configuration for the docker registry to push the imag
118
121
  **email:** email address to use when logging into the registry.
119
122
  **namespace:** namespace of your image to use when pushing the image to the registry.
120
123
 
124
+ #### after_build:
125
+ This section allows you to copy assets such as binaries or files which you would like to include into your Docker image.
126
+ ##### copy_assets:
127
+ An array of elements with the following parameters:
128
+ **from:** the source file or directory
129
+ **to:** the destination file or directory
130
+
121
131
  #### docker:
122
132
  This section contains configuration for the Docker build and run process.
123
133
  **docker_file:** path to the folder containing your Dockerfile used by the build_server task.
124
134
  **compose_file:** path to your docker-compose file for run and cucumber tasks.
125
135
 
126
136
  #### run:
137
+ The run section defines config for running your microservice with Docker Compose.
127
138
  ##### consul_loader:
128
139
  When the application is run using docker-compose you can load some default config into your consul server. Told you this was opinionated, if you are building microservices you are using consul right?
129
140
  **enabled:** boolean determining if this feature is enabled.
130
141
  **config_file:** path to a yaml file containing the key values you would like to load into consul. consul_loader flattens the structure of your yaml file and converts this into key values. For more information please see []()
142
+ ##### docker:
143
+ This section allows you to override the docker compose file specified in the main section incase you would like a different config for testing.
144
+ **compose_file:** path to your docker-compose file for run and cucumber tasks.
145
+ ##### after_start:
146
+ This section is an array of rake tasks which will be run after docker compose has started, you can define these rake tasks in your main Rakefile. e.g.
147
+ - 'wait_for_elastic_search'
148
+ - 'es:create_indexes'
149
+
150
+ #### cucumber:
151
+ The cucumber section defines config for running and testing your microservice with Docker Compose and cucumber, the config options are the same as in **run:** with the addition of health_check.
152
+ ##### health_check:
153
+ After the Docker Compose startup the application can wait until the main application has started before running the cucumber tests, to enable this specify true for the enabled: section then specify your health check url.
154
+ **enabled** (true|false) enable or disable the health check.
155
+ **url** url to use for health checks.
131
156
 
132
157
  ## Development
133
158
 
@@ -11,11 +11,6 @@ docker_registry:
11
11
  docker:
12
12
  docker_file: './'
13
13
  compose_file: './'
14
- build_args:
15
- image: 'golang:latest'
16
- env:
17
- - 'CGO_ENABLED=0' # used for alpine linux static linking
18
- working_directory: '/go/src/github.com/nicholasjackson/event-sauce'
19
14
  run:
20
15
  consul_loader:
21
16
  enabled: true
@@ -0,0 +1,32 @@
1
+ swift:
2
+ application_name: 'event-sauce'
3
+ docker_registry:
4
+ url: <%= ENV['DOCKER_REGISTRY_URL'] %>
5
+ user: <%= ENV['DOCKER_REGISTRY_USER'] %>
6
+ password: <%= ENV['DOCKER_REGISTRY_PASS'] %>
7
+ email: <%= ENV['DOCKER_REGISTRY_EMAIL'] %>
8
+ namespace: <%= ENV['DOCKER_NAMESPACE'] %>
9
+ docker:
10
+ docker_file: './'
11
+ compose_file: './'
12
+ run:
13
+ consul_loader:
14
+ enabled: true
15
+ config_file: './config.yml'
16
+ url: <%= "http://#{ENV['DOCKER_IP']}:9500" %>
17
+ cucumber:
18
+ consul_loader:
19
+ enabled: true
20
+ config_file: './config.yml'
21
+ url: <%= "http://#{ENV['DOCKER_IP']}:9500" %>
22
+ health_check:
23
+ enabled: true
24
+ url: <%= "http://#{ENV['DOCKER_IP']}:8001/v1/health" %>
25
+ after_build:
26
+ copy_assets:
27
+ -
28
+ from: <%= "#{ENV['GOPATH']}/src/github.com/nicholasjackson/event-sauce/event-sauce" %>
29
+ to: './docker/event-sauce'
30
+ -
31
+ from: './swagger_spec/swagger.yml'
32
+ to: './dockerfile/event-sauce/swagger_spec/swagger.yml'
@@ -0,0 +1,27 @@
1
+ module Minke
2
+ module Commands
3
+ class Go
4
+ def commands
5
+ {
6
+ :build => {
7
+ :get => ['go','get','-t','-v','-d','./...'],
8
+ :build => ['go','build','-a','-installsuffix','cgo','-ldflags','\'-s\'','-o', "application"],
9
+ :test => ['go','test','./...']
10
+ },
11
+ :docker => {
12
+ :image => 'golang:latest',
13
+ :env => ['CGO_ENABLED=0'],
14
+ :binds => ["#{ENV['GOPATH']}/src:/go/src"],
15
+ :working_directory => "#{working_directory}"
16
+ }
17
+ }
18
+ end
19
+
20
+ def working_directory
21
+ dir = File.expand_path('../.')
22
+ gopath = "#{ENV['GOPATH']}"
23
+ new_dir = "/go" + dir.gsub(gopath,'')
24
+ end
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,24 @@
1
+ module Minke
2
+ module Commands
3
+ class Swift
4
+ def commands
5
+ {
6
+ :build => {
7
+ :build => ['swift', 'build', '-Xcc', '-fblocks'],
8
+ :test => ['ls', '-ls'],
9
+ },
10
+ :docker => {
11
+ :image => 'ibmcom/kitura-ubuntu:latest',
12
+ :binds => ["#{source_directory}:/src"],
13
+ :working_directory => "/src"
14
+ }
15
+ }
16
+ end
17
+
18
+ def source_directory
19
+ Dir.pwd if File.exists?('Package.swift')
20
+ File.expand_path('../.') if File.exists?('../Package.swift')
21
+ end
22
+ end
23
+ end
24
+ end
@@ -1,5 +1,5 @@
1
1
  module Minke
2
- class GoDocker
2
+ class Docker
3
3
  def self.get_docker_ip_address
4
4
  if !ENV['DOCKER_HOST']
5
5
  return "127.0.0.1"
@@ -15,7 +15,7 @@ module Minke
15
15
 
16
16
  def self.find_image image_name
17
17
  found = nil
18
- Docker::Image.all.each do | image |
18
+ ::Docker::Image.all.each do | image |
19
19
  found = image if image.info["RepoTags"].include? image_name
20
20
  end
21
21
 
@@ -37,7 +37,7 @@ module Minke
37
37
  end
38
38
 
39
39
  def self.find_running_container
40
- containers = Docker::Container.all(:all => true)
40
+ containers = ::Docker::Container.all(:all => true)
41
41
  found = nil
42
42
 
43
43
  containers.each do | container |
@@ -52,9 +52,9 @@ module Minke
52
52
  def self.create_and_start_container args
53
53
  # update the timeout for the Excon Http Client
54
54
  # set the chunk size to enable streaming of log files
55
- Docker.options = {:chunk_size => 1, :read_timeout => 3600}
55
+ ::Docker.options = {:chunk_size => 1, :read_timeout => 3600}
56
56
 
57
- container = Docker::Container.create(
57
+ container = ::Docker::Container.create(
58
58
  'Image' => args['build_args']['image'],
59
59
  'Cmd' => ['/bin/bash'],
60
60
  'Tty' => true,
@@ -69,13 +69,13 @@ module Minke
69
69
  def self.create_and_run_container args, cmd
70
70
  # update the timeout for the Excon Http Client
71
71
  # set the chunk size to enable streaming of log files
72
- Docker.options = {:chunk_size => 1, :read_timeout => 3600}
73
- container = Docker::Container.create(
74
- 'Image' => args['build_args']['image'],
72
+ ::Docker.options = {:chunk_size => 1, :read_timeout => 3600}
73
+ container = ::Docker::Container.create(
74
+ 'Image' => args[:build_config][:docker][:image],
75
75
  'Cmd' => cmd,
76
- "Binds" => ["#{ENV['GOPATH']}/src:/go/src"],
77
- "Env" => args['build_args']['env'],
78
- 'WorkingDir' => args['build_args']['working_directory'])
76
+ "Binds" => args[:build_config][:docker][:binds],
77
+ "Env" => args[:build_config][:docker][:env],
78
+ 'WorkingDir' => args[:build_config][:docker][:working_directory])
79
79
 
80
80
  return_code = 0
81
81
 
data/lib/minke/helpers.rb CHANGED
@@ -27,6 +27,9 @@ module Minke
27
27
 
28
28
  def self.load_config config_file
29
29
  @config = YAML.parse(ERB.new(File.read(config_file)).result).transform
30
+
31
+ @config[:build_config] = Minke::Commands::Go.new.commands unless @config['language'] != 'go'
32
+ @config[:build_config] = Minke::Commands::Swift.new.commands unless @config['language'] != 'swift'
30
33
  end
31
34
 
32
35
  def self.copy_files assets
@@ -3,24 +3,26 @@ namespace :app do
3
3
  task :test => ['config:set_docker_env', 'config:load_config', 'docker:fetch_images'] do
4
4
  config = Minke::Helpers.config
5
5
 
6
- begin
7
- # Get go packages
8
- puts "## Go get"
9
- container, ret = Minke::GoDocker.create_and_run_container config['docker'], ['go','get','-t','-v','-d','./...']
10
- ensure
11
- Minke::GoDocker.delete_container container
12
- end
13
-
14
- puts ""
6
+ if config[:build_config][:build][:get] != nil
7
+ 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]
11
+ ensure
12
+ Minke::Docker.delete_container container
13
+ end
14
+
15
+ puts ""
16
+ end
15
17
 
16
18
  begin
17
19
  # Test application
18
- puts "## Go test"
19
- container, ret = Minke::GoDocker.create_and_run_container config['docker'], ['go','test','./...']
20
+ puts "## Test application"
21
+ container, ret = Minke::Docker.create_and_run_container config, config[:build_config][:build][:test]
20
22
 
21
23
  raise Exception, 'Error running command' unless ret == 0
22
24
  ensure
23
- Minke::GoDocker.delete_container container
25
+ Minke::Docker.delete_container container
24
26
  end
25
27
 
26
28
  puts ""
@@ -34,11 +36,11 @@ namespace :app do
34
36
 
35
37
  begin
36
38
  # Build go server
37
- container, ret = Minke::GoDocker.create_and_run_container config['docker'], ['go','build','-a','-installsuffix','cgo','-ldflags','\'-s\'','-o', config['go']['application_name']]
39
+ container, ret = Minke::Docker.create_and_run_container config, config[:build_config][:build][:build]
38
40
 
39
41
  raise Exception, 'Error running command' unless ret == 0
40
42
  ensure
41
- Minke::GoDocker.delete_container container
43
+ Minke::Docker.delete_container container
42
44
  end
43
45
 
44
46
  puts ""
@@ -60,10 +62,10 @@ namespace :app do
60
62
  task :build_server => [:build, :copy_assets] do
61
63
  config = Minke::Helpers.config
62
64
 
63
- puts "## Building Docker image: #{config['go']['application_name']}"
65
+ puts "## Building Docker image"
64
66
 
65
67
  Docker.options = {:read_timeout => 6200}
66
- image = Docker::Image.build_from_dir config['docker']['docker_file'], {:t => config['go']['application_name']}
68
+ image = Docker::Image.build_from_dir config['docker']['docker_file'], {:t => config['application_name']}
67
69
 
68
70
  puts ""
69
71
  end
@@ -73,7 +75,14 @@ namespace :app do
73
75
  puts "## Run application with docker compose"
74
76
 
75
77
  config = Minke::Helpers.config
76
- compose = Minke::DockerCompose.new config['docker']['compose_file']
78
+
79
+ if config['run']['docker'] != nil && config['run']['docker']['compose_file'] != nil
80
+ config_file = config['run']['docker']['compose_file']
81
+ else
82
+ config_file = config['docker']['compose_file']
83
+ end
84
+
85
+ compose = Minke::DockerCompose.new config_file
77
86
 
78
87
  begin
79
88
  compose.up
@@ -120,13 +129,22 @@ namespace :app do
120
129
 
121
130
  status = 0
122
131
 
123
- compose = Minke::DockerCompose.new config['docker']['compose_file']
132
+ config = Minke::Helpers.config
133
+
134
+ if config['cucumber']['docker'] != nil && config['cucumber']['docker']['compose_file'] != nil
135
+ config_file = config['cucumber']['docker']['compose_file']
136
+ else
137
+ config_file = config['docker']['compose_file']
138
+ end
139
+
140
+ compose = Minke::DockerCompose.new config_file
141
+
124
142
  begin
125
143
  compose.up
126
144
 
127
145
  # do we need to run any tasks after the server starts?
128
- if config['run']['after_start'] != nil
129
- config['run']['after_start'].each do |task|
146
+ if config['cucumber']['after_start'] != nil
147
+ config['cucumber']['after_start'].each do |task|
130
148
  puts "## Running after_start task: #{task}"
131
149
  Rake::Task[task].invoke
132
150
 
@@ -4,7 +4,7 @@ namespace :config do
4
4
  end
5
5
 
6
6
  task :set_docker_env do
7
- DOCKER_IP = Minke::GoDocker.get_docker_ip_address
7
+ DOCKER_IP = Minke::Docker.get_docker_ip_address
8
8
  ENV['DOCKER_IP'] = DOCKER_IP
9
9
  end
10
10
  end
@@ -1,16 +1,20 @@
1
1
  namespace :docker do
2
2
  desc "updates build images for swagger and golang will overwrite existing images"
3
3
  task :update_images do
4
+ config = Minke::Helpers.config
5
+
4
6
  puts "## Updating Docker images"
5
- Minke::GoDocker.pull_image 'golang:latest'
7
+ Minke::Docker.pull_image config[:build_config][:docker][:image]
6
8
 
7
9
  puts ""
8
10
  end
9
11
 
10
12
  desc "pull images for golang from Docker registry if not already downloaded"
11
13
  task :fetch_images do
14
+ config = Minke::Helpers.config
15
+
12
16
  puts "## Pulling Docker images"
13
- Minke::GoDocker.pull_image 'golang' unless Minke::GoDocker.find_image 'golang:latest'
17
+ Minke::Docker.pull_image config[:build_config][:docker][:image] unless Minke::Docker.find_image config[:build_config][:docker][:image]
14
18
 
15
19
  puts ""
16
20
  end
data/lib/minke/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Minke
2
- VERSION = "0.12.0"
2
+ VERSION = "0.13.0"
3
3
  end
data/lib/minke.rb CHANGED
@@ -6,6 +6,9 @@ require 'rake'
6
6
  require "erb"
7
7
 
8
8
  require 'minke/version'
9
- require 'minke/go_docker'
9
+ require 'minke/docker'
10
10
  require 'minke/docker_compose'
11
11
  require 'minke/helpers'
12
+
13
+ require 'minke/commands/go'
14
+ require 'minke/commands/swift'
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.12.0
4
+ version: 0.13.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-02-25 00:00:00.000000000 Z
11
+ date: 2016-03-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -127,10 +127,13 @@ files:
127
127
  - Rakefile
128
128
  - bin/console
129
129
  - bin/setup
130
- - examples/config.yml
130
+ - examples/config_go.yml
131
+ - examples/config_swift.yml
131
132
  - lib/minke.rb
133
+ - lib/minke/commands/go.rb
134
+ - lib/minke/commands/swift.rb
135
+ - lib/minke/docker.rb
132
136
  - lib/minke/docker_compose.rb
133
- - lib/minke/go_docker.rb
134
137
  - lib/minke/helpers.rb
135
138
  - lib/minke/rake/app.rake
136
139
  - lib/minke/rake/config.rake