minke 1.14.5 → 1.15.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e6a7b8b60ccbed410eeb27018feca48de863eb62
4
- data.tar.gz: f7eff0ed28dbddfdd61b8f5ad4e8930c6820bb17
3
+ metadata.gz: e2de397efc3384343df824b01a7700343a6bfe0a
4
+ data.tar.gz: c0cceaca1847f3749b488c53e91b3ca50e99c49d
5
5
  SHA512:
6
- metadata.gz: 4320dc51fffbf2605acd2a775e706d6b818f767e9adac3263f759eac4b23b0f23e7a02a3a6f10b3ef715db728c9854c8fe1fb763ab1e58e681a58c038f7ba156
7
- data.tar.gz: 36e008f6e038ef2f70728d57d436d7f7d660928c63f07754d16a1e385ce6b5c52e38dd9353839a39fe6b0dd21647a34f341da992539d3f1c6487b13b6322a255
6
+ metadata.gz: 8fca8727f5be9e3d9fdc0bcb475b4420bf6a82af9d9c57f872ca13778790d35866934d8152ced0964a479f229cb9c7bf9867a6365f0c14bff49679852b9738fa
7
+ data.tar.gz: 6dfa67110af32328eeadf1c111b146f957f28f83e73d649dfc506675c84607f1184dde9493167fc8da38b778a50a456afd2d242d9d621d3ce96015d7124a6749
@@ -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.14.5;
34
- docker push nicholasjackson/minke:1.14.5;
33
+ docker tag nicholasjackson/minke nicholasjackson/minke:1.15.0;
34
+ docker push nicholasjackson/minke:1.15.0;
35
35
  curl https://hooks.microbadger.com/images/nicholasjackson/minke/tkpohfdrYPE0B0TL5NzLcOap4k0=;
36
36
  fi
data/README.md CHANGED
@@ -24,23 +24,23 @@ $ mkdir ~/myservice
24
24
  $ cd ~/myservice
25
25
  ```
26
26
 
27
- 2. Run the generator command in a docker container. (note the space before -g)
27
+ 2. Run the generator command in a docker container.
28
28
 
29
29
  ```bash
30
- $ curl -L -s get.minke.rocks | bash -s ' -g minke-generator-go -o $(pwd) -n github.com/nicholasjackson -a myservice'
30
+ $ curl -Ls https://get.minke.rocks | bash -s 'generate -g minke-generator-go -o $(pwd) -n github.com/nicholasjackson -a myservice'
31
31
  ```
32
32
 
33
33
  3. Build a Docker image
34
34
 
35
35
  ```bash
36
- $ cd _build
37
- $ ./minke.sh rake app:build_image
36
+ $ cd _minke
37
+ $ ./minke -v build_image
38
38
  ```
39
39
 
40
40
  4. Execute the functional tests
41
41
 
42
42
  ```bash
43
- $ ./minke.sh rake app:cucumber
43
+ $ ./minke -v cucumber
44
44
  ```
45
45
 
46
46
  You now have a working microservice ready to be pushed to a Docker registry and deployed to a server. For more detailed information please see the [tutorial](tutorial.html).
data/bin/minke CHANGED
@@ -40,12 +40,14 @@ Commonly used command are:
40
40
  push : push built image to the registry
41
41
  encrypt : encrypt secrets with a private key
42
42
  shell : start a shell session inside the build container
43
+ provision : run the provisioner using terraform
43
44
  See 'minke COMMAND --help' for more information on a specific command.
44
45
  HELP
45
46
 
46
47
  global = OptionParser.new do |opts|
47
48
  opts.banner = "Usage: minke [options] [subcommand [options]]"
48
49
  opts.on("-v", "--[no-]verbose", "Run verbosely") { |v| options[:verbose] = true }
50
+ opts.on("-m", "-m [FOLDER]", "Mount folder in Minke container, e.g. ssh keys") { }
49
51
  opts.on("-A", "--forward-ssh", "Forward ssh keys to docker") { |v| options[:forward_ssh] = true }
50
52
  opts.separator ""
51
53
  opts.separator subtext
@@ -76,8 +78,16 @@ subcommands = {
76
78
 
77
79
  opts.on('-e', '--encrypt STRING', 'Encrypt a string') { |v| options[:encrypt] = v }
78
80
  opts.on('-k', '--key STRING', 'Private key to use for encryption') { |v| options[:key] = v }
81
+ end,
82
+
83
+ 'provision' => OptionParser.new do |opts|
84
+ opts.banner = "Usage: minke [options] provision [options]"
85
+
86
+ opts.on('-plan', '', 'Run terraform plan') { |v| options[:provision_mode] = 'plan' }
87
+ opts.on('-apply', '', 'Run terraform apply') { |v| options[:provision_mode] = 'apply' }
88
+ opts.on('-destroy', '', 'Run terraform destroy') { |v| options[:provision_mode] = 'destroy' }
79
89
  end
80
- }
90
+ }
81
91
 
82
92
  global.order!
83
93
  command = ARGV.shift
@@ -99,12 +109,13 @@ def load_config config_file, verbose
99
109
  return config, generator_config
100
110
  end
101
111
 
102
- def doCommand(command, verbose, config_file = nil)
112
+ def doCommand(command, verbose, options, config_file = nil)
103
113
  config, generator_config = load_config(config_file, verbose) unless config_file == nil
104
114
  Minke::Command.new(
105
115
  config,
106
116
  generator_config,
107
- verbose
117
+ verbose,
118
+ options
108
119
  ).public_send(command)
109
120
  end
110
121
 
@@ -143,21 +154,23 @@ end
143
154
 
144
155
  case command
145
156
  when "test"
146
- doCommand(:test, options[:verbose], options[:config])
157
+ doCommand(:test, options[:verbose], options, options[:config])
147
158
  when "build"
148
- doCommand(:build, options[:verbose], options[:config])
159
+ doCommand(:build, options[:verbose], options, options[:config])
149
160
  when "fetch"
150
- doCommand(:fetch, options[:verbose], options[:config])
161
+ doCommand(:fetch, options[:verbose], options, options[:config])
151
162
  when "cucumber"
152
- doCommand(:cucumber, options[:verbose], options[:config])
163
+ doCommand(:cucumber, options[:verbose], options, options[:config])
153
164
  when "build_image"
154
- doCommand(:build_image, options[:verbose], options[:config])
165
+ doCommand(:build_image, options[:verbose], options, options[:config])
155
166
  when "run"
156
- doCommand(:run, options[:verbose], options[:config])
167
+ doCommand(:run, options[:verbose], options, options[:config])
157
168
  when "push"
158
- doCommand(:push, options[:verbose], options[:config])
169
+ doCommand(:push, options[:verbose], options, options[:config])
159
170
  when "shell"
160
- doCommand(:shell, options[:verbose], options[:config])
171
+ doCommand(:shell, options[:verbose], options, options[:config])
172
+ when "provision"
173
+ doCommand(:provision, options[:verbose], options, options[:config])
161
174
  when "generate"
162
175
  if options[:generator] == nil || options[:output] == nil || options[:name] == nil || options[:namespace] == nil
163
176
  puts "Please specify options use: minke generate --help for help on command line options"
@@ -1,6 +1,7 @@
1
1
  FROM ruby:2.3.1
2
2
 
3
3
  ENV COMPOSE_VERSION 1.11.1
4
+ ENV TERRAFORM_VERSION 0.9.2
4
5
  ENV PATH /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
5
6
 
6
7
  # Build-time metadata as defined at http://label-schema.org
@@ -16,7 +17,7 @@ ENV PATH /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
16
17
  org.label-schema.vcs-url="https://github.com/nicholasjackson/minke"
17
18
 
18
19
  RUN apt-get update
19
- RUN apt-get -y install procps build-essential openssl libreadline6 libreadline6-dev curl git-core zlib1g zlib1g-dev libssl-dev libyaml-dev libxml2-dev libxslt-dev autoconf libc6-dev ncurses-dev automake libtool bison rubygems ca-certificates apt-transport-https
20
+ RUN apt-get -y install procps build-essential openssl libreadline6 libreadline6-dev curl git-core zlib1g zlib1g-dev libssl-dev libyaml-dev libxml2-dev libxslt-dev autoconf libc6-dev ncurses-dev automake libtool bison rubygems ca-certificates apt-transport-https unzip
20
21
 
21
22
  RUN apt-key adv --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys 58118E89F3A912897C070ADBF76221572C52609D
22
23
 
@@ -29,6 +30,11 @@ RUN curl -o /usr/local/bin/docker-compose -L \
29
30
  "https://github.com/docker/compose/releases/download/${COMPOSE_VERSION}/docker-compose-Linux-x86_64" \
30
31
  && chmod +x /usr/local/bin/docker-compose
31
32
 
33
+ RUN curl -o ./terraform.zip \
34
+ "https://releases.hashicorp.com/terraform/${TERRAFORM_VERSION}/terraform_${TERRAFORM_VERSION}_linux_amd64.zip" \
35
+ && unzip ./terraform.zip \
36
+ && mv ./terraform /usr/local/bin/terraform
37
+
32
38
  COPY Gemfile Gemfile
33
39
  COPY entrypoint.sh /
34
40
  RUN chmod +x /entrypoint.sh
@@ -3,7 +3,7 @@ source 'https://rubygems.org'
3
3
  gem "rake"
4
4
  gem "cucumber"
5
5
 
6
- gem 'minke', "= 1.14.5"
6
+ gem 'minke', "= 1.15.0"
7
7
  gem 'minke-generator-swift', "= 0.4"
8
8
  gem 'minke-generator-netmvc'
9
9
  gem 'minke-generator-go', "= 0.9.3"
@@ -34,6 +34,15 @@ require 'minke/docker/consul'
34
34
  require 'minke/docker/network'
35
35
 
36
36
  require 'minke/config/config'
37
+ require 'minke/config/consul_loader'
38
+ require 'minke/config/copy'
39
+ require 'minke/config/docker_registry_settings'
40
+ require 'minke/config/docker_settings'
41
+ require 'minke/config/task'
42
+ require 'minke/config/task_run_settings'
43
+ require 'minke/config/url'
44
+ require 'minke/config/terraform'
45
+ require 'minke/config/environment_settings'
37
46
  require 'minke/config/reader'
38
47
 
39
48
  require 'minke/tasks/task_runner'
@@ -47,6 +56,7 @@ require 'minke/tasks/run'
47
56
  require 'minke/tasks/test'
48
57
  require 'minke/tasks/build_image'
49
58
  require 'minke/tasks/shell'
59
+ require 'minke/tasks/terraform'
50
60
 
51
61
  require 'minke/generators/config'
52
62
  require 'minke/generators/config_processor'
@@ -1,11 +1,12 @@
1
1
  module Minke
2
2
  class Command
3
- attr_accessor :config, :generator_config, :verbose
3
+ attr_accessor :config, :generator_config, :verbose, :args
4
4
 
5
- def initialize(config, generator_config, verbose)
5
+ def initialize(config, generator_config, verbose, args)
6
6
  self.config = config
7
7
  self.generator_config = generator_config
8
8
  self.verbose = verbose
9
+ self.args = args
9
10
  end
10
11
 
11
12
  # Creates dependencies for minke
@@ -69,7 +70,8 @@ module Minke
69
70
  :build_image => Minke::Tasks::BuildImage.new(dependencies),
70
71
  :cucumber => Minke::Tasks::Cucumber.new(dependencies),
71
72
  :push => Minke::Tasks::Push.new(dependencies),
72
- :shell => Minke::Tasks::Shell.new(dependencies)
73
+ :shell => Minke::Tasks::Shell.new(dependencies),
74
+ :provision => Minke::Tasks::Terraform.new(dependencies)
73
75
  }
74
76
  end
75
77
 
@@ -129,5 +131,12 @@ module Minke
129
131
  tasks[:shell].run
130
132
  end
131
133
  end
134
+
135
+ def provision
136
+ if config.provision != nil
137
+ tasks = create_tasks :provision
138
+ tasks[:provision].run self.args[:provision_mode]
139
+ end
140
+ end
132
141
  end
133
142
  end
@@ -76,6 +76,13 @@ module Minke
76
76
  #
77
77
  # [Optional] if not provided the shell commands will not be executed
78
78
  attr_accessor :shell
79
+
80
+ ##
81
+ # Settings for the build provision phase
82
+ # instance of Minke::Config::Task
83
+ #
84
+ # [Optional] if not provided the provision commands will not be executed
85
+ attr_accessor :provision
79
86
 
80
87
  ##
81
88
  # Returns the docker_compose file for the given section,
@@ -141,200 +148,5 @@ module Minke
141
148
  end
142
149
  end
143
150
 
144
- ##
145
- # DockerRegistrySettings encapsulates the settings related to the docker registry
146
- class DockerRegistrySettings
147
- ##
148
- # url of the docker registry to use.
149
- #
150
- # [Optional]
151
- attr_accessor :url
152
-
153
- ##
154
- # user to use when logging into a docker registry.
155
- #
156
- # [Optional]
157
- attr_accessor :user
158
-
159
- ##
160
- # password to use when logging into a docker registry.
161
- #
162
- # [Optional]
163
- attr_accessor :password
164
-
165
- ##
166
- # email to use when logging into a docker registry.
167
- #
168
- # [Optional]
169
- attr_accessor :email
170
-
171
- ##
172
- # namespace to use when tagging an image for the docker registry.
173
- #
174
- # [Required]
175
- attr_accessor :namespace
176
- end
177
-
178
- ##
179
- # DockerSettings encapsulate the configuration used when running builds using docker.
180
- class DockerSettings
181
- ##
182
- # Docker Image to use when building the application source code.
183
- #
184
- # [Optional]
185
- attr_accessor :build_image
186
-
187
- ##
188
- # Specific docker settings to allow an override of the defaults provided by the template, you may want to use
189
- # this if you require a specific piece of software to be installed on the build container.
190
- #
191
- # [Optional]
192
- attr_accessor :build_docker_file
193
-
194
- ##
195
- # Dockerfile to use when creating the final docker image.
196
- #
197
- # [Required]
198
- attr_accessor :application_docker_file
199
-
200
- ##
201
- # Docker compose file to use when running and executing cucumber tests.
202
- #
203
- # [Required]
204
- attr_accessor :application_compose_file
205
-
206
- ##
207
- # Working directory to use for build root, relative to project root
208
- #
209
- # [Optional]
210
- attr_accessor :working_directory
211
- end
212
-
213
- ##
214
- # Task encapsulates the configuration for the various rake tasks like build, run, etc.
215
- class Task
216
- ##
217
- # consul_loader will specify that the given config file is loaded into Consul.
218
- # instance of Minke::Config::ConsulLoader
219
- #
220
- # [Optional]
221
- attr_accessor :consul_loader
222
-
223
- ##
224
- # health_check is the string representation of a url to check before continuing with the rest of the
225
- # task a successfull 200 response from the endpoint is required to contine.
226
- #
227
- # [Optional]
228
- attr_accessor :health_check
229
-
230
- ##
231
- # pre tasks will run before the main task executes.
232
- # instance of Minke::Config::TaskRunSettings
233
- #
234
- # [Optional]
235
- attr_accessor :pre
236
-
237
- ##
238
- # post tasks will run after the main task executes.
239
- # instance of Minke::Config::TaskRunSettings
240
- #
241
- # [Optional]
242
- attr_accessor :post
243
-
244
- ##
245
- # docker config allows you to override the main docker configuration on a per task basis.
246
- # instance of Minke::Config::TaskRunSettings
247
- #
248
- # [Optional]
249
- attr_accessor :docker
250
-
251
- ##
252
- # ports contains an array of Minke::Config::ContainerAddress which holds the details
253
- # for the address the public and private ports of any containers which will be started by this
254
- # task.
255
- attr_accessor :ports
256
- end
257
-
258
- ##
259
- # TaskRunSettings encapsulates the configuration for the various pre and post sections for each task.
260
- # You can use this section to load config into consul, wait for a health check to complete, copy files
261
- # or execute other tasks defined in your Rakefile.
262
- class TaskRunSettings
263
- ##
264
- # tasks is an array of strings which point to a defined task in your Rakefile.
265
- #
266
- # [Optional]
267
- attr_accessor :tasks
268
-
269
- ##
270
- # copy is an array of Copy instances which will be copied before the task continues.
271
- # instance of Minke::Config::Copy
272
- #
273
- # [Optional]
274
- attr_accessor :copy
275
- end
276
-
277
- ##
278
- # ConsulLoader defines the settings and url to be loaded into a running consul instance.
279
- class ConsulLoader
280
- ##
281
- # config_file points to a yaml file of key values to load into consul.
282
- #
283
- # [Required]
284
- attr_accessor :config_file
285
-
286
- ##
287
- # url is the url to the running consul instance into which the keys and values will be loaded.
288
- #
289
- # [Required]
290
- attr_accessor :url
291
- end
292
-
293
- ##
294
- # Copy defines a source and destination of either a file or directory to be copied during a task.
295
- class Copy
296
- ##
297
- # from is the file or directory to copy from.
298
- #
299
- # [Required]
300
- attr_accessor :from
301
-
302
- ##
303
- # to is the file or directory to copy to.
304
- #
305
- # [Required]
306
- attr_accessor :to
307
- end
308
-
309
- ##
310
- # URL represents a url object which is used for health_check and consul_loader locations
311
- class URL
312
- ##
313
- # address of the server i.e 127.0.0.1 or the docker name consul
314
- attr_accessor :address
315
-
316
- ##
317
- # port which the server is running on
318
- # default 80
319
- attr_accessor :port
320
-
321
- ##
322
- # protocol for the server
323
- # - http [default]
324
- # - https
325
- attr_accessor :protocol
326
-
327
- ##
328
- # path for the server
329
- # default /
330
- attr_accessor :path
331
-
332
- ##
333
- # type of the URL
334
- # - public
335
- # - private used for linked containers
336
- attr_accessor :type
337
- end
338
-
339
151
  end
340
152
  end
@@ -0,0 +1,19 @@
1
+ module Minke
2
+ module Config
3
+ ##
4
+ # ConsulLoader defines the settings and url to be loaded into a running consul instance.
5
+ class ConsulLoader
6
+ ##
7
+ # config_file points to a yaml file of key values to load into consul.
8
+ #
9
+ # [Required]
10
+ attr_accessor :config_file
11
+
12
+ ##
13
+ # url is the url to the running consul instance into which the keys and values will be loaded.
14
+ #
15
+ # [Required]
16
+ attr_accessor :url
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,19 @@
1
+ module Minke
2
+ module Config
3
+ ##
4
+ # Copy defines a source and destination of either a file or directory to be copied during a task.
5
+ class Copy
6
+ ##
7
+ # from is the file or directory to copy from.
8
+ #
9
+ # [Required]
10
+ attr_accessor :from
11
+
12
+ ##
13
+ # to is the file or directory to copy to.
14
+ #
15
+ # [Required]
16
+ attr_accessor :to
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,37 @@
1
+ module Minke
2
+ module Config
3
+ ##
4
+ # DockerRegistrySettings encapsulates the settings related to the docker registry
5
+ class DockerRegistrySettings
6
+ ##
7
+ # url of the docker registry to use.
8
+ #
9
+ # [Optional]
10
+ attr_accessor :url
11
+
12
+ ##
13
+ # user to use when logging into a docker registry.
14
+ #
15
+ # [Optional]
16
+ attr_accessor :user
17
+
18
+ ##
19
+ # password to use when logging into a docker registry.
20
+ #
21
+ # [Optional]
22
+ attr_accessor :password
23
+
24
+ ##
25
+ # email to use when logging into a docker registry.
26
+ #
27
+ # [Optional]
28
+ attr_accessor :email
29
+
30
+ ##
31
+ # namespace to use when tagging an image for the docker registry.
32
+ #
33
+ # [Required]
34
+ attr_accessor :namespace
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,38 @@
1
+ module Minke
2
+ module Config
3
+ ##
4
+ # DockerSettings encapsulate the configuration used when running builds using docker.
5
+ class DockerSettings
6
+ ##
7
+ # Docker Image to use when building the application source code.
8
+ #
9
+ # [Optional]
10
+ attr_accessor :build_image
11
+
12
+ ##
13
+ # Specific docker settings to allow an override of the defaults provided by the template, you may want to use
14
+ # this if you require a specific piece of software to be installed on the build container.
15
+ #
16
+ # [Optional]
17
+ attr_accessor :build_docker_file
18
+
19
+ ##
20
+ # Dockerfile to use when creating the final docker image.
21
+ #
22
+ # [Required]
23
+ attr_accessor :application_docker_file
24
+
25
+ ##
26
+ # Docker compose file to use when running and executing cucumber tests.
27
+ #
28
+ # [Required]
29
+ attr_accessor :application_compose_file
30
+
31
+ ##
32
+ # Working directory to use for build root, relative to project root
33
+ #
34
+ # [Optional]
35
+ attr_accessor :working_directory
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,10 @@
1
+ module Minke
2
+ module Config
3
+ ##
4
+ # EnvironmentSettings is a hash containing the environment variables which
5
+ # will be set to the current shell when the minke task runs.
6
+ class EnvironmentSettings < Hash
7
+
8
+ end
9
+ end
10
+ end
@@ -25,13 +25,13 @@ module Minke
25
25
  config.docker_registry = read_docker_registry file['docker_registry'] unless file['docker_registry'] == nil
26
26
  config.docker = read_docker_section file['docker'] unless file['docker'] == nil
27
27
 
28
- config.fetch = read_task_section file['fetch'], config.docker unless file['fetch'] == nil
29
- config.build = read_task_section file['build'], config.docker unless file['build'] == nil
30
- config.test = read_task_section file['test'], config.docker unless file['test'] == nil
31
- config.run = read_task_section file['run'], config.docker unless file['run'] == nil
32
- config.cucumber = read_task_section file['cucumber'], config.docker unless file['cucumber'] == nil
33
-
34
- config.shell = read_task_section file['shell'], config.docker unless file['shell'] == nil
28
+ config.fetch = read_task_section file['fetch'], config.docker unless file['fetch'] == nil
29
+ config.build = read_task_section file['build'], config.docker unless file['build'] == nil
30
+ config.test = read_task_section file['test'], config.docker unless file['test'] == nil
31
+ config.run = read_task_section file['run'], config.docker unless file['run'] == nil
32
+ config.cucumber = read_task_section file['cucumber'], config.docker unless file['cucumber'] == nil
33
+ config.shell = read_task_section file['shell'], config.docker unless file['shell'] == nil
34
+ config.provision = read_task_section file['provision'], config.docker unless file['provision'] == nil
35
35
 
36
36
  return config
37
37
  end
@@ -58,12 +58,13 @@ module Minke
58
58
 
59
59
  def read_task_section section, docker_config
60
60
  Task.new.tap do |t|
61
- t.consul_loader = read_consul_loader_section section['consul_loader'] unless section['consul_loader'] == nil
62
- t.health_check = read_url section['health_check'] unless section['health_check'] == nil
63
- t.docker = read_docker_section section['docker'] unless section['docker'] == nil
64
- t.pre = read_pre_post_section section['pre'] unless section['pre'] == nil
65
- t.post = read_pre_post_section section['post'] unless section['post'] == nil
66
- t.ports = section['ports'] unless section['ports'] == nil
61
+ t.consul_loader = read_consul_loader_section section['consul_loader'] unless section['consul_loader'] == nil
62
+ t.health_check = read_url section['health_check'] unless section['health_check'] == nil
63
+ t.docker = read_docker_section section['docker'] unless section['docker'] == nil
64
+ t.pre = read_pre_post_section section['pre'] unless section['pre'] == nil
65
+ t.post = read_pre_post_section section['post'] unless section['post'] == nil
66
+ t.ports = section['ports'] unless section['ports'] == nil
67
+ t.terraform = read_terraform_section section['terraform'] unless section['terraform'] == nil
67
68
  end
68
69
  end
69
70
 
@@ -90,6 +91,25 @@ module Minke
90
91
  end
91
92
  end
92
93
 
94
+ def read_terraform_section section
95
+ TerraformSettings.new.tap do |t|
96
+ t.config_dir = section['config_dir']
97
+ t.environment = read_env_vars section['environment'] unless section['environment'] == nil
98
+ end
99
+ end
100
+
101
+ def read_env_vars section
102
+ env = EnvironmentSettings.new
103
+
104
+ section.each do |e|
105
+ e.each do |k,v|
106
+ env[k] = v.is_a?(Hash) ? read_secure(v) : v
107
+ end
108
+ end
109
+
110
+ env
111
+ end
112
+
93
113
  def read_url section
94
114
  URL.new.tap do |url|
95
115
  url.address = section['address']
@@ -0,0 +1,53 @@
1
+ module Minke
2
+ module Config
3
+
4
+ # Task encapsulates the configuration for the various rake tasks like build, run, etc.
5
+ class Task
6
+ ##
7
+ # consul_loader will specify that the given config file is loaded into Consul.
8
+ # instance of Minke::Config::ConsulLoader
9
+ #
10
+ # [Optional]
11
+ attr_accessor :consul_loader
12
+
13
+ ##
14
+ # health_check is the string representation of a url to check before continuing with the rest of the
15
+ # task a successfull 200 response from the endpoint is required to contine.
16
+ #
17
+ # [Optional]
18
+ attr_accessor :health_check
19
+
20
+ ##
21
+ # pre tasks will run before the main task executes.
22
+ # instance of Minke::Config::TaskRunSettings
23
+ #
24
+ # [Optional]
25
+ attr_accessor :pre
26
+
27
+ ##
28
+ # post tasks will run after the main task executes.
29
+ # instance of Minke::Config::TaskRunSettings
30
+ #
31
+ # [Optional]
32
+ attr_accessor :post
33
+
34
+ ##
35
+ # docker config allows you to override the main docker configuration on a per task basis.
36
+ # instance of Minke::Config::TaskRunSettings
37
+ #
38
+ # [Optional]
39
+ attr_accessor :docker
40
+
41
+ ##
42
+ # ports contains an array of Minke::Config::ContainerAddress which holds the details
43
+ # for the address the public and private ports of any containers which will be started by this
44
+ # task.
45
+ attr_accessor :ports
46
+
47
+ ##
48
+ # terraform contains the an instance of Minke::Config::TerraformSettings which
49
+ # contains the details for the terraform provisioning section.
50
+ attr_accessor :terraform
51
+ end
52
+ end
53
+ end
@@ -0,0 +1,22 @@
1
+ module Minke
2
+ module Config
3
+ ##
4
+ # TaskRunSettings encapsulates the configuration for the various pre and post sections for each task.
5
+ # You can use this section to load config into consul, wait for a health check to complete, copy files
6
+ # or execute other tasks defined in your Rakefile.
7
+ class TaskRunSettings
8
+ ##
9
+ # tasks is an array of strings which point to a defined task in your Rakefile.
10
+ #
11
+ # [Optional]
12
+ attr_accessor :tasks
13
+
14
+ ##
15
+ # copy is an array of Copy instances which will be copied before the task continues.
16
+ # instance of Minke::Config::Copy
17
+ #
18
+ # [Optional]
19
+ attr_accessor :copy
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,21 @@
1
+ module Minke
2
+ module Config
3
+
4
+ class TerraformSettings
5
+ ##
6
+ # config_dir is the relative folder containing your terraform config.
7
+ attr_accessor :config_dir
8
+
9
+ ##
10
+ # environment contains the environment variable settings to be used with
11
+ # terraform provisioning, this can include:
12
+ # AWS_ACCESS_KEY_ID
13
+ # AWS_SECRET_ACCESS_KEY
14
+ # AWS_DEFAULT_REGION
15
+ #
16
+ # The secure feature of minke can also be used to encrypt these values
17
+ # with a private key.
18
+ attr_accessor :environment
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,33 @@
1
+ module Minke
2
+ module Config
3
+ ##
4
+ # URL represents a url object which is used for health_check and consul_loader locations
5
+ class URL
6
+ ##
7
+ # address of the server i.e 127.0.0.1 or the docker name consul
8
+ attr_accessor :address
9
+
10
+ ##
11
+ # port which the server is running on
12
+ # default 80
13
+ attr_accessor :port
14
+
15
+ ##
16
+ # protocol for the server
17
+ # - http [default]
18
+ # - https
19
+ attr_accessor :protocol
20
+
21
+ ##
22
+ # path for the server
23
+ # default /
24
+ attr_accessor :path
25
+
26
+ ##
27
+ # type of the URL
28
+ # - public
29
+ # - private used for linked containers
30
+ attr_accessor :type
31
+ end
32
+ end
33
+ end
@@ -1,6 +1,6 @@
1
1
  #!/bin/bash
2
2
 
3
- MINKE_VERSION="1.14.5"
3
+ MINKE_VERSION="1.15.0"
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:]')
@@ -29,6 +29,14 @@ fi
29
29
  # Test if interactive terminal and set the flag
30
30
  [[ -t 1 ]] && IT="-it" || IT=""
31
31
 
32
+ # Do we need to forward an ssh key for encrypt?
33
+ MOUNT_VOLUME=""
34
+ while getopts 'Avm:v' flag; do
35
+ if [[ $flag == "m" ]]; then
36
+ SSH_KEY="-v ${OPTARG}"
37
+ fi
38
+ done
39
+
32
40
  if [[ $1 != \generate* ]]; then
33
41
  # Test if we need to mount any special volumes for paths specified in the Gemfile
34
42
  while read -r line; do
@@ -40,7 +48,7 @@ if [[ $1 != \generate* ]]; then
40
48
 
41
49
  DIR=$(dirname `pwd`)
42
50
 
43
- DOCKER_RUN="docker run ${IT} --rm --net=minke_${NEW_UUID} ${SSH_AUTH} ${GEM_VOLUMES} -v ${DOCKER_SOCK} -v ${DIR}:${DIR} -e BUNDLE_PATH=${PWD}/vendor -e BUNDLE_JOBS=2 -e DOCKER_NETWORK=minke_${NEW_UUID} -w ${DIR}/_minke ${DOCKER_IMAGE} ${COMMAND}"
51
+ DOCKER_RUN="docker run ${IT} --rm --net=minke_${NEW_UUID} ${SSH_AUTH} ${GEM_VOLUMES} ${SSH_KEY} -v ${DOCKER_SOCK} -v ${DIR}:${DIR} -e BUNDLE_PATH=${PWD}/vendor -e BUNDLE_JOBS=2 -e DOCKER_NETWORK=minke_${NEW_UUID} -w ${DIR}/_minke ${DOCKER_IMAGE} ${COMMAND}"
44
52
 
45
53
  echo "Running command: minke ${COMMAND}"
46
54
  id=$(docker network create minke_${NEW_UUID})
@@ -17,7 +17,7 @@ module Minke
17
17
  @docker_network = args[:docker_network]
18
18
  @health_check = args[:health_check]
19
19
  @service_discovery = args[:service_discovery]
20
- @task_settings = @config.send(@task_name)
20
+ @task_settings = @config.send(@task_name) unless @task_name == :push
21
21
  end
22
22
 
23
23
  ##
@@ -0,0 +1,23 @@
1
+ module Minke
2
+ module Tasks
3
+ class Terraform < Task
4
+
5
+ def run args
6
+ @logger.info "## Provision application " + args
7
+
8
+ if @task_settings.terraform.environment != nil
9
+ @logger.info "### Setting environment variables "
10
+ @task_settings.terraform.environment.each do |e|
11
+ ENV[e[0]] = e[1]
12
+ end
13
+ end
14
+
15
+ Dir.chdir @task_settings.terraform.config_dir do
16
+ @shell_helper.execute "echo yes | terraform #{args}", true
17
+ end
18
+ end
19
+
20
+ end
21
+ end
22
+ end
23
+
@@ -1,3 +1,3 @@
1
1
  module Minke
2
- VERSION = "1.14.5"
2
+ VERSION = "1.15.0"
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.14.5
4
+ version: 1.15.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-03-06 00:00:00.000000000 Z
11
+ date: 2017-03-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -252,7 +252,16 @@ files:
252
252
  - lib/minke.rb
253
253
  - lib/minke/command.rb
254
254
  - lib/minke/config/config.rb
255
+ - lib/minke/config/consul_loader.rb
256
+ - lib/minke/config/copy.rb
257
+ - lib/minke/config/docker_registry_settings.rb
258
+ - lib/minke/config/docker_settings.rb
259
+ - lib/minke/config/environment_settings.rb
255
260
  - lib/minke/config/reader.rb
261
+ - lib/minke/config/task.rb
262
+ - lib/minke/config/task_run_settings.rb
263
+ - lib/minke/config/terraform.rb
264
+ - lib/minke/config/url.rb
256
265
  - lib/minke/docker/consul.rb
257
266
  - lib/minke/docker/docker_compose.rb
258
267
  - lib/minke/docker/docker_runner.rb
@@ -282,6 +291,7 @@ files:
282
291
  - lib/minke/tasks/shell.rb
283
292
  - lib/minke/tasks/task.rb
284
293
  - lib/minke/tasks/task_runner.rb
294
+ - lib/minke/tasks/terraform.rb
285
295
  - lib/minke/tasks/test.rb
286
296
  - lib/minke/version.rb
287
297
  - minke.gemspec