1- FROM ubuntu:bionic
1+ # [Choice] bionic (18.04), focal (20.04)
2+ ARG VARIANT="focal"
3+ FROM ubuntu:${VARIANT}
24
3- # Install packages available from standard repos
4- RUN apt-get update -qq && \
5+ # Restate the variant to use it later on in the llvm and cmake installations
6+ ARG VARIANT
7+
8+ # Install necessary packages available from standard repos
9+ RUN apt-get update -qq && export DEBIAN_FRONTEND=noninteractive && \
510 apt-get install -y --no-install-recommends \
6- software-properties-common wget git gpg-agent file \
7- python3 python3-pip doxygen graphviz ccache cppcheck build-essential \
8- neovim emacs nano
11+ software-properties-common wget apt-utils file zip \
12+ openssh-client gpg-agent socat rsync \
13+ make ninja-build git \
14+ python3 python3-pip
915
1016# Install conan
1117RUN python3 -m pip install --upgrade pip setuptools && \
1218 python3 -m pip install conan && \
1319 conan --version
1420
21+ # By default, anything you run in Docker is done as superuser.
22+ # Conan runs some install commands as superuser, and will prepend `sudo` to
23+ # these commands, unless `CONAN_SYSREQUIRES_SUDO=0` is in your env variables.
24+ ENV CONAN_SYSREQUIRES_SUDO 0
25+ # Some packages request that Conan use the system package manager to install
26+ # a few dependencies. This flag allows Conan to proceed with these installations;
27+ # leaving this flag undefined can cause some installation failures.
28+ ENV CONAN_SYSREQUIRES_MODE enabled
29+
1530# User-settable versions:
16- # This Dockerfile should support gcc-[7, 8, 9, 10] and clang-[10, 11]
31+ # This Dockerfile should support gcc-[7, 8, 9, 10, 11 ] and clang-[10, 11, 12, 13 ]
1732# Earlier versions of clang will require significant modifications to the IWYU section
18- ARG GCC_VER="10"
19- ARG LLVM_VER="11"
20-
33+ ARG GCC_VER="11"
2134# Add gcc-${GCC_VER}
2235RUN add-apt-repository -y ppa:ubuntu-toolchain-r/test && \
23- apt-get update -qq && \
24- apt-get install -y --no-install-recommends gcc-${GCC_VER} g++-${GCC_VER}
36+ apt-get update -qq && export DEBIAN_FRONTEND=noninteractive && \
37+ apt-get install -y --no-install-recommends \
38+ gcc-${GCC_VER} g++-${GCC_VER} gdb
39+
40+ # Set gcc-${GCC_VER} as default gcc
41+ RUN update-alternatives --install /usr/bin/gcc gcc $(which gcc-${GCC_VER}) 100
42+ RUN update-alternatives --install /usr/bin/g++ g++ $(which g++-${GCC_VER}) 100
2543
44+ ARG LLVM_VER="13"
2645# Add clang-${LLVM_VER}
46+ ARG LLVM_URL="http://apt.llvm.org/${VARIANT}/"
47+ ARG LLVM_PKG="llvm-toolchain-${VARIANT}-${LLVM_VER}"
2748RUN wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | apt-key add - 2>/dev/null && \
28- add-apt-repository -y "deb http://apt.llvm.org/bionic/ llvm-toolchain-bionic-${LLVM_VER } main" && \
29- apt-get update -qq && \
49+ add-apt-repository -y "deb ${LLVM_URL} ${LLVM_PKG } main" && \
50+ apt-get update -qq && export DEBIAN_FRONTEND=noninteractive && \
3051 apt-get install -y --no-install-recommends \
3152 clang-${LLVM_VER} lldb-${LLVM_VER} lld-${LLVM_VER} clangd-${LLVM_VER} \
3253 llvm-${LLVM_VER}-dev libclang-${LLVM_VER}-dev clang-tidy-${LLVM_VER}
3354
55+ # Set the default clang-tidy, so CMake can find it
56+ RUN update-alternatives --install /usr/bin/clang-tidy clang-tidy $(which clang-tidy-${LLVM_VER}) 1
57+
58+ # Set clang-${LLVM_VER} as default clang
59+ RUN update-alternatives --install /usr/bin/clang clang $(which clang-${LLVM_VER}) 100
60+ RUN update-alternatives --install /usr/bin/clang++ clang++ $(which clang++-${LLVM_VER}) 100
61+
3462# Add current cmake/ccmake, from Kitware
63+ ARG CMAKE_URL="https://apt.kitware.com/ubuntu/"
64+ ARG CMAKE_PKG=${VARIANT}
3565RUN wget -O - https://apt.kitware.com/keys/kitware-archive-latest.asc 2>/dev/null \
3666 | gpg --dearmor - | tee /etc/apt/trusted.gpg.d/kitware.gpg >/dev/null && \
37- apt-add-repository ' deb https://apt.kitware.com/ubuntu/ bionic main' && \
38- apt-get update -qq && \
67+ apt-add-repository -y " deb ${CMAKE_URL} ${CMAKE_PKG} main" && \
68+ apt-get update -qq && export DEBIAN_FRONTEND=noninteractive && \
3969 apt-get install -y --no-install-recommends cmake cmake-curses-gui
4070
41- # Set the default clang-tidy, so CMake can find it
42- RUN update-alternatives --install /usr/bin/clang-tidy clang-tidy $(which clang-tidy-${LLVM_VER}) 1
71+ # Install editors
72+ RUN apt-get update -qq && export DEBIAN_FRONTEND=noninteractive && \
73+ apt-get install -y --no-install-recommends \
74+ neovim emacs nano
75+
76+ # Install optional dependecies
77+ RUN apt-get update -qq && export DEBIAN_FRONTEND=noninteractive && \
78+ apt-get install -y --no-install-recommends \
79+ doxygen graphviz ccache cppcheck
4380
4481# Install include-what-you-use
4582ENV IWYU /home/iwyu
@@ -64,16 +101,8 @@ RUN ln -s $(readlink -f /usr/lib/clang/${LLVM_VER}/include) \
64101 $(include-what-you-use -print-resource-dir 2>/dev/null)/include
65102
66103# # Cleanup cached apt data we don't need anymore
67- # RUN apt-get clean && \
68- # rm -rf /var/lib/apt/lists/*
69-
70- # Set gcc-${GCC_VER} as default gcc
71- RUN update-alternatives --install /usr/bin/gcc gcc $(which gcc-${GCC_VER}) 100
72- RUN update-alternatives --install /usr/bin/g++ g++ $(which g++-${GCC_VER}) 100
73-
74- # Set clang-${LLVM_VER} as default clang
75- RUN update-alternatives --install /usr/bin/clang clang $(which clang-${LLVM_VER}) 100
76- RUN update-alternatives --install /usr/bin/clang++ clang++ $(which clang++-${LLVM_VER}) 100
104+ RUN apt-get autoremove -y && apt-get clean && \
105+ rm -rf /var/lib/apt/lists/*
77106
78107# Allow the user to set compiler defaults
79108ARG USE_CLANG
@@ -84,17 +113,8 @@ ENV CXX=${USE_CLANG:+"clang++"}
84113ENV CC=${CC:-"gcc" }
85114ENV CXX=${CXX:-"g++" }
86115
87- # By default, anything you run in Docker is done as superuser.
88- # Conan runs some install commands as superuser, and will prepend `sudo` to
89- # these commands, unless `CONAN_SYSREQUIRES_SUDO=0` is in your env variables.
90- ENV CONAN_SYSREQUIRES_SUDO 0
91- # Some packages request that Conan use the system package manager to install
92- # a few dependencies. This flag allows Conan to proceed with these installations;
93- # leaving this flag undefined can cause some installation failures.
94- ENV CONAN_SYSREQUIRES_MODE enabled
95-
96116# Include project
97- ADD . /starter_project
98- WORKDIR /starter_project
117+ # ADD . /workspaces/cpp_starter_project
118+ # WORKDIR /workspaces/cpp_starter_project
99119
100120CMD ["/bin/bash" ]
0 commit comments