samus 3.0.3 → 3.0.4

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
  SHA256:
3
- metadata.gz: d4ae50bb62ac1a723440bdeb5b2481190be1c4c937decebdd7bf6d372c3b5373
4
- data.tar.gz: 3c1995481a759d75315aff3498cf92ef2d26e600e0addc833e6ce4b2ee4c1db9
3
+ metadata.gz: d5abc0a8419bc2037a0f18d7473a0156909deb7e0de4d900256b5829592db883
4
+ data.tar.gz: 39895dfb2f089a65ff1e03cc6412011b62254d4a469ca210822a0b8adc5fccf9
5
5
  SHA512:
6
- metadata.gz: c33f66b251e307696f80b26fba7a4decc6c9a9a96c9927dbe7cb51a0e341527f78991d8a8b8bddc0a8716e5095246526366a87ab3cee2cd3084e8d98efb9165c
7
- data.tar.gz: 05b0bd0f94ebb9809521b4eeaac23b7d9d7890667373cabbae7e5779949c8a5c806f103577e2855a4e8976cb0a49bb9d3c433861ca447af72a7013127714dfdb
6
+ metadata.gz: b25b940e53902fa2d3a73f040ec78dcdd94d9d4070e831b77f8ce14c0b7cff9b14e5cfa534739abda9e4ee0158eb9dbafb03f543d8bd6125153e4c343a80882a
7
+ data.tar.gz: aee76adacf89dd1d58741bb16220cc53ce7d83eeb9330151e3e1fd9dced2aa462f03912e86ddd0f6931b8f6fc27dcb6748934a5587bbf800fe9af61345abdd4d
@@ -1,3 +1,16 @@
1
+ # 3.0.4 - April 1st, 2019
2
+
3
+ - Automatically build Dockerfile.samus as tempfile if it is not present in
4
+ the repo when using `Samus::Rake::DockerReleaseTask`. This docker image
5
+ copies all credentials in so it can be run directly without mounts.
6
+ - Add `mount_samus_config` option (defaults to `false`) to `DockerReleaseTask`
7
+ options to allow Docker image to mount the Samus configuration directory
8
+ from the host when publishing the image. To override the config directory,
9
+ specify the `SAMUS_CONFIG_PATH` environment variable to the `publish` task.
10
+ - Add `extra_config` to `DockerReleaseTask` to allow extra files to be
11
+ copied into the `/root` directory of the build image. The value should be
12
+ a hash of src -> dest filenames to copy.
13
+
1
14
  # 3.0.3 - April 1st, 2019
2
15
 
3
16
  - Add `Samus::Rake::ReleaseTask` and `Samus::Rake::DockerReleaseTask` to
@@ -1,7 +1,7 @@
1
1
  require 'rake'
2
2
  require 'rake/tasklib'
3
-
4
- require_relative '../../samus'
3
+ require 'tempfile'
4
+ require 'fileutils'
5
5
 
6
6
  module Samus
7
7
  module Rake
@@ -23,6 +23,7 @@ module Samus
23
23
  class DockerReleaseTask < ::Rake::TaskLib
24
24
  include Helpers
25
25
 
26
+ PREP_DIR = '.samusprep'
26
27
  DEFAULT_DOCKERFILE = "Dockerfile.samus"
27
28
 
28
29
  attr_accessor :dockerfile
@@ -33,17 +34,56 @@ module Samus
33
34
 
34
35
  attr_accessor :git_pull_after_publish
35
36
 
37
+ attr_accessor :mount_samus_config
38
+
39
+ attr_accessor :extra_config
40
+
36
41
  def initialize(namespace = :samus)
37
42
  @namespace = namespace
38
43
  @dockerfile = DEFAULT_DOCKERFILE
39
44
  @delete_image_after_publish = true
40
45
  @git_pull_before_build = true
41
46
  @git_pull_after_publish = true
47
+ @mount_samus_config = false
48
+ @extra_config = {}
49
+
42
50
  yield self if block_given?
51
+
52
+ @config_files = {
53
+ Samus::CONFIG_PATH => '.samus',
54
+ File.expand_path('~/.gitconfig') => '.gitconfig'
55
+ }.merge(extra_config)
56
+
43
57
  define
44
58
  end
45
59
 
46
60
  private
61
+
62
+ def copy_prep
63
+ FileUtils.rm_rf(PREP_DIR)
64
+ FileUtils.mkdir_p(PREP_DIR)
65
+ @config_files.each do |src, dst|
66
+ FileUtils.cp_r(src, File.join(PREP_DIR, dst))
67
+ end
68
+ end
69
+
70
+ def build_or_get_dockerfile
71
+ return dockerfile if File.exist?(dockerfile)
72
+ fname = File.join(PREP_DIR, 'Dockerfile')
73
+ config_copies = @config_files.values.map {|f| "COPY ./#{PREP_DIR}/#{f} /root/#{f}" }
74
+ File.open(fname, 'w') do |f|
75
+ f.puts([
76
+ "FROM lsegal/samus:build",
77
+ "ARG VERSION",
78
+ "ENV VERSION=${VERSION}",
79
+ "COPY . /build",
80
+ config_copies.join("\n"),
81
+ "RUN rm -rf /build/.samusprep",
82
+ "RUN samus build ${VERSION}"
83
+ ].join("\n"))
84
+ end
85
+ fname
86
+ end
47
87
 
48
88
  def define
49
89
  namespace(@namespace) do
@@ -52,14 +92,20 @@ module Samus
52
92
  img = release_image
53
93
  ver = release_version
54
94
  sh "git pull" if git_pull_before_build
55
- sh "docker build . -t #{img} -f #{dockerfile} --build-arg VERSION=#{ver}"
95
+
96
+ begin
97
+ copy_prep
98
+ sh "docker build . -t #{img} -f #{build_or_get_dockerfile} --build-arg VERSION=#{ver}"
99
+ ensure
100
+ FileUtils.rm_rf(PREP_DIR)
101
+ end
56
102
  end
57
103
 
58
104
  desc '[VERSION=X.Y.Z] Publishes a built release using Docker'
59
105
  task :publish do
60
106
  img = release_image
61
- mount = "#{Samus::CONFIG_PATH}:/root/.samus:ro"
62
- sh "docker run -v #{mount} --rm #{img}"
107
+ mount = mount_samus_config ? "-v #{Samus::CONFIG_PATH}:/root/.samus:ro" : ''
108
+ sh "docker run #{mount} --rm #{img}"
63
109
  sh "docker rmi -f #{img}" if delete_image_after_publish
64
110
  sh "git pull" if git_pull_after_publish
65
111
  end
@@ -1,3 +1,3 @@
1
1
  module Samus
2
- VERSION = '3.0.3'.freeze
2
+ VERSION = '3.0.4'.freeze
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: samus
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.3
4
+ version: 3.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Loren Segal
@@ -20,7 +20,6 @@ files:
20
20
  - CHANGELOG.md
21
21
  - Dockerfile
22
22
  - Dockerfile.build
23
- - Dockerfile.samus
24
23
  - LICENSE
25
24
  - README.md
26
25
  - Rakefile
@@ -1,5 +0,0 @@
1
- FROM lsegal/samus:build
2
- ARG VERSION
3
- ENV VERSION=${VERSION}
4
- COPY . /build
5
- RUN samus build ${VERSION}