Skip to content

Commit a040dc2

Browse files
committed
Use custom user configuration values to influence package ID
1 parent 13963d4 commit a040dc2

File tree

3 files changed

+44
-11
lines changed

3 files changed

+44
-11
lines changed

docker/debian/Dockerfile

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ FROM base AS gcc
7171

7272
# These are not inherited from the base image.
7373
ARG DEBIAN_FRONTEND=noninteractive
74+
ARG DEBIAN_VERSION
7475
ARG GCC_VERSION
7576

7677
# Copy GCC from the source image, make the package manager aware of its
@@ -132,10 +133,14 @@ conan profile detect
132133
rm -rf /tmp/*
133134
EOF
134135

135-
# Explicitly set the compiler flags.
136+
# Explicitly set the compiler flags, as well as a custom flag that specifies the
137+
# distribution name and version. This is important to avoid conflicts between
138+
# builds using the same compiler but different distribution versions.
136139
RUN <<EOF
137140
cat >> $(conan config home)/global.conf <<EOT
138141
tools.build:compiler_executables={"c": "${CC}", "cpp": "${CXX}"}
142+
user.package:distro="debian-${DEBIAN_VERSION}"
143+
tools.info.package_id:confs=["user.package:distro"]
139144
EOT
140145
EOF
141146

@@ -154,8 +159,8 @@ EOF
154159
FROM base AS clang
155160

156161
# These are not inherited from the base image.
157-
ARG DEBIAN_VERSION
158162
ARG DEBIAN_FRONTEND=noninteractive
163+
ARG DEBIAN_VERSION
159164

160165
# Install Clang. Use the LLVM apt repository to access the latest versions. Some
161166
# build dependencies require GCC to be also available.
@@ -217,10 +222,14 @@ conan profile detect
217222
rm -rf /tmp/*
218223
EOF
219224

220-
# Explicitly set the compiler flags and the distribution name and version.
225+
# Explicitly set the compiler flags, as well as a custom flag that specifies the
226+
# distribution name and version. This is important to avoid conflicts between
227+
# builds using the same compiler but different distribution versions.
221228
RUN <<EOF
222229
cat >> $(conan config home)/global.conf <<EOT
223230
tools.build:compiler_executables={"c": "${CC}", "cpp": "${CXX}"}
231+
user.package:distro="debian-${DEBIAN_VERSION}"
232+
tools.info.package_id:confs=["user.package:distro"]
224233
EOT
225234
EOF
226235

docker/rhel/Dockerfile

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,12 +42,15 @@ RUN pip install --no-cache conan==${CONAN_VERSION} gcovr==${GCOVR_VERSION}
4242
# ====================== GCC IMAGE ======================
4343
FROM base AS gcc
4444

45+
# These are not inherited from the base image.
46+
ARG GCC_VERSION
47+
ARG RHEL_VERSION
48+
4549
# Install GCC. Red Hat installs GCC as a Software Collection (SCL) package,
4650
# where typically you would run `scl enable gcc-toolset-X` to open another Bash
4751
# shell with the GCC toolset enabled. To avoid having to do so, we delete the
4852
# default GCC packages first, and then reference the GCC toolset binaries
4953
# directly.
50-
ARG GCC_VERSION
5154
RUN <<EOF
5255
dnf remove -y gcc gcc-c++
5356
dnf install -y --setopt=tsflags=nodocs gcc-toolset-${GCC_VERSION}-gcc gcc-toolset-${GCC_VERSION}-gcc-c++
@@ -100,10 +103,14 @@ conan profile detect
100103
rm -rf /tmp/*
101104
EOF
102105

103-
# Explicitly set the compiler flags.
106+
# Explicitly set the compiler flags, as well as a custom flag that specifies the
107+
# distribution name and version. This is important to avoid conflicts between
108+
# builds using the same compiler but different distribution versions.
104109
RUN <<EOF
105110
cat >> $(conan config home)/global.conf <<EOT
106111
tools.build:compiler_executables={"c": "${CC}", "cpp": "${CXX}"}
112+
user.package:distro="rhel-${RHEL_VERSION}"
113+
tools.info.package_id:confs=["user.package:distro"]
107114
EOT
108115
EOF
109116

@@ -121,6 +128,9 @@ EOF
121128
# ===================== CLANG IMAGE =====================
122129
FROM base AS clang
123130

131+
# This is not inherited from the base image.
132+
ARG RHEL_VERSION
133+
124134
# Install Clang. Note that in the RHEL UBIs, we cannot choose the Clang version
125135
# to install and we get what is available. Some build dependencies require GCC
126136
# to be also available.
@@ -168,10 +178,14 @@ conan profile detect
168178
rm -rf /tmp/*
169179
EOF
170180

171-
# Explicitly set the compiler flags.
181+
# Explicitly set the compiler flags, as well as a custom flag that specifies the
182+
# distribution name and version. This is important to avoid conflicts between
183+
# builds using the same compiler but different distribution versions.
172184
RUN <<EOF
173185
cat >> $(conan config home)/global.conf <<EOT
174186
tools.build:compiler_executables={"c": "${CC}", "cpp": "${CXX}"}
187+
user.package:distro="rhel-${RHEL_VERSION}"
188+
tools.info.package_id:confs=["user.package:distro"]
175189
EOT
176190
EOF
177191

docker/ubuntu/Dockerfile

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -58,12 +58,13 @@ RUN pipx install --pip-args='--no-cache' conan==${CONAN_VERSION} && \
5858
# ====================== GCC IMAGE ======================
5959
FROM base AS gcc
6060

61-
# This is not inherited from the base image.
61+
# These are not inherited from the base image.
6262
ARG DEBIAN_FRONTEND=noninteractive
63+
ARG GCC_VERSION
64+
ARG UBUNTU_VERSION
6365

6466
# Install GCC and create the necessary symlinks. We only support packaging with
6567
# gcc because of the hard package dependencies from libtool to gcc
66-
ARG GCC_VERSION
6768
RUN <<EOF
6869
apt-get update
6970
apt-get install -y --no-install-recommends \
@@ -118,10 +119,14 @@ conan profile detect
118119
rm -rf /tmp/*
119120
EOF
120121

121-
# Explicitly set the compiler flags.
122+
# Explicitly set the compiler flags, as well as a custom flag that specifies the
123+
# distribution name and version. This is important to avoid conflicts between
124+
# builds using the same compiler but different distribution versions.
122125
RUN <<EOF
123126
cat >> $(conan config home)/global.conf <<EOT
124127
tools.build:compiler_executables={"c": "${CC}", "cpp": "${CXX}"}
128+
user.package:distro="ubuntu-${UBUNTU_VERSION}"
129+
tools.info.package_id:confs=["user.package:distro"]
125130
EOT
126131
EOF
127132

@@ -139,8 +144,9 @@ EOF
139144
# ===================== CLANG IMAGE =====================
140145
FROM base AS clang
141146

142-
# This is not inherited from the base image.
147+
# These are not inherited from the base image.
143148
ARG DEBIAN_FRONTEND=noninteractive
149+
ARG UBUNTU_VERSION
144150

145151
# Install Clang. Some build dependencies require GCC to be also available.
146152
ARG CLANG_VERSION
@@ -199,10 +205,14 @@ conan profile detect
199205
rm -rf /tmp/*
200206
EOF
201207

202-
# Explicitly set the compiler flags.
208+
# Explicitly set the compiler flags, as well as a custom flag that specifies the
209+
# distribution name and version. This is important to avoid conflicts between
210+
# builds using the same compiler but different distribution versions.
203211
RUN <<EOF
204212
cat >> $(conan config home)/global.conf <<EOT
205213
tools.build:compiler_executables={"c": "${CC}", "cpp": "${CXX}"}
214+
user.package:distro="ubuntu-${UBUNTU_VERSION}"
215+
tools.info.package_id:confs=["user.package:distro"]
206216
EOT
207217
EOF
208218

0 commit comments

Comments
 (0)