minimal_pipeline 0.3.2 → 0.3.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/minimal_pipeline/docker.rb +36 -18
  3. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e633583b5092b2ea1fa64e202847265cb5110dd3d646abeb5db934160b821e53
4
- data.tar.gz: c2e374fe91ca7278785021625214dfd8c8d32c054a122db6e61b1f9fa0fdf3cb
3
+ metadata.gz: 1d80cfbd6763abb55d2d5575870ac30fda0283e1a51b547cad5faf5e441b844b
4
+ data.tar.gz: 0b690eb4b534578da250202355188094d45bce9b1a17af499d7739243e4ec66c
5
5
  SHA512:
6
- metadata.gz: 160f3a17a3cb7dac487ca574eb7731a3d357fa1c53b26ad22d7632a82314c183f74a2d3d44ba2e27cfee901a86f67d258fbdb7022004eb4e78db184ea75f2e89
7
- data.tar.gz: 13fdaf4fb6e1d40a26539bbb1981938a2627cae2595d3c3dad6df2d777262ab2b0da2ea750b424f4ff89349e68b7d79974ea2918386d775db460b17d2ad287ef
6
+ metadata.gz: 6c40c2211306a3d611b23075ca2609e73313a2d391e4b615f51fde5b591e873a9e116404249ba94295d1fadda96ef6a3bfb8c16c56c71203fecb1ff9f79ddc92
7
+ data.tar.gz: 985225eded867f85241e9a9c7bc60ce48f4e0ef38542a977f051f46ac755ce8642252774bd8176affeb02094bd48ef08f4dd4cfd54e7b7582ad675a4b21acef6
@@ -66,26 +66,24 @@ class MinimalPipeline
66
66
  # @param dockerfile [String] The path to Dockerfile
67
67
  # @param build_args [Hash] Additional build args to pass to Docker
68
68
  # @param timeout [Integer] The Docker build timeout
69
+ # @param options Additional options to pass to docker API
70
+ #
71
+ # For a full list of options, see https://docs.docker.com/engine/api/v1.37/#operation/ImageBuild
72
+ #
73
+ # rubocop:disable Metrics/ParameterLists
69
74
  def build_docker_image(image_id, build_context: '.',
70
- dockerfile: 'Dockerfile',
71
- build_args: {},
72
- timeout: 600)
73
- %w[HTTP_PROXY HTTPS_PROXY NO_PROXY http_proxy https_proxy
74
- no_proxy].each do |arg|
75
- build_args[arg] = ENV[arg] if ENV[arg]
76
- end
75
+ dockerfile: 'Dockerfile', build_args: {},
76
+ timeout: 600, **options)
77
+
78
+ build_args_json = generate_build_args_json(build_args)
79
+
80
+ args = populate_args_hash(image_id, build_args_json, dockerfile)
81
+ options.each { |key, value| args[key] = value }
77
82
 
78
- args = populate_args_hash(image_id, dockerfile, build_args)
79
83
  puts "Build args: #{args.inspect}" if ENV['DEBUG']
80
- ::Docker.options = {
81
- timeout: timeout,
82
- read_timeout: timeout,
83
- write_timeout: timeout
84
- }
85
- ::Docker::Image.build_from_dir(build_context, args) do |value|
86
- build_output(value)
87
- end
84
+ build_image(build_context, args, timeout)
88
85
  end
86
+ # rubocop:enable Metrics/ParameterLists
89
87
 
90
88
  # Pushes a docker image from local to AWS ECR.
91
89
  # This handles login, the upload, and local cleanup of the container
@@ -102,14 +100,34 @@ class MinimalPipeline
102
100
 
103
101
  private
104
102
 
105
- def populate_args_hash(image_id, dockerfile, build_args)
103
+ def generate_build_args_json(build_args)
104
+ %w[HTTP_PROXY HTTPS_PROXY NO_PROXY http_proxy https_proxy
105
+ no_proxy].each do |arg|
106
+ build_args[arg] = ENV[arg] if ENV[arg]
107
+ end
108
+
109
+ JSON.dump(build_args)
110
+ end
111
+
112
+ def populate_args_hash(image_id, build_args_json, dockerfile)
106
113
  {
107
114
  'nocache' => 'true',
108
115
  'pull' => 'true',
109
116
  't' => image_id,
110
117
  'dockerfile' => dockerfile,
111
- 'buildargs' => JSON.dump(build_args)
118
+ 'buildargs' => build_args_json
119
+ }
120
+ end
121
+
122
+ def build_image(build_context, args, timeout)
123
+ ::Docker.options = {
124
+ timeout: timeout,
125
+ read_timeout: timeout,
126
+ write_timeout: timeout
112
127
  }
128
+ ::Docker::Image.build_from_dir(build_context, args) do |value|
129
+ build_output(value)
130
+ end
113
131
  end
114
132
  end
115
133
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: minimal_pipeline
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.2
4
+ version: 0.3.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mayowa Aladeojebi