Appendix B — Docker Container

This book and others which target hands-on developers contain numerous code examples. Container technology (https://en.wikipedia.org/wiki/Open_Container_Initiative) is an effective tool to distribute the corpus of software libraries and examples to enable students to replicate the results on their own infrastructure. In order to experiment with e.g. MQTT support outlined elsewhere in this book, a container with all the prerequisites can be and is made available.

In fact a container is made available that installs, builds the entire toolkit discussed extensively in this book. Also included are all the examples.

B.1 Learning Objectives

  • Replicating all the examples in this book

B.2 Toolkit Container

The only prerequisites for the toolkit are the compilation system and the library manager alire. Assuming the compiler system is installed the following specifications performs the basic preparatory steps:

~/bin/codemd ../../toolkit/examples/containers/docker/Dockerfile -x AlireBuild -l
0034 | WORKDIR /projects
0035 | RUN git clone --recurse-submodules https://github.com/alire-project/alire.git
0036 | RUN cd alire; dev/build.sh ; cp bin/alr /bin
0037 | RUN alr toolchain --disable-assistant

Once alire is build and made available, the library and all the examples are built:

~/bin/codemd ../../toolkit/examples/containers/docker/Dockerfile -x Toolkit -l
0041 | RUN git clone https://gitlab.com/ada23/codemd.git
0042 | RUN cd codemd; alr build; cp bin/codemd /usr/local/toolkit/bin
0043 | RUN git clone https://gitlab.com/ada23/toolkit.git
0044 | RUN cd toolkit/adalib; alr build
0045 | RUN cd toolkit/examples/;  ./build.sh; cp bin/* /usr/local/toolkit/bin
0046 | 
0047 | RUN git clone https://gitlab.com/RajaSrinivasan/TechAdaBook.git
0048 | RUN cd TechAdaBook/Prj; ./build.sh; cp bin/* /usr/local/toolkit/bin
0049 | ENV PATH /usr/local/toolkit/bin:$PATH

The container image can then be produced resulting in an Ubuntu based image:

docker build --no-cache -t toolkit:latest .

The image can now be accessed:

docker run -it toolkit:latest bash

thus enabling access.

B.3 Stretch

B.4 Sample Implementation

Repository: toolkit
Directory: examples/containers/docker
Repository: adamosquitto
Directory: examples/docker