blob: 1460cff3c4ef87dc372e9f0513d901d291c19721 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
|
import qbs
import qbs.FileInfo
import qbs.Probes
import qbs.Utilities
Module {
Probes.BinaryProbe {
id: dockercli
names: ["docker"]
}
property string dockerFilePath: dockercli.filePath
property string imageTag
property stringList buildFlags
FileTagger {
patterns: ["Dockerfile"]
fileTags: ["docker.dockerfile"]
}
Rule {
inputs: ["docker.dockerfile"]
Artifact {
// Let Docker handle the dependency management
filePath: FileInfo.joinPaths(product.buildDirectory,
Utilities.getHash(input.filePath), ".docker-image-dummy")
fileTags: ["docker.docker-image"]
}
prepare: {
var args = ["build"];
var tag = product.docker.imageTag;
if (tag)
args.push("-t", tag);
Array.prototype.push.apply(args, product.docker.buildFlags);
args.push(".");
var cmd = new Command(product.docker.dockerFilePath, args);
cmd.workingDirectory = FileInfo.path(input.filePath);
cmd.description = "building docker image "
+ FileInfo.fileName(cmd.workingDirectory) + (tag ? " (" + tag + ")" : "");
return [cmd];
}
}
validate: {
if (!dockerFilePath)
throw ModUtils.ModuleError("Could not find Docker.");
}
}
|