Skip to content

Commit 7d73e87

Browse files
authored
Merge pull request #793 from pipex/build-image-from-cache
Use JSON serialization for cachefrom option
2 parents 6ec9f25 + 88597cc commit 7d73e87

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

lib/docker.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -286,6 +286,10 @@ Docker.prototype.buildImage = function(file, opts, callback) {
286286
optsf.authconfig = optsf.options.authconfig;
287287
delete optsf.options.authconfig;
288288
}
289+
290+
if (opts.cachefrom && Array.isArray(opts.cachefrom)) {
291+
optsf.options.cachefrom = JSON.stringify(opts.cachefrom);
292+
}
289293
}
290294

291295
function dial(callback) {

test/docker.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,28 @@ describe("#docker", function() {
149149
}, { t: 'multiple-files' }, handler);
150150
});
151151

152+
it("should build image from multiple files using cache", function(done) {
153+
this.timeout(60000);
154+
155+
function handler(err, stream) {
156+
expect(err).to.be.null;
157+
expect(stream).to.be.ok;
158+
159+
stream.pipe(process.stdout, {
160+
end: true
161+
});
162+
163+
stream.on('end', function() {
164+
done();
165+
});
166+
}
167+
168+
docker.buildImage({
169+
context: __dirname,
170+
src: ['Dockerfile']
171+
}, { t: 'multiple-files-cachefrom', 'cachefrom': ['ubuntu:latest'] }, handler);
172+
});
173+
152174
it("should build image from multiple files while respecting the .dockerignore file", function(done) {
153175
this.timeout(60000);
154176

0 commit comments

Comments
 (0)