[krita] build-tools/docker: Add a framework for building Krita under Docker

Dmitry Kazakov null at kde.org
Wed May 2 10:34:40 UTC 2018


Git commit 8b84c126bc0464b7712c0563840d26b366f0fd17 by Dmitry Kazakov.
Committed on 02/05/2018 at 10:33.
Pushed by dkazakov into branch 'master'.

Add a framework for building Krita under Docker

Now you can have a Krita build in 30 minutes on any Linux OS without
thinkign about the deps (because the deps are prebuilt by KDE).

The docker image uses the same dependencies that are used by KDE CI
for building AppImage builds, therefore the resulting build will look
(and work) almost exactly as the user-delivered AppImage.

CC:kimageshop at kde.org

A  +1    -0    build-tools/docker/.gitignore
A  +35   -0    build-tools/docker/Dockerfile
A  +110  -0    build-tools/docker/README.md
A  +13   -0    build-tools/docker/bin/bootstrap-deps.sh
A  +8    -0    build-tools/docker/bin/build_image
A  +8    -0    build-tools/docker/bin/enter_container
A  +19   -0    build-tools/docker/bin/run_container
A  +8    -0    build-tools/docker/default-home/.bash_aliases
A  +26   -0    build-tools/docker/default-home/devenv.inc
A  +8    -0    build-tools/docker/default-home/run_cmake.sh

https://commits.kde.org/krita/8b84c126bc0464b7712c0563840d26b366f0fd17

diff --git a/build-tools/docker/.gitignore b/build-tools/docker/.gitignore
new file mode 100644
index 00000000000..f050bccf3b4
--- /dev/null
+++ b/build-tools/docker/.gitignore
@@ -0,0 +1 @@
+persistent
diff --git a/build-tools/docker/Dockerfile b/build-tools/docker/Dockerfile
new file mode 100644
index 00000000000..ff5f8b99df2
--- /dev/null
+++ b/build-tools/docker/Dockerfile
@@ -0,0 +1,35 @@
+FROM kdeorg/appimage-base
+
+MAINTAINER Dmitry Kazakov <dimula73 at gmail.com>
+RUN apt-get update && apt-get -y install curl
+
+ENV USRHOME=/home/appimage
+
+RUN chsh -s /bin/bash appimage
+
+RUN locale-gen en_US.UTF-8
+
+USER appimage
+
+RUN echo 'export LC_ALL=en_US.UTF-8' >> ${USRHOME}/.bashrc && \
+    echo 'export LANG=en_US.UTF-8'  >> ${USRHOME}/.bashrc && \
+    echo "export PS1='\u@\h:\w>'"  >> ${USRHOME}/.bashrc && \
+    echo 'source ~/devenv.inc' >> ${USRHOME}/.bashrc && \
+    echo 'prepend PATH ~/bin/' >> ${USRHOME}/.bashrc
+
+RUN mkdir -p ${USRHOME}/appimage-workspace/krita-inst && \
+    mkdir -p ${USRHOME}/appimage-workspace/krita-build && \
+    mkdir -p ${USRHOME}/bin
+
+COPY ./default-home/devenv.inc \
+     ./default-home/.bash_aliases \
+     ${USRHOME}/
+
+COPY ./default-home/run_cmake.sh \
+     ${USRHOME}/bin
+
+ADD persistent/krita-appimage-deps.tar ${USRHOME}/appimage-workspace/
+
+CMD tail -f /dev/null
+
+
diff --git a/build-tools/docker/README.md b/build-tools/docker/README.md
new file mode 100644
index 00000000000..072da59fd75
--- /dev/null
+++ b/build-tools/docker/README.md
@@ -0,0 +1,110 @@
+# Krita developer environment Docker image
+
+This *Dockerfile* is based on the official KDE build environmet [0]
+that in used on KDE CI for building official AppImage packages.
+Therefore running this image in a docker container is the best way
+to reproduce AppImage-only bugs in Krita.
+
+[0] - https://binary-factory.kde.org/job/Krita_Nightly_Appimage_Dependency_Build/
+
+## Prerequisites
+
+Firstly we need to download deps and Krita source tree. These steps are not
+included into the *Dockerfile* to save internael bandwidth (most Krita
+developers already have al least one clone of Krita source tree).
+
+```bash
+# download the deps archive
+./bin/bootstrap-deps.sh
+
+# mount/copy/chechout Krita sources to 'persistent/krita'
+mkdir -p persistent/krita
+sudo mount --bind ../../ ./persistent/krita
+```
+
+## Build the docker image and run the container
+
+```bash
+./bin/build_image krita-deps
+./bin/run_container krita-deps krita-build
+```
+
+## Enter the container and build Krita
+
+```bash
+# enter the docker container
+./bin/enter_container krita-build
+
+# ... now your are inside the container with all the deps prepared ...
+
+# build Krita as usual
+cd appimage-workspace/krita-build/
+run_cmake.sh ~/persistent/krita
+make -j8 install
+
+# start Krita
+krita
+
+```
+
+## Extra developer tools
+
+If you want to develop Krita, you might want to install at least some
+developer tools into the container, e.g. GDB, Valgring, ccmake and QtCreator.
+To do that, execute the following from yout **host** console:
+
+```bash
+sudo docker exec -ti apt install gdb
+sudo docker exec -ti apt install valgrind
+sudo docker exec -ti apt install cmake-curses-gui
+
+# inside the container
+cd ~/persistent
+wget http://master.qt.io/archive/online_installers/3.0/qt-unified-linux-x64-3.0.4-online.run
+./qt-unified-linux-x64-3.0.4-online.run
+
+# when going through the setup wizard select not to install any
+# extra Qt libraries, install QtCreator only!
+
+```
+
+## Stopping the container and cleaning up
+
+When not in use you can stop the container. All your filesystem state is saved, but
+all the currently running processes are killed (just ensure you logout from all the
+terminals before stopping).
+
+```bash
+sudo docker stop krita-build
+```
+
+If you don't need your container/image anymore, you can delete them from the docker
+
+```bash
+# remove the container
+sudo docker rm krita-build
+
+# remove the image
+sudo docker rmi krita-deps
+```
+
+TODO: do we need some extra cleaups for docker's caches?
+
+
+## Troubleshooting
+
+### Krita binary is not found after the first build
+
+Either relogin to the container or just execute `source ~/.devenv.inc`
+
+
+### Not enough space on root partition
+
+All the docker images and containers are stored in a special docker-daemon controlled
+folder under */var* directory. You might not have enough space there for building Krita
+(it needs about 10 GiB). In such a case it is recommended to move the docker images
+folder into another location, where there is enough space.
+
+```bash
+echo 'DOCKER_OPTS="-g /home/devel5/docker"' > /etc/default/docker
+```
diff --git a/build-tools/docker/bin/bootstrap-deps.sh b/build-tools/docker/bin/bootstrap-deps.sh
new file mode 100755
index 00000000000..b293b802264
--- /dev/null
+++ b/build-tools/docker/bin/bootstrap-deps.sh
@@ -0,0 +1,13 @@
+#!/bin/bash
+
+if [ ! -d ./persistent ]; then
+    mkdir ./persistent
+fi
+
+if [ ! -f ./persistent/krita-appimage-deps.tar ]; then
+    (
+        cd ./persistent/
+        wget https://binary-factory.kde.org/job/Krita_Nightly_Appimage_Dependency_Build/lastSuccessfulBuild/artifact/krita-appimage-deps.tar || exit 1
+    )
+fi
+
diff --git a/build-tools/docker/bin/build_image b/build-tools/docker/bin/build_image
new file mode 100755
index 00000000000..47f6772ebbf
--- /dev/null
+++ b/build-tools/docker/bin/build_image
@@ -0,0 +1,8 @@
+#!/bin/bash
+
+if [ "$#" -ne 1 ]; then
+  echo "Usage: $0 IMAGE_NAME" >&2
+  exit 1
+fi
+
+sudo docker build -t $1 .
diff --git a/build-tools/docker/bin/enter_container b/build-tools/docker/bin/enter_container
new file mode 100755
index 00000000000..083e3dd25af
--- /dev/null
+++ b/build-tools/docker/bin/enter_container
@@ -0,0 +1,8 @@
+#!/bin/bash
+
+if [ "$#" -ne 1 ]; then
+  echo "Usage: $0 CONTAINER_NAME" >&2
+  exit 1
+fi
+
+sudo docker exec -ti $1 sh -c "cd /home/appimage && /bin/bash -l"
diff --git a/build-tools/docker/bin/run_container b/build-tools/docker/bin/run_container
new file mode 100755
index 00000000000..835be35acf0
--- /dev/null
+++ b/build-tools/docker/bin/run_container
@@ -0,0 +1,19 @@
+#!/bin/bash
+
+if [ "$#" -ne 2 ]; then
+  echo "Usage: $0 IMAGE_NAME CONTAINER_NAME" >&2
+  exit 1
+fi
+
+sudo docker run -P -t -d \
+  -v $(pwd)/persistent/:/home/appimage/persistent/:rw \
+  -v /tmp/.X11-unix/:/tmp/.X11-unix \
+  -v /home/$USER/.Xauthority:/home/appimage/.Xauthority \
+  -v /etc/localtime:/etc/localtime:ro \
+  -e DISPLAY=$DISPLAY \
+  -h $HOSTNAME \
+  --device /dev/dri \
+  --device /dev/snd \
+  -p127.0.0.1:2022:22 \
+  --name $2 \
+  $1
diff --git a/build-tools/docker/default-home/.bash_aliases b/build-tools/docker/default-home/.bash_aliases
new file mode 100644
index 00000000000..716865784d2
--- /dev/null
+++ b/build-tools/docker/default-home/.bash_aliases
@@ -0,0 +1,8 @@
+alias ll='ls -alF'
+alias la='ls -A'
+alias l='ls -CF'
+
+alias ..='cd ..'
+alias ...='cd ../..'
+alias ....='cd ../../..'
+
diff --git a/build-tools/docker/default-home/devenv.inc b/build-tools/docker/default-home/devenv.inc
new file mode 100644
index 00000000000..5c7103df628
--- /dev/null
+++ b/build-tools/docker/default-home/devenv.inc
@@ -0,0 +1,26 @@
+prepend() { [ -d "$2" ] && eval $1=\"$2\$\{$1:+':'\$$1\}\" && export $1 ; }
+
+export KRITADIR=/home/appimage/appimage-workspace/krita-inst
+export DEPSDIR=/home/appimage/appimage-workspace/deps/usr
+
+
+prepend PATH $KRITADIR/bin
+prepend LD_LIBRARY_PATH $KRITADIR/lib64
+prepend LD_LIBRARY_PATH $KRITADIR/lib
+prepend XDG_DATA_DIRS $KRITADIR/share
+prepend PKG_CONFIG_PATH $KRITADIR/lib64/pkgconfig
+prepend PKG_CONFIG_PATH $KRITADIR/lib/pkgconfig
+
+prepend PATH $DEPSDIR/bin
+prepend LD_LIBRARY_PATH $DEPSDIR/lib64
+prepend LD_LIBRARY_PATH $DEPSDIR/lib
+prepend XDG_DATA_DIRS $DEPSDIR/share
+prepend PKG_CONFIG_PATH $DEPSDIR/lib64/pkgconfig
+prepend PKG_CONFIG_PATH $DEPSDIR/lib/pkgconfig
+
+prepend CMAKE_PREFIX_PATH $DEPSDIR
+
+prepend PYTHONPATH $DEPSDIR/lib/python3.5/
+prepend PYTHONPATH $DEPSDIR/sip
+
+prepend PYQT_SIP_DIR_OVERRIDE $DEPSDIR/share/sip
\ No newline at end of file
diff --git a/build-tools/docker/default-home/run_cmake.sh b/build-tools/docker/default-home/run_cmake.sh
new file mode 100755
index 00000000000..dc5ff85582d
--- /dev/null
+++ b/build-tools/docker/default-home/run_cmake.sh
@@ -0,0 +1,8 @@
+#!/bin/bash
+
+cmake -DCMAKE_INSTALL_PREFIX=${KRITADIR} \
+      -DCMAKE_BUILD_TYPE=RelWithDebInfo \
+      -DBUILD_TESTING=TRUE \
+      -DHIDE_SAFE_ASSERTS=FALSE \
+      -DPYQT_SIP_DIR_OVERRIDE=~/appimage-workspace/deps/usr/share/sip
+      $@


More information about the kimageshop mailing list