Skip to content
Browse files

Merge pull request #71 from rose-a/docker-compatibility

make compatible with docker build
  • Loading branch information...
synapticvoid committed Jul 14, 2019
2 parents 416ac61 + 258c463 commit 112e6560eadf3bc7bbb0ac337edc8a555bd257e8
@@ -3,22 +3,19 @@
## Purpose
Offer an easy-to-use environment to cross-compile Qt application on a Raspberry Pi. This repo contains all the scripts needed to prepare a sysroot, cross-compile Qt and deploy Qt libraries to your Raspberry.

For more information, go to

## How to contact us?
You can fill a contact form from our [official website]( or send us an email at *contact [at] neuronalmotion [dot] com*.
For more information, go to [the wiki](

## Difference between init-qtrpi-minimal and init-qtrpi-full
* **init-qtrpi-minimal**, the typical way: downloads ready-to-use Qt binaries for the Raspberry Pi and a minimal sysroot that we released on the [official website](
* **init-qtrpi-minimal**, the typical way: downloads ready-to-use Qt binaries for the Raspberry Pi and a minimal sysroot that we released on the [download page](
* **init-qtrpi-full**, the custom way: compiles on your computer the Qt binaries for the Raspberry Pi to let you tweak the configuration, enhance the compilation by adding some missing Qt modules to QtRpi or add some specific third-party dependencies

### Summary
| | init-qtrpi-minimal | init-qtrpi-full |
| ------------------- | ----------------------------- | ------------------------------------ |
| Raspbian image | | *from [](* |
| Toochain | *from [the github project](* | *from [the github project](* |
| Sysroot | *from [](* | generated from raspbian image |
| Qt binaries | *from [](* | compiled |
| Sysroot | *from qtrpi team* | generated from raspbian image |
| Qt binaries | *from qtrpi team* | compiled |

## Tutorial of

@@ -29,7 +26,7 @@ This tutorial will help you to:

### Requirements
* A 64-bit Linux host computer
* A Raspberry Pi 3
* A Raspberry Pi 3 **with Raspbian Jessie** (Raspbian Stretch is currently not supported!)

In this example, you already have an SSH access to your Raspberry Pi 3 at `` with the user `pi`. The script will use sudo several times to install the packages on the board. You should add your SSH key in your Raspberry Pi. For example with **`ssh-copy-id`**:
@@ -80,3 +77,25 @@ How to build a Raspberry Pi 3 application from your desktop Qt Creator (step by
* If you want to add a module, just add the repository name in the file [qt-modules.txt](
* You might have to add some packages in the sysroot, this can be done in [utils/](
* Once you have modified these scripts, you should be able to re-execute []( and see the magic happen.

## Docker images

The images are tagged according to their target configuration.

Currently the following tags are available:

* `rpi3-qt5.6.2`: Crosscompile Qt 5.6.2 for the Raspbarry Pi 3

Choose the image which fits your needs.

### Building a Qt project

To build a Qt project, mount the directory containing the sources and the project file to the `/sources` path inside the container and run it.
By default the image automatically executes `qmake` and `make` in the current working directory, which is set to `/sources` by default.

#### Example

``` shell
docker pull arose/qtrpi:rpi3-qt5.6.2
docker run -v /someqtprojectfolder/:/source arose/qtrpi:rpi3-qt5.6.2
@@ -0,0 +1,40 @@
FROM debian:stable-slim
LABEL maintainer="Alexander Rose <>"

# install necessary packages
RUN apt-get update -q && apt-get install -yq --no-install-recommends \
build-essential \
ca-certificates \
curl \
git \
unzip \
&& rm -rf /var/lib/apt/lists/*

# Clone Qtrpi and additional scripts
RUN git clone -b docker-compatibility

# Setup Qtrpi environment
QTRPI_TARGET_DEVICE='linux-rpi3-g++' \
QTRPI_TARGET_HOST='pi@localhost' \

# Change workdir
WORKDIR /qtrpi

# Execute init script and clean up after it
RUN ./ && \
rm /opt/qtrpi/*.zip && \
rm -rf /opt/qtrpi/raspi/tools/.git && \
rm -rf /opt/qtrpi/raspi/tools/arm-bcm2708/arm-* && \
rm -rf /opt/qtrpi/raspi/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian

# Extend path
ENV PATH=/opt/qtrpi/bin:$PATH

# Create path for source files
RUN mkdir /source
WORKDIR /source

# Execute build commands on run
CMD /qtrpi/docker/scripts/
@@ -0,0 +1,11 @@

source ${0%/*}/utils/

# Run qmake
message 'running qmake...'

# Run make
message 'running make...'
@@ -6,3 +6,4 @@ qtquickcontrols
@@ -82,6 +82,10 @@ QTRPI_SYSROOT_URL="$QTRPI_BASE_URL/sysroot/"

# evaluate docker usage
if [[ $QTRPI_DOCKER ]]; then

# Get absolute path of script dir for later execution
# /!\ has to be executed *before* any "cd" command
@@ -53,7 +53,8 @@ function download_raspbian() {
message 'Downloading Raspbian latest image'
wget --output-document=${RASPBIAN_BASENAME}.zip \
--content-disposition \

@@ -4,15 +4,23 @@ source ${0%/*}/

message 'Creating qtrpi directory structure'

# sanity check for mounted image
sudo umount /mnt/raspbian
sudo umount $ROOT/raspbian/sysroot-full/sys
sudo umount $ROOT/raspbian/sysroot-full/dev
sudo umount $ROOT/raspbian/sysroot-full/proc
if [[ ! $DOCKER_BUILD ]]; then
# sanity check for mounted image
sudo umount /mnt/raspbian
sudo umount $ROOT/raspbian/sysroot-full/sys
sudo umount $ROOT/raspbian/sysroot-full/dev
sudo umount $ROOT/raspbian/sysroot-full/proc

sudo mkdir -p $ROOT
sudo chown -R $USER:$USER $ROOT
# === Docker-Mode ===
# umount is not allowed in a docker image, besides we use a fresh linux image => skipping sanity checks
# sudo is also not needed/installed by default => creating directory structure without use of sudo
mkdir -p $ROOT
chown -R $USER:$USER $ROOT

sudo mkdir -p $ROOT
sudo chown -R $USER:$USER $ROOT

mkdir raspi raspbian bin logs

@@ -7,6 +7,7 @@ mkdir -p raspbian ; cd raspbian

# Mount and extract the raspbian sysroot
message 'Creating sysroot'
sudo umount /dev/loop0
sudo losetup -P /dev/loop0 ${RASPBIAN_BASENAME}.img
sudo mkdir /mnt/raspbian
sudo mount /dev/loop0p2 /mnt/raspbian
@@ -43,10 +43,15 @@ cd raspi

message 'Downloading Raspberry Pi toolchain'

if [[ ! -d 'tools' ]]; then
git clone
if [[ ! $DOCKER_BUILD ]]; then
if [[ ! -d 'tools' ]]; then
git clone

pushd tools
git pull origin master
# create shallow copy, which is a lot faster
git clone --depth=1 -b master

pushd tools
git pull origin master

0 comments on commit 112e656

Please sign in to comment.
You can’t perform that action at this time.