minimal_pipeline 0.3.2 → 0.3.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/minimal_pipeline/docker.rb +36 -18
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1d80cfbd6763abb55d2d5575870ac30fda0283e1a51b547cad5faf5e441b844b
|
4
|
+
data.tar.gz: 0b690eb4b534578da250202355188094d45bce9b1a17af499d7739243e4ec66c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
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
|
-
|
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
|
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' =>
|
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
|