Docker Image for Qt Development and Continuous Integration for Linux and Android


Sometimes I need to have specific versions of Qt to build apps and run CI tasks. In this article I introduced what I used for this purpose: a multi-arch docker image containing a build of Qt to build Qt apps on arm64 or amd64 and run the app itself (useful to run unit tests for instance). I’ve been using these images to run builds and unit tests with GitLab and Jenkins on a Raspberry Pi and on a amd64 Linux desktop systems.

Building these images requires time, so I’m always looking for existing alternatives. If you know, please comment!

Android

I often also need containers to build Qt apps for Android, at least for armv7 and arm64. Instead of manually creating these images, I though I could simply add scripts to my existing project docker-qt to include the Android build.

So, for versions >= 6.4.1, I also started to include a build of Qt for Android armv7 and armv8.

NOTE: only the amd64 image contains the builds for Android, which means you cannot currently crossbuild for Android from a arm64 container.

With these images it is possible to build a Qt app for Android and get the final apk or aab package. Images include the Android NDK, the Android SDK and all the typical dev tools.

Qt Builds

Qt builds in all images are located in /opt:

$ docker run -it --rm carlonluca/qt-dev:6.4.2 "ls -l /opt"
total 20
drwxr-xr-x 14 root root 4096 Jan  7 15:44 Qt-amd64-6.4.2
drwxr-xr-x 15 root root 4096 Jan  8 00:22 Qt-and-armv7a-6.4.2
drwxr-xr-x 15 root root 4096 Jan  8 00:47 Qt-and-armv8a-6.4.2
drwxr-xr-x 13 root root 4096 Jan  7 17:04 Qt-arm64-6.4.2
drwxr-xr-x  7 root root 4096 Jan  8 10:30 android-sdk

All the binaries you need are included in these directories, like qmake, qt-cmake, androiddeployqt etc…

Example

A typical usage for these images is running CI in GitLab:

Test_linux:
  stage: test_linux
  image:
    name: "carlonluca/qt-dev:6.4.2"
    entrypoint: [""]
  script:
    - mkdir build
    - cd build
    - /opt/Qt-amd64-6.4.2/bin/qt-cmake ..
    - make

Test_android:
  stage: test_android
  image:
    name: "carlonluca/qt-dev:6.4.2"
    entrypoint: [""]
  script:
    - mkdir build
    - cd build
    - /opt/Qt-and-armv7a-6.4.2/bin/qt-cmake ..
    - make
    - test -f ./android-build/build/outputs/apk/debug/android-build-debug.apk

It is also possible to build aab packages by using the androiddeployqt binary, included in the build.

Building the Images

I don’t exactly know how many images I’ll build and how often, but you can build the images by yourself by using a proper builder. See the GitHub repo docker-qt for the appropriate scripts.

Links

Docker hub of qt-builder: https://hub.docker.com/r/carlonluca/qt-builder.
Docker hub of qt-dev: https://hub.docker.com/r/carlonluca/qt-dev.

GitHub repo: https://github.com/carlonluca/docker-qt.

5 thoughts on “Docker Image for Qt Development and Continuous Integration for Linux and Android”

  1. Hi Luca,

    Am I understanding the purpose of the QT dev image is that I could copy the sources of an app I have written with QT 5 into this image and execute the build of my sources in this container?

    Just trying to figure out if the QT Dev (x86-64) would be a QT5 compilation environment for my application.

    Thank you!

    1. Hello,
      yes, that is the point. You choose the version you need from the list of available images, you copy your sources into the container (or you mount a volume) and you build your app.
      This is typically useful in CI systems like Jenkins or GitLab, where you want your sources to be compiled and tested frequently to get notified in case of failures. The artifacts can then be extracted and distributed (like in Google Play for instance).

      1. Hi and thanks for responding Luca. I am looking to try this out. What I want to do first is to run the QT-Dev from docker-compose and like you say, mount a volume to the container that has my source and execute the build of the source in the container (only need for qt-dev:5.15.2 / x86_64). Does this sound like a valid approach? I am just trying to figure out what the proper arguments would be to run the container.

        1. If you want to do it manually of course, that is a reasonable approach. Something like docker run -it -v /host_path:/container_path carlonluca/qt-dev:5.15.2 bash. You are ready to go.

Leave a Reply

Your email address will not be published. Required fields are marked *