diff options
author | Richard Weickelt <richard@weickelt.de> | 2020-03-17 13:24:27 +0100 |
---|---|---|
committer | Richard Weickelt <richard@weickelt.de> | 2020-03-26 12:13:20 +0000 |
commit | 92b39d31334b7503c5ab37713b2077b5e0fb64c3 (patch) | |
tree | 3670a9ba6288d7897f365fdacff242182d5951aa | |
parent | 215ceb0393e890367a40c6bec7236bd9162cf088 (diff) |
Use docker-compose exclusively for managing Docker images
Qbs used to have docker products and a module for building the images, but this
became obsolet and was superseded by the docker-compose infrastructure.
Docker-compose is a much better fit for our use-case (which is mostly CI). It
allows us to use unique (and complicated) tags both when building and running
the images without exposing that to the user. Unique tags like
bionic-5.12.6_1.14.1-2 instead of just bionic ensure that changes in the
infrastructure don't suddenly break builds in older branches using the same
image.
This patch also updates the documentation to emphasize the usage of
docker-compose.
Change-Id: I45335d37034d10dda5ab5079ee3be1f81cb3e5c5
Reviewed-by: Ivan Komissarov <ABBAPOH@gmail.com>
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
-rw-r--r-- | doc/qbs.qdoc | 41 | ||||
-rw-r--r-- | docker/docker.qbs | 38 | ||||
-rw-r--r-- | qbs-resources/modules/docker/docker.qbs | 50 | ||||
-rw-r--r-- | qbs.qbs | 9 |
4 files changed, 28 insertions, 110 deletions
diff --git a/doc/qbs.qdoc b/doc/qbs.qdoc index ef757d0d1..db9a64af4 100644 --- a/doc/qbs.qdoc +++ b/doc/qbs.qdoc @@ -694,7 +694,7 @@ A set of Docker images for developing \QBS (which are maintained by the \QBS team) is available \l{https://hub.docker.com/u/qbsbuild/}{on Docker Hub}. - Both Windows Server Core and Debian Linux container types are available. + Both Windows 10 and Debian Linux container types are available. \note The source code for the \QBS development Docker images is located in the \c{docker/} directory of the \QBS source tree, if you wish to build them yourself. @@ -712,45 +712,46 @@ \li Latest stable release of \QBS for building \QBS with \QBS \endlist - Run the following command to download the \QBS development image based on Ubuntu 18.04 \e Bionic: + We are using docker-compose for building and running the Docker images because it simplifies + the Docker command line and ensures that the correct image tag is used. All available images + are listed in the \c docker-compose.yml file in the project root directory. + + Run the following command to download the \QBS development image based on Ubuntu 18.04 + \e Bionic: \code - docker pull qbsbuild/qbsdev:bionic + docker-compose pull bionic \endcode You can then create a new container with the \QBS source directory mounted from your host machine's file system, by running: \code - docker run -it -v ${PWD}:/qbs -w /qbs qbsbuild/qbsdev:bionic - \endcode - - You will now be in an interactive Linux shell where you can develop and build \QBS. - - For convenience, you can also run \c docker-compose from the project root directory: - - \code docker-compose run --rm bionic \endcode - This will download and run the container in one go and mount the project root directory - to \c /qbs in the container. + You will now be in an interactive Linux shell where you can develop and build \QBS. \section2 Windows Containers To build \QBS for Windows using Windows containers, your host OS must be running Windows 10 Pro - and have Hyper-V enabled. \l{https://docs.docker.com/docker-for-windows/#switch-between-windows-and-linux-containers}{Switch your Docker environment to use Windows containers}, then run the - following command to download the Windows 10 \QBS development image: + and have Hyper-V enabled. \l{https://docs.docker.com/docker-for-windows/#switch-between-windows-and-linux-containers}{Switch your Docker environment to use Windows containers}. + + We are using docker-compose for building and running the Docker images because it simplifies + the Docker command line and ensures that the correct image tag is used. All available images + are listed in the \c docker-compose.yml file in the project root directory. + + Run the following command to download the \QBS development image based on Windows 10: \code - docker pull qbsbuild/qbsdev:windowsservercore + docker-compose pull windows \endcode You can then create a new container with the \QBS source directory mounted from your host machine's file system, by running: \code - docker run -it -v %CD%:C:\qbs -w C:\qbs qbsbuild/qbsdev:windowsservercore + docker-compose run --rm windows \endcode If you want to use Windows containers on a macOS or Linux host, you will have to create a @@ -764,7 +765,7 @@ \code eval $(docker-machine env windows) - docker run -it -v C:$PWD:C:\\qbs -w C:\\qbs qbsbuild/qbsdev:windowsservercore + docker-compose run --rm windows \endcode \section2 Building Release Packages @@ -772,14 +773,14 @@ Release packages for \QBS for Windows can be built using the following command on Windows: \code - docker run --rm -v %CD%:C:\qbs -w C:\qbs qbsbuild/qbsdev:windowsservercore cmd /c scripts\make-release-archives + docker-compose run --rm windows cmd /c scripts\make-release-archives \endcode For building release packages for Windows on macOS or Linux: \code eval $(docker-machine env windows) - docker run --rm -v C:$PWD:C:\\qbs -w C:\\qbs qbsbuild/qbsdev:windowsservercore cmd /c scripts\\make-release-archives + docker-compose run --rm windows cmd /c scripts\\make-release-archives \endcode */ diff --git a/docker/docker.qbs b/docker/docker.qbs index 752c61d3b..513a5fd8b 100644 --- a/docker/docker.qbs +++ b/docker/docker.qbs @@ -1,34 +1,8 @@ -import qbs -Project { - Product { - Depends { name: "docker"; required: false } - - name: "qbs-docker-stretch" - type: ["docker.docker-image"] - builtByDefault: false - condition: docker.present - - docker.imageTag: "qbsbuild/qbsdev:stretch" - - files: [ - "stretch/Dockerfile", - "stretch/entrypoint.sh", - ] - } - - Product { - Depends { name: "docker"; required: false } - - name: "qbs-docker-windowsservercore" - type: ["docker.docker-image"] - builtByDefault: false - condition: docker.present - - docker.imageTag: "qbsbuild/qbsdev:windowsservercore" - - files: [ - "windowsservercore/Dockerfile", - ] - } +// This is a convenience product to be able to use Qt Creator for editing the docker files. +// For building and managing the images, use docker-compose as explained in +// https://doc.qt.io/qbs/building-qbs.html#using-docker. +Product { + name: "docker" + files: "**" } diff --git a/qbs-resources/modules/docker/docker.qbs b/qbs-resources/modules/docker/docker.qbs deleted file mode 100644 index 1460cff3c..000000000 --- a/qbs-resources/modules/docker/docker.qbs +++ /dev/null @@ -1,50 +0,0 @@ -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."); - } -} @@ -4,7 +4,6 @@ Project { minimumQbsVersion: "1.6" qbsSearchPaths: ["qbs-resources"] property bool withCode: true - property bool withDocker: true property bool withDocumentation: true property bool withExamples: false property bool withTests: withCode @@ -12,18 +11,12 @@ Project { property stringList autotestWrapper: [] references: [ + "docker/docker.qbs", "share/share.qbs", "scripts/scripts.qbs", ] SubProject { - filePath: "docker/docker.qbs" - Properties { - condition: parent.withDocker - } - } - - SubProject { filePath: "doc/doc.qbs" Properties { condition: parent.withDocumentation |