-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile.layer2
More file actions
161 lines (139 loc) · 5.06 KB
/
Dockerfile.layer2
File metadata and controls
161 lines (139 loc) · 5.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
# Layer 2: C++ Bench Image
# Extends Layer 1 (devbench-base) with C++ specific tools
# Includes: GCC, Clang, CMake, vcpkg, Conan, debuggers, analyzers
# USER-AGNOSTIC: No user creation — Layer 3 handles user setup
FROM devbench-base:latest
# Container version labels
LABEL layer="2"
LABEL layer.name="cpp-bench"
LABEL layer.version="2.0.0"
LABEL layer.description="C++ development tools and compilers (user-agnostic)"
LABEL bench.type="cpp"
# Everything runs as root
USER root
# ========================================
# FIX APT SOURCES (Ubuntu mirror issues)
# ========================================
# Switch to mirrors that work (archive.ubuntu.com is returning 403)
RUN sed -i 's|http://archive.ubuntu.com/ubuntu|http://us.archive.ubuntu.com/ubuntu|g' /etc/apt/sources.list.d/ubuntu.sources 2>/dev/null || \
sed -i 's|http://archive.ubuntu.com/ubuntu|http://us.archive.ubuntu.com/ubuntu|g' /etc/apt/sources.list 2>/dev/null || true
RUN sed -i 's|http://security.ubuntu.com/ubuntu|http://security.ubuntu.com/ubuntu|g' /etc/apt/sources.list.d/ubuntu.sources 2>/dev/null || \
sed -i 's|http://security.ubuntu.com/ubuntu|http://security.ubuntu.com/ubuntu|g' /etc/apt/sources.list 2>/dev/null || true
# ========================================
# C++ COMPILERS AND BUILD TOOLS
# ========================================
# Install modern C++ compilers and build systems
RUN apt-get update && apt-get install -y \
# Build essentials
build-essential \
cmake \
ninja-build \
make \
autotools-dev \
automake \
autoconf \
libtool \
pkg-config \
# Archive tools (needed for vcpkg)
zip \
unzip \
tar \
curl \
# Modern GCC
gcc-12 \
g++-12 \
# Modern Clang/LLVM
clang-15 \
clang++-15 \
clang-tools-15 \
clang-tidy-15 \
clang-format-15 \
llvm-15 \
llvm-15-dev \
&& rm -rf /var/lib/apt/lists/*
# Set up compiler alternatives
RUN update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-12 100 \
&& update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-12 100 \
&& update-alternatives --install /usr/bin/clang clang /usr/bin/clang-15 100 \
&& update-alternatives --install /usr/bin/clang++ clang++ /usr/bin/clang++-15 100
# ========================================
# DEBUGGERS AND PROFILERS
# ========================================
RUN apt-get update && apt-get install -y \
gdb \
lldb \
valgrind \
strace \
ltrace \
linux-tools-generic \
heaptrack \
&& rm -rf /var/lib/apt/lists/*
# ========================================
# STATIC ANALYSIS AND FORMATTING TOOLS
# ========================================
RUN apt-get update && apt-get install -y \
cppcheck \
vera++ \
doxygen \
graphviz \
ccache \
mold \
iwyu \
&& rm -rf /var/lib/apt/lists/*
# ========================================
# C++ DEVELOPMENT LIBRARIES
# ========================================
RUN apt-get update && apt-get install -y \
libssl-dev \
libcurl4-openssl-dev \
libboost-all-dev \
libeigen3-dev \
libgtest-dev \
libgmock-dev \
libbenchmark-dev \
&& rm -rf /var/lib/apt/lists/*
# ========================================
# C++ PACKAGE MANAGERS
# ========================================
# Install vcpkg
RUN git clone https://github.com/Microsoft/vcpkg.git /opt/vcpkg \
&& cd /opt/vcpkg \
&& ./bootstrap-vcpkg.sh \
&& ln -s /opt/vcpkg/vcpkg /usr/local/bin/vcpkg
# Install Conan and related Python tools
RUN pip3 install --break-system-packages \
conan \
pre-commit \
cpplint \
cmake-format \
cmakelang \
lizard \
|| echo "⚠️ Some Python C++ tools failed, skipping"
# ========================================
# ENVIRONMENT SETUP
# ========================================
# Set up environment variables
ENV VCPKG_ROOT=/opt/vcpkg
ENV PATH="$VCPKG_ROOT:$PATH"
ENV CC=/usr/bin/gcc-12
ENV CXX=/usr/bin/g++-12
ENV PATH="/usr/lib/ccache:$PATH"
# ========================================
# SHELL CONFIGURATION (into /etc/skel)
# ========================================
# Add C++ development aliases and environment to /etc/skel/.zshrc
RUN echo '' >> /etc/skel/.zshrc && \
echo '# C++ Development Environment' >> /etc/skel/.zshrc && \
echo 'export VCPKG_ROOT=/opt/vcpkg' >> /etc/skel/.zshrc && \
echo 'export PATH="$PATH:/opt/vcpkg"' >> /etc/skel/.zshrc && \
echo 'export CC=/usr/bin/gcc-12' >> /etc/skel/.zshrc && \
echo 'export CXX=/usr/bin/g++-12' >> /etc/skel/.zshrc && \
echo '' >> /etc/skel/.zshrc && \
echo '# C++ Build aliases' >> /etc/skel/.zshrc && \
echo 'alias cmake-debug="cmake -DCMAKE_BUILD_TYPE=Debug"' >> /etc/skel/.zshrc && \
echo 'alias cmake-release="cmake -DCMAKE_BUILD_TYPE=Release"' >> /etc/skel/.zshrc && \
echo 'alias ninja-build="cmake --build . -- -j$(nproc)"' >> /etc/skel/.zshrc && \
echo 'alias cppclean="find . -name \"*.o\" -o -name \"*.a\" -o -name \"*.so\" | xargs rm -f"' >> /etc/skel/.zshrc && \
echo 'alias valgrind-leak="valgrind --leak-check=full --show-leak-kinds=all"' >> /etc/skel/.zshrc
# Default command
CMD ["sleep", "infinity"]