Skip to content

Commit 887637c

Browse files
author
DongRyeol Cha
authored
build: Fix that custom docker image build (#12564)
* build: Fix that custom docker image build The do_ci.sh builds the envoy and copies binary to under build-* directories. But recently, the arm64 build system was added but it does not consider the previous custom docker image build. It is very useful to build the custom docker image and test it within k8s environment. So, this patch support previous behavior again so that we can build the custom docker image. If some more cpu architectures are added, we can simple extends more cpu architectures. Signed-off-by: DongRyeol Cha <[email protected]>
1 parent 9ad7d4c commit 887637c

File tree

4 files changed

+23
-10
lines changed

4 files changed

+23
-10
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
/bazel-*
22
BROWSE
33
/build
4-
/build_*
54
*.bzlc
65
.cache
76
.clangd
@@ -34,3 +33,4 @@ clang.bazelrc
3433
user.bazelrc
3534
CMakeLists.txt
3635
cmake-build-debug
36+
/linux

ci/build_setup.sh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,10 @@ export PPROF_PATH=/thirdparty_build/bin/pprof
99
[ -z "${NUM_CPUS}" ] && NUM_CPUS=`grep -c ^processor /proc/cpuinfo`
1010
[ -z "${ENVOY_SRCDIR}" ] && export ENVOY_SRCDIR=/source
1111
[ -z "${ENVOY_BUILD_TARGET}" ] && export ENVOY_BUILD_TARGET=//source/exe:envoy-static
12+
[ -z "${ENVOY_BUILD_ARCH}" ] && export ENVOY_BUILD_ARCH=$(uname -m)
1213
echo "ENVOY_SRCDIR=${ENVOY_SRCDIR}"
1314
echo "ENVOY_BUILD_TARGET=${ENVOY_BUILD_TARGET}"
15+
echo "ENVOY_BUILD_ARCH=${ENVOY_BUILD_ARCH}"
1416

1517
function setup_gcc_toolchain() {
1618
if [[ ! -z "${ENVOY_STDLIB}" && "${ENVOY_STDLIB}" != "libstdc++" ]]; then
@@ -83,7 +85,7 @@ export BAZEL_BUILD_OPTIONS=" ${BAZEL_OPTIONS} --verbose_failures --show_task_fin
8385
--test_output=errors --repository_cache=${BUILD_DIR}/repository_cache --experimental_repository_cache_hardlinks \
8486
${BAZEL_BUILD_EXTRA_OPTIONS} ${BAZEL_EXTRA_TEST_OPTIONS}"
8587

86-
[[ "$(uname -m)" == "aarch64" ]] && BAZEL_BUILD_OPTIONS="${BAZEL_BUILD_OPTIONS} --test_env=HEAPCHECK="
88+
[[ "${ENVOY_BUILD_ARCH}" == "aarch64" ]] && BAZEL_BUILD_OPTIONS="${BAZEL_BUILD_OPTIONS} --test_env=HEAPCHECK="
8789

8890
[[ "${BAZEL_EXPUNGE}" == "1" ]] && bazel clean --expunge
8991

ci/do_ci.sh

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,17 @@ SRCDIR="${PWD}"
1616
. "$(dirname "$0")"/build_setup.sh $build_setup_args
1717
cd "${SRCDIR}"
1818

19+
if [[ "${ENVOY_BUILD_ARCH}" == "x86_64" ]]; then
20+
BUILD_ARCH_DIR="/linux/amd64"
21+
elif [[ "${ENVOY_BUILD_ARCH}" == "aarch64" ]]; then
22+
BUILD_ARCH_DIR="/linux/arm64"
23+
else
24+
# Fall back to use the ENVOY_BUILD_ARCH itself.
25+
BUILD_ARCH_DIR="/linux/${ENVOY_BUILD_ARCH}"
26+
fi
27+
1928
echo "building using ${NUM_CPUS} CPUs"
29+
echo "building for ${ENVOY_BUILD_ARCH}"
2030

2131
function collect_build_profile() {
2232
declare -g build_profile_count=${build_profile_count:-1}
@@ -52,18 +62,19 @@ function cp_binary_for_outside_access() {
5262

5363
function cp_binary_for_image_build() {
5464
# TODO(mattklein123): Replace this with caching and a different job which creates images.
65+
local BASE_TARGET_DIR="${ENVOY_SRCDIR}${BUILD_ARCH_DIR}"
5566
echo "Copying binary for image build..."
56-
mkdir -p "${ENVOY_SRCDIR}"/build_"$1"
57-
cp -f "${ENVOY_DELIVERY_DIR}"/envoy "${ENVOY_SRCDIR}"/build_"$1"
58-
mkdir -p "${ENVOY_SRCDIR}"/build_"$1"_stripped
59-
strip "${ENVOY_DELIVERY_DIR}"/envoy -o "${ENVOY_SRCDIR}"/build_"$1"_stripped/envoy
67+
mkdir -p "${BASE_TARGET_DIR}"/build_"$1"
68+
cp -f "${ENVOY_DELIVERY_DIR}"/envoy "${BASE_TARGET_DIR}"/build_"$1"
69+
mkdir -p "${BASE_TARGET_DIR}"/build_"$1"_stripped
70+
strip "${ENVOY_DELIVERY_DIR}"/envoy -o "${BASE_TARGET_DIR}"/build_"$1"_stripped/envoy
6071

6172
# Copy for azp which doesn't preserve permissions, creating a tar archive
62-
tar czf "${ENVOY_BUILD_DIR}"/envoy_binary.tar.gz -C "${ENVOY_SRCDIR}" build_"$1" build_"$1"_stripped
73+
tar czf "${ENVOY_BUILD_DIR}"/envoy_binary.tar.gz -C "${BASE_TARGET_DIR}" build_"$1" build_"$1"_stripped
6374

6475
# Remove binaries to save space, only if BUILD_REASON exists (running in AZP)
6576
[[ -z "${BUILD_REASON}" ]] || \
66-
rm -rf "${ENVOY_SRCDIR}"/build_"$1" "${ENVOY_SRCDIR}"/build_"$1"_stripped "${ENVOY_DELIVERY_DIR}"/envoy \
77+
rm -rf "${BASE_TARGET_DIR}"/build_"$1" "${BASE_TARGET_DIR}"/build_"$1"_stripped "${ENVOY_DELIVERY_DIR}"/envoy \
6778
bazel-bin/"${ENVOY_BIN}"
6879
}
6980

@@ -117,7 +128,7 @@ if [[ "$CI_TARGET" == "bazel.release" ]]; then
117128
# toolchain is kept consistent. This ifdef is checked in
118129
# test/common/stats/stat_test_utility.cc when computing
119130
# Stats::TestUtil::MemoryTest::mode().
120-
[[ "$(uname -m)" == "x86_64" ]] && BAZEL_BUILD_OPTIONS="${BAZEL_BUILD_OPTIONS} --test_env=ENVOY_MEMORY_TEST_EXACT=true"
131+
[[ "${ENVOY_BUILD_ARCH}" == "x86_64" ]] && BAZEL_BUILD_OPTIONS="${BAZEL_BUILD_OPTIONS} --test_env=ENVOY_MEMORY_TEST_EXACT=true"
121132

122133
setup_clang_toolchain
123134
echo "Testing ${TEST_TARGETS}"

ci/run_envoy_docker.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ docker run --rm ${ENVOY_DOCKER_OPTIONS} -e HTTP_PROXY=${http_proxy} -e HTTPS_PRO
2828
-e BAZEL_BUILD_EXTRA_OPTIONS -e BAZEL_EXTRA_TEST_OPTIONS -e BAZEL_REMOTE_CACHE -e ENVOY_STDLIB -e BUILD_REASON \
2929
-e BAZEL_REMOTE_INSTANCE -e GCP_SERVICE_ACCOUNT_KEY -e NUM_CPUS -e ENVOY_RBE -e FUZZIT_API_KEY -e ENVOY_BUILD_IMAGE \
3030
-e ENVOY_SRCDIR -e ENVOY_BUILD_TARGET -e SYSTEM_PULLREQUEST_TARGETBRANCH -e SYSTEM_PULLREQUEST_PULLREQUESTNUMBER \
31-
-e GCS_ARTIFACT_BUCKET -e BUILD_SOURCEBRANCHNAME -e BAZELISK_BASE_URL \
31+
-e GCS_ARTIFACT_BUCKET -e BUILD_SOURCEBRANCHNAME -e BAZELISK_BASE_URL -e ENVOY_BUILD_ARCH \
3232
-v "$PWD":/source --cap-add SYS_PTRACE --cap-add NET_RAW --cap-add NET_ADMIN "${ENVOY_BUILD_IMAGE}" \
3333
/bin/bash -lc "groupadd --gid $(id -g) -f envoygroup && useradd -o --uid $(id -u) --gid $(id -g) --no-create-home \
3434
--home-dir /build envoybuild && usermod -a -G pcap envoybuild && sudo -EHs -u envoybuild bash -c \"cd /source && $*\""

0 commit comments

Comments
 (0)