Skip to content

Commit 1a62b69

Browse files
authored
Add debhelper to base images (#17)
Add `debhelper` to Ubuntu `gcc` image, document packaging support for various images.
1 parent e834dd5 commit 1a62b69

File tree

7 files changed

+56
-20
lines changed

7 files changed

+56
-20
lines changed

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@ of environments and using different C++ compilers.
1515
[Debian instructions](docker/debian/README.md)
1616
[RHEL instructions](docker/rhel/README.md)
1717

18+
### Packaging
19+
20+
Only some of the container images provided support packaging.
21+
1822
## Tools images
1923

2024
Aside from build images, XRPLF projects also use container images with specialized tools, e.g.

docker/debian/Dockerfile

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -167,11 +167,19 @@ apt-get update
167167
apt-get install -t llvm-toolchain-${DEBIAN_VERSION}-${CLANG_VERSION} -y --no-install-recommends clang-${CLANG_VERSION} llvm-${CLANG_VERSION}
168168
apt-get clean
169169
rm -rf /var/lib/apt/lists/*
170+
update-alternatives --install /usr/bin/cc cc /usr/bin/clang-${CLANG_VERSION} 999
171+
update-alternatives --install \
172+
/usr/bin/clang clang /usr/bin/clang-${CLANG_VERSION} 100 \
173+
--slave /usr/bin/clang++ clang++ /usr/bin/clang++-${CLANG_VERSION}
174+
update-alternatives --install \
175+
/usr/bin/llvm-cov llvm-cov /usr/bin/llvm-cov-${CLANG_VERSION} 100
176+
update-alternatives --auto cc
177+
update-alternatives --auto clang
178+
update-alternatives --auto llvm-cov
170179
EOF
180+
171181
ENV CC=/usr/bin/clang-${CLANG_VERSION}
172182
ENV CXX=/usr/bin/clang++-${CLANG_VERSION}
173-
# This is required by some build dependencies
174-
RUN update-alternatives --install /usr/bin/cc cc $CC 999
175183

176184
# Check that the installed Clang version matches the expected version.
177185
RUN <<EOF

docker/debian/README.md

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,15 @@ versions by specifying the `DEBIAN_VERSION` build argument. There are additional
2929
arguments to specify as well, namely `GCC_VERSION` for the GCC flavor and
3030
`CLANG_VERSION` for the Clang flavor.
3131

32-
Run the commands below from the root directory of the repository.
32+
None of the build images support packaging, since (in order to be access the most
33+
recent official releases) the compilers are installed from external sources:
3334

34-
#### Building the Docker image for GCC.
35+
* [gcc Docker Official Image](https://hub.docker.com/_/gcc)
36+
* [LLVM Debian/Ubuntu nightly packages](https://apt.llvm.org/)
37+
38+
In order to build an image, run the commands below from the root directory of the repository.
39+
40+
#### Building the Docker image for GCC
3541

3642
Ensure you've run the login command above to authenticate with the Docker
3743
registry.
@@ -55,7 +61,7 @@ docker buildx build . \
5561
--tag ${CONTAINER_REGISTRY}/${CONTAINER_IMAGE}
5662
```
5763

58-
#### Building the Docker image for Clang.
64+
#### Building the Docker image for Clang
5965

6066
Ensure you've run the login command above to authenticate with the Docker
6167
registry.

docker/rhel/Dockerfile

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,12 +54,14 @@ dnf clean -y all
5454
rm -rf /var/cache/dnf/*
5555
update-alternatives --install /usr/bin/cc cc /opt/rh/gcc-toolset-${GCC_VERSION}/root/usr/bin/gcc 999
5656
update-alternatives \
57-
--install /usr/bin/gcc gcc /opt/rh/gcc-toolset-${GCC_VERSION}/root/usr/bin/gcc ${GCC_VERSION} \
57+
--install /usr/bin/gcc gcc /opt/rh/gcc-toolset-${GCC_VERSION}/root/usr/bin/gcc 100 \
5858
--slave /usr/bin/g++ g++ /opt/rh/gcc-toolset-${GCC_VERSION}/root/usr/bin/g++ \
5959
--slave /usr/bin/cpp cpp /opt/rh/gcc-toolset-${GCC_VERSION}/root/usr/bin/cpp \
6060
--slave /usr/bin/gcov gcov /opt/rh/gcc-toolset-${GCC_VERSION}/root/usr/bin/gcov \
6161
--slave /usr/bin/gcov-dump gcov-dump /opt/rh/gcc-toolset-${GCC_VERSION}/root/usr/bin/gcov-dump-${GCC_VERSION} \
6262
--slave /usr/bin/gcov-tool gcov-tool /opt/rh/gcc-toolset-${GCC_VERSION}/root/usr/bin/gcov-tool-${GCC_VERSION}
63+
update-alternatives --auto cc
64+
update-alternatives --auto gcc
6365
EOF
6466
ENV CC=/usr/bin/gcc
6567
ENV CXX=/usr/bin/g++
@@ -139,11 +141,12 @@ RUN <<EOF
139141
dnf install -y --setopt=tsflags=nodocs clang llvm
140142
dnf clean -y all
141143
rm -rf /var/cache/dnf/*
144+
update-alternatives --install /usr/bin/cc cc /usr/bin/clang 999
145+
update-alternatives --auto cc
142146
EOF
147+
143148
ENV CC=/usr/bin/clang
144149
ENV CXX=/usr/bin/clang++
145-
# This is required by some build dependencies
146-
RUN update-alternatives --install /usr/bin/cc cc $CC 999
147150

148151
# Check that the installed Clang version is not older than the minimum required.
149152
ARG MINIMUM_CLANG_VERSION=16

docker/rhel/README.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,11 @@ versions by specifying the `RHEL_VERSION` build argument. There are additional
4848
arguments to specify as well, namely `GCC_VERSION` for the GCC flavor and
4949
`CLANG_VERSION` for the Clang flavor.
5050

51-
Run the commands below from the root directory of the repository.
51+
Both build images for `gcc` and `clang` support packaging.
5252

53-
#### Building the Docker image for GCC.
53+
In order to build an image, run the commands below from the root directory of the repository.
54+
55+
#### Building the Docker image for GCC
5456

5557
Ensure you've run the login command above to authenticate with the Docker
5658
registry.
@@ -74,7 +76,7 @@ docker buildx build . \
7476
--tag ${CONTAINER_REGISTRY}/${CONTAINER_IMAGE}
7577
```
7678

77-
#### Building the Docker image for Clang.
79+
#### Building the Docker image for Clang
7880

7981
Ensure you've run the login command above to authenticate with the Docker
8082
registry.

docker/ubuntu/Dockerfile

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -60,23 +60,26 @@ FROM base AS gcc
6060
# This is not inherited from base image, ensure no manual interaction needed.
6161
ARG DEBIAN_FRONTEND=noninteractive
6262

63-
# Install GCC and create the necessary symlinks.
63+
# Install GCC and create the necessary symlinks. We only support packaging with
64+
# gcc because of the hard package dependencies from libtool to gcc
6465
ARG GCC_VERSION
6566
RUN <<EOF
6667
apt-get update
6768
apt-get install -y --no-install-recommends \
6869
gcc-${GCC_VERSION} \
69-
g++-${GCC_VERSION}
70+
g++-${GCC_VERSION} \
71+
debhelper
7072
apt-get clean
7173
rm -rf /var/lib/apt/lists/*
7274
update-alternatives --install /usr/bin/cc cc /usr/bin/gcc-${GCC_VERSION} 999
7375
update-alternatives \
74-
--install /usr/bin/gcc gcc /usr/bin/gcc-${GCC_VERSION} ${GCC_VERSION} \
76+
--install /usr/bin/gcc gcc /usr/bin/gcc-${GCC_VERSION} 100 \
7577
--slave /usr/bin/g++ g++ /usr/bin/g++-${GCC_VERSION} \
76-
--slave /usr/bin/cpp cpp /usr/bin/cpp-${GCC_VERSION} \
7778
--slave /usr/bin/gcov gcov /usr/bin/gcov-${GCC_VERSION} \
7879
--slave /usr/bin/gcov-dump gcov-dump /usr/bin/gcov-dump-${GCC_VERSION} \
7980
--slave /usr/bin/gcov-tool gcov-tool /usr/bin/gcov-tool-${GCC_VERSION}
81+
update-alternatives --auto cc
82+
update-alternatives --auto gcc
8083
EOF
8184
ENV CC=/usr/bin/gcc
8285
ENV CXX=/usr/bin/g++
@@ -161,11 +164,19 @@ apt-get install -y --no-install-recommends \
161164
llvm-${CLANG_VERSION}
162165
apt-get clean
163166
rm -rf /var/lib/apt/lists/*
167+
update-alternatives --install /usr/bin/cc cc /usr/bin/clang-${CLANG_VERSION} 999
168+
update-alternatives --install \
169+
/usr/bin/clang clang /usr/bin/clang-${CLANG_VERSION} 100 \
170+
--slave /usr/bin/clang++ clang++ /usr/bin/clang++-${CLANG_VERSION}
171+
update-alternatives --install \
172+
/usr/bin/llvm-cov llvm-cov /usr/bin/llvm-cov-${CLANG_VERSION} 100
173+
update-alternatives --auto cc
174+
update-alternatives --auto clang
175+
update-alternatives --auto llvm-cov
164176
EOF
177+
165178
ENV CC=/usr/bin/clang-${CLANG_VERSION}
166179
ENV CXX=/usr/bin/clang++-${CLANG_VERSION}
167-
# This is required by some build dependencies
168-
RUN update-alternatives --install /usr/bin/cc cc $CC 999
169180

170181
# Check that the installed Clang version matches the expected version.
171182
RUN <<EOF

docker/ubuntu/README.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,11 @@ future versions by specifying the `UBUNTU_VERSION` build argument. There are
2929
additional arguments to specify as well, namely `GCC_VERSION` for the GCC flavor
3030
and `CLANG_VERSION` for the Clang flavor.
3131

32-
Run the commands below from the root directory of the repository.
32+
Build image for `gcc` supports packaging.
3333

34-
#### Building the Docker image for GCC.
34+
In order to build an image, run the commands below from the root directory of the repository.
35+
36+
#### Building the Docker image for GCC
3537

3638
Ensure you've run the login command above to authenticate with the Docker
3739
registry.
@@ -55,7 +57,7 @@ docker buildx build . \
5557
--tag ${CONTAINER_REGISTRY}/${CONTAINER_IMAGE}
5658
```
5759

58-
#### Building the Docker image for Clang.
60+
#### Building the Docker image for Clang
5961

6062
Ensure you've run the login command above to authenticate with the Docker
6163
registry.

0 commit comments

Comments
 (0)