inapp docker container

Build a docker container for inapp.

Stage 1: Build manually on x86

Run a Debian image for tests:

sudo docker run -ti --rm debian:jessie-slim bash

...and validate the build sequence:

apt-get update
apt-get install make
apt-get install g++
apt-get install qtbase5-dev
apt-get install libqt5websockets5-dev
apt-get install liblttng-ust-dev
apt-get install curl

cd root
curl --remote-name http://vjordan.info/tmp/inapp/inapp-0.1.tar.gz
tar xf inapp-0.1.tar.gz
mkdir build
cd build/
qmake -qt5 ../inapp-0.1
make
make install

Stage 2: Automate the build container

In Dockerfile.builder:

FROM debian:jessie-slim

# Prepare build environment
RUN apt-get update && apt-get install -y \
        make \
        g++ \
        qtbase5-dev \
        libqt5websockets5-dev \
        liblttng-ust-dev \
        curl \
    && rm -rf /var/lib/apt/lists/*

# Build
WORKDIR /root
RUN set -x \
    && curl --remote-name http://vjordan.info/tmp/inapp/inapp-0.1.tar.gz \
    && tar xf inapp-0.1.tar.gz \
    && mkdir build \
    && cd build/ \
    && qmake -qt5 ../inapp-0.1 \
    && make \
    && make install
Notes:
  • set -x prints the commands before running them.
  • The intermediate container between each RUN block is kept, and rebuilt only if the content of the RUN block changed. Here is it interesting not to download/install the Debian package again if we only change a build option.

Create the container with:

sudo docker build -t inapp-builder --pull -f Dockerfile.builder .

Run the build container and extract inapp installation (found in /opt):

sudo docker run --rm inapp-builder tar c /opt | xz -z9 > "inapp.tar.xz"

Stage 3: Create the final container image

In Dockerfile:

FROM debian:jessie-slim

# Prepare environment
# todo: Why libqt5sql ???
RUN apt-get update && apt-get install -y \
        libqt5core5a \
        libqt5network5 \
        libqt5sql5 \
        libqt5websockets5 \
        liblttng-ust0 \
    && rm -rf /var/lib/apt/lists/*

ADD inapp.tar.xz /

# Make main binary executable
# todo: Really needed?
RUN set -x \
    && chmod +x /opt/ina/pp/bin/inapp2

Create the container with:

sudo docker build -t inapp .

Run the container with:

# Needs to run priviledged to make "mount loop" possible.
sudo docker run -ti --privileged=true --rm -p 80:80 -p 4000:4000 -v /media/vjp/INAPP_DOCS/:/mnt/data/ inapp sh -xec "/opt/ina/pp/etc/start.sh && tail -f /dev/null"

Stage 4: Same but for arm7

Replace debian:jessie-slim with armv7/armhf-debian from [1].

Remember that xz -z9 consumes 674MB of RAM [2] and avoid getting:

xz: (stdin): Cannot allocate memory
write /dev/stdout: broken pipe

Watch a movie because it takes forever...

Side note

Get ldd (already installed):

sudo apt-get install libc-bin