Skip to content

Commit 4ae51e0

Browse files
rprichardyuxuanchen1997
authored andcommitted
[libc++][Android] Fix Android bugs in the CI Dockerfile (#99623)
Summary: The base of android-buildkite-builder is buildkite-builder, not android-build-base. android-build-base is only used for its /opt/android directory, so move the Docker installation step into android-buildkite-builder. Install bzip2 for extracting ndk_platform.tar.bz2. Add "set -e" to RUN heredocs to catch failing commands. Test Plan: Reviewers: Subscribers: Tasks: Tags: Differential Revision: https://phabricator.intern.facebook.com/D60251028
1 parent e9eeeee commit 4ae51e0

File tree

2 files changed

+28
-16
lines changed

2 files changed

+28
-16
lines changed

libcxx/utils/ci/Dockerfile

Lines changed: 27 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ RUN sudo apt-get update \
106106
#RUN apt-get update && apt-get install -y ninja-build python3 python3-distutils python3-psutil git gdb ccache
107107
# TODO add ninja-build once 1.11 is available in Ubuntu, also remove the manual installation.
108108
RUN <<EOF
109+
set -e
109110
wget -qO /tmp/ninja.gz https://github.com/ninja-build/ninja/releases/latest/download/ninja-linux.zip
110111
gunzip /tmp/ninja.gz
111112
chmod a+x /tmp/ninja
@@ -115,6 +116,7 @@ EOF
115116

116117
# These two locales are not enabled by default so generate them
117118
RUN <<EOF
119+
set -e
118120
printf "fr_CA ISO-8859-1\ncs_CZ ISO-8859-2" | sudo tee -a /etc/locale.gen
119121
sudo mkdir /usr/local/share/i1en/
120122
printf "fr_CA ISO-8859-1\ncs_CZ ISO-8859-2" | sudo tee -a /usr/local/share/i1en/SUPPORTED
@@ -129,6 +131,7 @@ EOF
129131
# 14 release branch CI uses it. The tip-of-trunk CI will never use Clang 12,
130132
# though.
131133
RUN <<EOF
134+
set -e
132135
sudo apt-get update
133136
wget https://apt.llvm.org/llvm.sh -O /tmp/llvm.sh
134137
chmod +x /tmp/llvm.sh
@@ -142,6 +145,7 @@ EOF
142145

143146
# Install the most recent GCC, like clang install the previous version as a transition.
144147
RUN <<EOF
148+
set -e
145149
sudo git clone https://github.com/compiler-explorer/infra.git /tmp/ce-infra
146150
(cd /tmp/ce-infra && sudo make ce)
147151
sudo /tmp/ce-infra/bin/ce_install install compilers/c++/x86/gcc $GCC_LATEST_VERSION.1.0
@@ -155,13 +159,14 @@ EOF
155159

156160
RUN <<EOF
157161
# Install a recent CMake
162+
set -e
158163
wget https://github.com/Kitware/CMake/releases/download/v3.21.1/cmake-3.21.1-linux-x86_64.sh -O /tmp/install-cmake.sh
159164
sudo bash /tmp/install-cmake.sh --prefix=/usr --exclude-subdir --skip-license
160165
rm /tmp/install-cmake.sh
161166
EOF
162167

163168
# ===----------------------------------------------------------------------===##
164-
# Android Buildkite Image
169+
# Android Builder Base Image
165170
# ===----------------------------------------------------------------------===##
166171

167172
FROM ubuntu:jammy AS android-builder-base
@@ -170,10 +175,11 @@ ARG ANDROID_CLANG_VERSION
170175
ARG ANDROID_CLANG_PREBUILTS_COMMIT
171176
ARG ANDROID_SYSROOT_BID
172177

173-
RUN apt-get update && apt-get install -y curl unzip git
178+
RUN apt-get update && apt-get install -y curl bzip2 git unzip
174179

175180
# Install the Android platform tools (e.g. adb) into /opt/android/sdk.
176181
RUN <<EOF
182+
set -e
177183
mkdir -p /opt/android/sdk
178184
cd /opt/android/sdk
179185
curl -LO https://dl.google.com/android/repository/platform-tools-latest-linux.zip
@@ -187,6 +193,7 @@ EOF
187193
ENV ANDROID_CLANG_VERSION=$ANDROID_CLANG_VERSION
188194
ENV ANDROID_CLANG_PREBUILTS_COMMIT=$ANDROID_CLANG_PREBUILTS_COMMIT
189195
RUN <<EOF
196+
set -e
190197
git clone --filter=blob:none --sparse \
191198
https://android.googlesource.com/platform/prebuilts/clang/host/linux-x86 \
192199
/opt/android/clang
@@ -206,26 +213,14 @@ EOF
206213

207214
ENV ANDROID_SYSROOT_BID=$ANDROID_SYSROOT_BID
208215
RUN <<EOF
216+
set -e
209217
cd /opt/android
210218
curl -L -o ndk_platform.tar.bz2 \
211219
https://androidbuildinternal.googleapis.com/android/internal/build/v3/builds/${ANDROID_SYSROOT_BID}/ndk/attempts/latest/artifacts/ndk_platform.tar.bz2/url
212220
tar xf ndk_platform.tar.bz2
213221
rm ndk_platform.tar.bz2
214222
EOF
215223

216-
# Install Docker
217-
RUN <<EOF
218-
curl -fsSL https://get.docker.com -o /tmp/get-docker.sh
219-
sh /tmp/get-docker.sh
220-
rm /tmp/get-docker.sh
221-
222-
# Install Docker. Mark the binary setuid so it can be run without prefixing it
223-
# with sudo. Adding the container user to the docker group doesn't work because
224-
# /var/run/docker.sock is owned by the host's docker GID, not the container's
225-
# docker GID.
226-
chmod u+s /usr/bin/docker
227-
EOF
228-
229224
# ===----------------------------------------------------------------------===##
230225
# Buildkite Builder Image
231226
# ===----------------------------------------------------------------------===##
@@ -243,6 +238,7 @@ WORKDIR /home/libcxx-builder
243238
# Install the Buildkite agent and dependencies. This must be done as non-root
244239
# for the Buildkite agent to be installed in a path where we can find it.
245240
RUN <<EOF
241+
set -e
246242
cd /home/libcxx-builder
247243
curl -sL https://raw.githubusercontent.com/buildkite/agent/main/install.sh -o /tmp/install-agent.sh
248244
bash /tmp/install-agent.sh
@@ -271,6 +267,22 @@ COPY ./vendor/android/container-setup.sh /opt/android/container-setup.sh
271267

272268
ENV PATH="/opt/android/sdk/platform-tools:${PATH}"
273269

270+
USER root
271+
272+
# Install Docker
273+
RUN <<EOF
274+
set -e
275+
curl -fsSL https://get.docker.com -o /tmp/get-docker.sh
276+
sh /tmp/get-docker.sh
277+
rm /tmp/get-docker.sh
278+
279+
# Install Docker. Mark the binary setuid so it can be run without prefixing it
280+
# with sudo. Adding the container user to the docker group doesn't work because
281+
# /var/run/docker.sock is owned by the host's docker GID, not the container's
282+
# docker GID.
283+
chmod u+s /usr/bin/docker
284+
EOF
285+
274286
USER libcxx-builder
275287
WORKDIR /home/libcxx-builder
276288

libcxx/utils/ci/vendor/android/run-buildbot-container

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,5 +27,5 @@ if [ -S /var/run/docker.sock ]; then
2727
DOCKER_OPTIONS+=(--volume /var/run/docker.sock:/var/run/docker.sock)
2828
fi
2929

30-
docker run "${DOCKER_OPTIONS[@]}" libcxx-builder-android \
30+
docker run "${DOCKER_OPTIONS[@]}" ghcr.io/libcxx/android-buildkite-builder \
3131
bash -c 'git config --global --add safe.directory /llvm; (/opt/android/container-setup.sh && exec bash)'

0 commit comments

Comments
 (0)