Programming mode Docker container
Idea
It is handy to always have a container ready to be spinned in case we find ourselves in a new environment and need to do some quick debugging.
Dockerfile
Build the container on top of Debian is the way to go, Debian is better than alpine in this case because we may need to interact with the layer just above the hypervisor.
FROM debian:bullseye
RUN apt update && apt upgrade -y
Install compilers and debuggers.
RUN apt install -y git vim wget bzip2 flex bison build-essential gcc g++ gdb \
lsb-release software-properties-common gnupg cmake valgrind \
libncurses5-dev libncursesw5-dev cmake-curses-gui cppcheck manpages-dev
RUN wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | apt-key add -
RUN add-apt-repository "deb http://apt.llvm.org/unstable/ llvm-toolchain-11 main"
RUN apt update && apt install -y clang-11 lldb-11 lld-11 clangd-11
Expose clang through the alias.
RUN ln -sf /usr/bin/clang-11 /usr/bin/clang
RUN ln -sf /usr/bin/clang++-11 /usr/bin/clang++
RUN ln -sf /usr/bin/clangd-11 /usr/bin/clangd
RUN ln -sf /usr/bin/clang-cpp-11 /usr/bin/clang-cpp
RUN ln -sf /usr/bin/lldb-11 /usr/bin/lldb
Clean up to remove useless caches from the image.
RUN apt-get clean && apt-get autoclean && apt-get autoremove
Separate the work in a new directory in order to map it from the command line.
RUN mkdir workspace
WORKDIR workspace
Finally, set the command to start.
CMD ["bash"]