Commit 8b84c126 authored by Dmitry Kazakov's avatar Dmitry Kazakov

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@kde.org
parent a99fea91
FROM kdeorg/appimage-base
MAINTAINER Dmitry Kazakov <dimula73@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
# 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
```
#!/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
#!/bin/bash
if [ "$#" -ne 1 ]; then
echo "Usage: $0 IMAGE_NAME" >&2
exit 1
fi
sudo docker build -t $1 .
#!/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"
#!/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
alias ll='ls -alF'
alias la='ls -A'
alias l='ls -CF'
alias ..='cd ..'
alias ...='cd ../..'
alias ....='cd ../../..'
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
#!/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
$@
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment