diff options
author | Jake Petroules <jake.petroules@qt.io> | 2017-08-15 16:45:51 -0700 |
---|---|---|
committer | Jake Petroules <jake.petroules@qt.io> | 2017-08-18 18:03:31 +0000 |
commit | ee727769c96af3e274a2b4c3ce145e070c3fc4b5 (patch) | |
tree | 23814bf919a810cb0d342846fe8db185f7b8afd3 /qbs-resources | |
parent | b198f65709dbd3f4e78e85058558d06b9e295e3c (diff) |
Add products to build the Qbs Docker images
Change-Id: Id88521a86c057ad09355dff11ff69a1aba000a17
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
Diffstat (limited to 'qbs-resources')
-rw-r--r-- | qbs-resources/modules/docker/docker.qbs | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/qbs-resources/modules/docker/docker.qbs b/qbs-resources/modules/docker/docker.qbs new file mode 100644 index 000000000..422b1a8f5 --- /dev/null +++ b/qbs-resources/modules/docker/docker.qbs @@ -0,0 +1,51 @@ +import qbs +import qbs.FileInfo +import qbs.Probes +import qbs.Utilities + +Module { + Probes.BinaryProbe { + id: dockercli + names: ["docker"] + platformPaths: qbs.hostOS.contains("unix") ? ["/usr/bin", "/usr/local/bin"] : [] + } + + 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."); + } +} |