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.

Leave a Reply

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