Developing KDE with Docker

2017-07-23

Docker can help you to quickly set up a development environment for working on a software project. This is great for getting new contributors up to speed quickly. I’ve recently discovered how nice this is and want to share how I use Docker.

KDE projects often have desktop services, mimetypes and plugins. Ideally, these are installed system-wide. During development it is not convenient to change your main environment just to test your software. This is where Docker comes in. Docker is the most popular Linux container system. It gives you a system that is separate from your main system and which you can rewind when you break it.

Dolphin in KDE neon

The simplest way to get going is to run a fresh Plasma system. KDE neon provides Docker images.

After installing Docker, you can get a system going like this;

clazy quality checker. Clazy has not been packaged so the Dockerfile needs to have a build step for it.

FROM kdeneon/plasma:dev-stable

USER root

RUN apt-get update && apt-get dist-upgrade -y

RUN apt-get install -y --no-install-recommends \
  cmake extra-cmake-modules g++ gettext git kdoctools-dev kross-dev \
  libboost-all-dev libeigen3-dev libetonyek-dev libfontconfig1-dev \
  libfreetype6-dev libgit2-dev libgsl-dev libkf5activities-dev \
  libkf5archive-dev libkf5kcmutils-dev libkf5kdelibs4support-dev \
  libkf5notifications-dev libkf5notifyconfig-dev libkf5parts-dev \
  libkf5wallet-dev libkf5xmlgui-dev libodfgen-dev libpoppler-qt5-dev \
  libqca-qt5-2-dev libqt5opengl5-dev libqt5svg5-dev libqt5x11extras5-dev \
  librevenge-dev libwpd-dev libwpg-dev libwps-dev ninja-build pkg-config \
  sudo

# requirements for clazy
RUN apt-get install -y --no-install-recommends \
  clang llvm-dev libclang-3.8-dev

# build and install clazy
RUN git clone git://anongit.kde.org/clazy \
  && cd clazy \
  && cmake -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_BUILD_TYPE=Release -GNinja \
  && ninja install

# dependencies for development
RUN apt-get install -y --no-install-recommends \
  cmake-curses-gui \
  less vim strace qtcreator kdevelop valgrind gdb

USER neon
CMD ["/bin/bash", "-l"]

my Akademy presentation on Calligra.

Two versions of Calligra running in Docker containers
Two versions of Calligra running in Docker containers.

Helping contributors to get started

Getting started in KDE can be challenging. Docker images or Dockerfiles for complete development environments can get new contributors started more quickly. In KDE, neon already uses Docker images. Jonathan Riddell is giving a presentation about that this Akademy. Because this is so easy, I predict that we’ll see more Dockerfiles being published by KDE projects.

Comments

Post a comment

Lightweight than a virtual machine?

From the description, this seems to be more similar to the Python's virtualenv than a heavyweight virtual machine. Is my assumption correct?

If so, then Docker sounds like the best option for me. I want to test waters of KDE development before jumping in, but don't want to pollute my current stable setup of OpenSUSE Leap 42.3. However, development would likely require latest devel packages, which Leap may not provide.

Reply to this comment