Creating OpenWrt Docker Test Environment - C/C++ + CMake

Hi there,

I search an easy way for using an OpenWRT docker container as host/test environment for my C/C++ daemons.

The advantages shall be:

  1. not to build a complete firmware, but only the new services.
  2. to have OpenWRT system services like ubus available.

The core idea is that I write a very simple Dockerfile, in which I set up an OpenWRT Docker container, integrate the required build environment into it, as well as copy the necessary .c/.cpp/.h files to the system, then build it into an application afterwards via CMake and gcc.

For other systems like Ubuntu, this path already exists:
https://blog.totalcross.com/docker-basics-cross-compiling-a-cmake-project-642001240b6f

In Ubuntu, my Dockerfile would look like this:

FROM ubuntu

RUN apt-get update && apt-get install -y libopencv-dev

WORKDIR src

RUN apt-get update && \
    apt-get upgrade -y && \
    apt-get install -y subversion && \
	apt-get install -y build-essential && \
	apt-get install -y cmake
# apt-get install -y git	

# RUN git clone https://github.com/Demo.git

RUN cmake .. ...
RUN make
RUN make install

However, with OpenWRT I have the following problems:

  • apt packet manager does not exist
  • opkg does not recognize build-essential, subversion, git and cmake as packages

Since all projects at our company rely on a combination of CMake and Makefiles, I would like to change as little as possible in customizations of CMake and Makefiles, it would be very helpful to have CMake installable as a package.

The idea is simple: in the Dockerfile all data of a certain folder should be copied into a Docker container, then compiled there according to a CMakeList file and then a library or daemon should be installed in a corresponding folder.

Without CMake, however, I can't get any further ...

Has anyone started a similar project?
Does anyone have experience installing CMake, gcc, gdb and co. on an OpenWRT system?

I am open for any suggestion!

Thanks a lot already!
Matthias

OpenWrt is not a self-hosting system so you can’t really extend some OpenWrt rootfs, install a toolchain and compile away. You will need to cross compile.