├── Dockerfile ├── README.md └── script.sh /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM debian:latest 2 | 3 | ARG QT_VERSION=5.12.4 4 | ARG NDK_VERSION=r17c 5 | ARG SDK_INSTALL_PARAMS=platform-tool,build-tools-20.0.0,android-19 6 | ARG QT_PACKAGES="qt,qt.qt5.5124,qt.qt5.5124.gcc_64,qt.qt5.5124.android_armv7" 7 | 8 | RUN dpkg --add-architecture i386 9 | RUN apt-get update 10 | 11 | RUN apt-get install -y \ 12 | wget \ 13 | curl \ 14 | unzip \ 15 | git \ 16 | g++ \ 17 | make \ 18 | lib32z1 \ 19 | lib32ncurses6 \ 20 | libbz2-1.0:i386 \ 21 | lib32stdc++6 \ 22 | && apt-get clean 23 | 24 | #install dependencies for Qt installer 25 | RUN apt-get install -y \ 26 | libgl1-mesa-glx \ 27 | libglib2.0-0 \ 28 | && apt-get clean 29 | 30 | #install dependencies for Qt modules 31 | RUN apt-get install -y \ 32 | libfontconfig1 \ 33 | libdbus-1-3 \ 34 | libx11-xcb1 \ 35 | libnss3-dev \ 36 | libasound2-dev \ 37 | libxcomposite1 \ 38 | libxrandr2 \ 39 | libxcursor-dev \ 40 | libegl1-mesa-dev \ 41 | libxi-dev \ 42 | libxss-dev \ 43 | libxtst6 \ 44 | libgl1-mesa-dev \ 45 | && apt install apt-transport-https ca-certificates wget dirmngr gnupg software-properties-common -y \ 46 | && wget -qO - https://adoptopenjdk.jfrog.io/adoptopenjdk/api/gpg/key/public | apt-key add - \ 47 | && add-apt-repository --yes https://adoptopenjdk.jfrog.io/adoptopenjdk/deb/ \ 48 | && apt update && apt install adoptopenjdk-8-hotspot -y \ 49 | && apt-get clean 50 | 51 | 52 | ENV VERBOSE=1 53 | ENV QT_CI_PACKAGES=$QT_PACKAGES 54 | 55 | RUN wget https://raw.githubusercontent.com/homdx/qtci/master/bin/install-android-sdk --directory-prefix=/tmp \ 56 | && chmod u+rx /tmp/install-android-sdk \ 57 | && /tmp/install-android-sdk $SDK_INSTALL_PARAMS 58 | 59 | 60 | #dependencies for Qt installer 61 | RUN apt-get install -y \ 62 | libgl1-mesa-glx \ 63 | libglib2.0-0 \ 64 | && apt-get clean 65 | 66 | #download + install Qt 67 | 68 | RUN mkdir -p /tmp/qt-installer \ 69 | cd /tmp/qt-installer \ 70 | && wget https://raw.githubusercontent.com/homdx/qtci/master/bin/extract-qt-installer --directory-prefix=/tmp/qt-installer/ \ 71 | && wget https://raw.githubusercontent.com/homdx/qtci/master/recipes/install-qt --directory-prefix=/tmp/qt-installer/ \ 72 | && export PATH=$PATH:/tmp/qt-installer/ \ 73 | && chmod u+rx /tmp/qt-installer/extract-qt-installer \ 74 | && chmod u+rx /tmp/qt-installer/install-qt \ 75 | && bash /tmp/qt-installer/install-qt $QT_VERSION \ 76 | && rm -rf /tmp/qt-installer 77 | 78 | RUN wget https://raw.githubusercontent.com/homdx/qtci/master/bin/build-android-gradle-project --directory-prefix=/root/ \ 79 | && chmod u+rx /root/build-android-gradle-project 80 | 81 | RUN echo $PATH 82 | 83 | ENV PATH="/Qt/$QT_VERSION/android_armv7/bin/:${PATH}" 84 | ENV ANDROID_NDK_ROOT="/android-ndk-$NDK_VERSION" 85 | ENV ANDROID_SDK_ROOT="/android-sdk-linux" 86 | ENV QT_HOME=/Qt/$QT_VERSION/ 87 | 88 | # install sdk tools to accept licenses 89 | RUN mkdir -p /root/sdk-tools \ 90 | && wget https://dl.google.com/android/repository/sdk-tools-linux-4333796.zip --directory-prefix=/root/sdk-tools/ \ 91 | && cd /root/sdk-tools/ \ 92 | && unzip sdk-tools-linux-4333796.zip \ 93 | && rm -f sdk-tools-linux-4333796.zip \ 94 | && yes | tools/bin/sdkmanager --licenses --sdk_root=$ANDROID_SDK_ROOT \ 95 | && rm -vf /android-ndk-*.zip /android-sdk*.tgz 96 | 97 | RUN ln -s /root/build-android-gradle-project /usr/bin/build-android-gradle-project 98 | 99 | CMD tail -f /var/log/faillog 100 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | This Dockerfile allows to build Qt applications inside a container container. It uses the awesome [qtci](https://github.com/benlau/qtci) scripts from [@benlau](https://github.com/benlau) for installing Qt, the android SDK + NDK. 2 | 3 | # Usage 4 | * Download the Dockerfile to your host system with 5 | `wget https://raw.githubusercontent.com/bbernhard/qt-android-docker/master/Dockerfile` 6 | 7 | * Change to the directory where the Dockerfile resides and build the docker container with: 8 | 9 | ```docker build -t qt-android .``` 10 | 11 | If no build arguments are specified, a docker container with Qt 5.12.0, Android NDK r17c and android-19 will be created. 12 | 13 | In case you want to create a docker image with different versions, change the following line accordingly: 14 | 15 | ```bash 16 | docker build -t qt-android --build-arg QT_VERSION="5.12.0" --build-arg NDK_VERSION="r17c" --build-arg SDK_INSTALL_PARAMS="platform-tool,build-tools-20.0.0,android-19" --build-arg QT_PACKAGES="qt,qt.qt5.5120,qt.qt5.5120.gcc_64,qt.qt5.5120.android_armv7" . 17 | ``` 18 | 19 | * Next, create a bash script on your host system, which will then be executed inside the docker container. 20 | 21 | e.q: The script to build [Imagemonkey - TheGame](https://github.com/bbernhard/imagemonkey-thegame) looks like this: 22 | 23 | ```bash 24 | # script.sh 25 | #!/bin/bash 26 | 27 | export ANDROID_TARGET_SDK_VERSION=23 28 | git clone https://github.com/bbernhard/imagemonkey-thegame.git /tmp/imagemonkey-thegame 29 | build-android-gradle-project /tmp/imagemonkey-thegame/imagemonkey_thegame.pro 30 | ``` 31 | 32 | * Now, create a folder named `android-build` on your host system and run the docker container with 33 | 34 | `docker run --mount type=bind,source="$(pwd)/android-build",target=/android-build -i qt < script.sh` 35 | 36 | to build your application. Inside the `android-build` folder you should now find the apk. 37 | -------------------------------------------------------------------------------- /script.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # This is a sample script that illustrates how to build a Qt android app inside the docker container. 4 | # This script here runs _inside_ the docker container. It clones the imagemonkey-thegame project 5 | # (that's the one we want to build) and then starts the building process. 6 | 7 | export ANDROID_TARGET_SDK_VERSION=23 8 | git clone https://github.com/bbernhard/imagemonkey-thegame.git /tmp/imagemonkey-thegame 9 | build-android-gradle-project /tmp/imagemonkey-thegame/imagemonkey_thegame.pro 10 | --------------------------------------------------------------------------------