Skip to content

Commit fa7a36e

Browse files
committed
docker/debian: Add separate GCC layer
Signed-off-by: Ryan Northey <[email protected]>
1 parent 5710750 commit fa7a36e

File tree

5 files changed

+36
-7
lines changed

5 files changed

+36
-7
lines changed

docker/linux/common_fun.sh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,9 @@ install_build_tools () {
3232

3333
install_build () {
3434
setup_tcpdump
35-
install_build_tools
35+
if [[ -z "${NO_INSTALL_BUILDTOOLS}" ]]; then
36+
install_build_tools
37+
fi
3638
git config --global --add safe.directory /source
3739
mv ~/.gitconfig /etc/gitconfig
3840
}

docker/linux/debian/Dockerfile

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,18 @@ COPY debian/entrypoint.sh /entrypoint.sh
3434
ENTRYPOINT ["/entrypoint.sh"]
3535

3636

37+
# This can be removed if/when we implement hermetic gcc toolchains
38+
FROM worker-base AS gcc-base
39+
RUN --mount=type=tmpfs,target=/var/cache/apt \
40+
--mount=type=tmpfs,target=/var/lib/apt/lists \
41+
--mount=type=bind,source=/common_fun.sh,target=/common_fun.sh \
42+
--mount=type=bind,source=/debian/fun.sh,target=/debian/fun.sh \
43+
. ./debian/fun.sh \
44+
&& install_gcc
45+
COPY debian/entrypoint.sh /entrypoint.sh
46+
ENTRYPOINT ["/entrypoint.sh"]
47+
48+
3749
FROM ci-base AS docker-base
3850
ARG APT_KEY_K8S=https://download.opensuse.org/repositories/devel:kubic:libcontainers:stable/Debian_Testing/Release.key \
3951
APT_KEY_DOCKER=https://download.docker.com/linux/debian/gpg
@@ -108,6 +120,13 @@ RUN --mount=type=bind,source=/common_fun.sh,target=/common_fun.sh \
108120
. ./debian/fun.sh \
109121
&& stamp_build worker "$CONTAINER_TAG"
110122

123+
FROM gcc-base AS gcc
124+
ARG CONTAINER_TAG
125+
RUN --mount=type=bind,source=/common_fun.sh,target=/common_fun.sh \
126+
--mount=type=bind,source=/debian/fun.sh,target=/debian/fun.sh \
127+
. ./debian/fun.sh \
128+
&& stamp_build gcc "$CONTAINER_TAG"
129+
111130
FROM docker-base AS docker
112131
ARG CONTAINER_TAG
113132
RUN --mount=type=bind,source=/common_fun.sh,target=/common_fun.sh \

docker/linux/debian/fun.sh

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ DEBIAN_PACKAGES=(
2121
docker-ce-cli
2222
doxygen
2323
expect
24-
g++-13
2524
gdb
2625
git
2726
gnupg2
@@ -159,7 +158,10 @@ install_devel () {
159158

160159
apt_install "${DEV_PACKAGES[@]}"
161160
apt-get -qq dist-upgrade -y
162-
update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-13 1
161+
install_gcc
162+
163+
# not sure if this is necessary
164+
export NO_INSTALL_BUILDTOOLS=1
163165
install_build
164166

165167
echo "Development tools installation completed - compilers provided by toolchains"
@@ -171,6 +173,12 @@ install () {
171173
create_user
172174
}
173175

176+
install_gcc () {
177+
apt-get -qq update -y
178+
apt-get -qq install -y g++-13
179+
update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-13 1
180+
}
181+
174182
install_bazelisk () {
175183
apt-get -qq update
176184
apt-get -qq install -y --no-install-recommends wget

docker/linux/debian_build.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
set -o pipefail
44

55
# Debian-specific build configuration
6-
DEBIAN_DOCKER_VARIANTS=("worker" "ci" "devtools" "docker" "llvm" "mobile" "test")
6+
DEBIAN_DOCKER_VARIANTS=("worker" "ci" "gcc" "devtools" "docker" "llvm" "mobile" "test")
77
IMAGE_TAGS=${IMAGE_TAGS:-}
88
OS_DISTRO="debian"
99

@@ -57,8 +57,8 @@ build_and_push_variants () {
5757
push_arg+=(--push)
5858
fi
5959

60-
# Platform logic: worker, ci, devtools, docker and test get multi-arch, others get amd64 only
61-
if [[ "$variant" == "test" || "$variant" == "ci" || "$variant" == "docker" || "$variant" == "worker" || "$variant" == "devtools" ]]; then
60+
# Platform logic: worker, ci, gcc, devtools, docker and test get multi-arch, others get amd64 only
61+
if [[ "$variant" == "test" || "$variant" == "ci" || "$variant" == "gcc" || "$variant" == "docker" || "$variant" == "worker" || "$variant" == "devtools" ]]; then
6262
platform="${BUILD_TOOLS_PLATFORMS}"
6363
elif [[ "$BUILD_TOOLS_PLATFORMS" == *"linux/amd64"* ]]; then
6464
# devtools and mobile are amd64 only (matching original behavior for full/mobile)

docker/linux/group_manifests.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ if [[ -z "$TAG_SHA" ]]; then
88
TAG_SHA="$(git log -1 --pretty=format:"%H" .)"
99
fi
1010

11-
VARIANTS=(ci worker devtools docker llvm mobile test)
11+
VARIANTS=(ci worker gcc devtools docker llvm mobile test)
1212
ARCHES=(amd64 arm64)
1313

1414
exists () {

0 commit comments

Comments
 (0)