Skip to content
This repository was archived by the owner on Aug 1, 2025. It is now read-only.

Commit 5f9db69

Browse files
authored
feature: use-distro-packages (#35)
* remove grpc, abseil, curl and openssl compilation * fix resolution of grpc cpp plugin * only fetch submodules if we're building the container * add a user to the build environment rather than working from root * fix $HOME env variable * consolidate apt-get in base Dockerfile * move bcc package requirement to base * move libbpf package requirements to base * move libuv removal to base image * set base username * add explicit error prints to user verification * add sudo package * consolidate package installations and add sudo * fix PATH * add debug print to bcc * export PATH to .bashrc in base container * write to .profile so /bin/sh will pick up * bring libuv1 removal back to the uv container as it was removing cmake * add chown on copying bcc files * add chown to COPY in libuv * hardcode uid, gid for test * export UID and GID as env variables for chown * add chown statements to all relevant COPY statements * add ssh and ag to packages in final * switch to multi-line RUN to get Docker to allow multi-line * remove CFLAGS setting, it seems to end up empty anyway * create output directory * reset UNAME for LZ4 which seems to depend on it * fix lz4 builds * reduce container sizes by making them into multi-stage builds * re-comment clause that was accidentally un-commented * add protoc flag (required since we apparently downgraded protoc versions) * add missing library dependencies * remove the now redundant Dockerfiles and submodules, and their mentions in the GHA * switch to podman for building images * add missing package * update to bookworm * add libpolly, required by bcc * add CMAKE_BUILD_TYPE and BUILD_CFLAGS arguments * bcc build examins the git repo, so check a standalone version * install python libs via apt, as suggested by pip3 * fix apt install clause * auto-run workflow on push and PR, with dry run * disable fossa and ossf-scorecard on contributor repos * add --break-system-packages to `pip3 install pcpp` since an apt package is not available for bookworm * reorder less-changing layers in final to earlier position, to leverage layer caching * add uidmap, required by podman * fix permissions for podman to work inside the build environment * remove flotsam (oops) * set clang-tidy and clang-format to version 16 * add slirp4netns for podman * remove the pull request trigger; it does not have permissions to push to ghcr
1 parent 00c6c7e commit 5f9db69

File tree

24 files changed

+273
-512
lines changed

24 files changed

+273
-512
lines changed

.github/actions/build-push-container/action.yml

Lines changed: 25 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -54,15 +54,6 @@ runs:
5454
ref: ${{ inputs.ref }}
5555
fetch-depth: 0
5656

57-
- name: Initialize directory-specific submodules
58-
shell: bash
59-
run: |
60-
DIRECTORY="${{ inputs.directory }}"
61-
echo "Initializing submodules for directory: ${DIRECTORY}"
62-
63-
# Initialize submodules for the specific directory path
64-
git submodule update --init --recursive -- "${DIRECTORY}/"
65-
6657
- name: Compute recursive tags for all directories
6758
id: compute-recursive-tags
6859
shell: bash
@@ -74,24 +65,20 @@ runs:
7465
# Define dependency mapping based on CMakeLists.txt
7566
declare -A DEPS
7667
DEPS["base"]=""
77-
DEPS["openssl"]="base"
7868
DEPS["bcc"]="base"
7969
DEPS["libuv"]="base"
8070
DEPS["cpp_misc"]="base"
8171
DEPS["go"]="base"
82-
DEPS["abseil_cpp"]="base"
8372
DEPS["libmaxminddb"]="base"
8473
DEPS["libbpf"]="base"
85-
DEPS["curl"]="base openssl"
86-
DEPS["grpc_cpp"]="base abseil_cpp openssl"
87-
DEPS["aws_sdk"]="base openssl curl"
88-
DEPS["gcp_cpp"]="base openssl curl grpc_cpp"
89-
DEPS["opentelemetry"]="base grpc_cpp"
90-
DEPS["final"]="base openssl curl bcc libuv aws_sdk cpp_misc go grpc_cpp abseil_cpp libmaxminddb gcp_cpp opentelemetry libbpf"
74+
DEPS["aws_sdk"]="base"
75+
DEPS["gcp_cpp"]="base"
76+
DEPS["opentelemetry"]="base"
77+
DEPS["final"]="base bcc libuv aws_sdk cpp_misc go libmaxminddb gcp_cpp opentelemetry libbpf"
9178
9279
# Compute direct hashes for all directories upfront
9380
declare -A DIRECT_HASHES
94-
ALL_DIRS="base openssl bcc libuv cpp_misc go abseil_cpp libmaxminddb libbpf curl grpc_cpp aws_sdk gcp_cpp opentelemetry final"
81+
ALL_DIRS="base bcc libuv cpp_misc go libmaxminddb libbpf aws_sdk gcp_cpp opentelemetry final"
9582
9683
echo "Computing direct hashes..." >&2
9784
for dir in $ALL_DIRS; do
@@ -187,7 +174,6 @@ runs:
187174
188175
# Compute all dependency tags for build args
189176
echo "Computing all dependency tags..." >&2
190-
ALL_DIRS="base openssl bcc libuv cpp_misc go abseil_cpp libmaxminddb libbpf curl grpc_cpp aws_sdk gcp_cpp opentelemetry final"
191177
192178
for dir in $ALL_DIRS; do
193179
if [[ "$dir" != "$DIRECTORY" ]]; then
@@ -220,6 +206,17 @@ runs:
220206
echo "Image ${FULL_IMAGE_TAG} does not exist in registry"
221207
fi
222208
209+
- name: Initialize directory submodules
210+
if: steps.check-exists.outputs.exists == 'false'
211+
shell: bash
212+
run: |
213+
DIRECTORY="${{ inputs.directory }}"
214+
echo "Initializing submodules for directory: ${DIRECTORY}"
215+
216+
# Initialize submodules for the specific directory path
217+
git submodule update --init --recursive -- "${DIRECTORY}/"
218+
219+
223220
- name: Log in to Container Registry
224221
if: steps.check-exists.outputs.exists == 'false'
225222
uses: docker/login-action@9780b0c442fbb1117ed29e0efdff1e18412f7567 # v3.3.0
@@ -240,16 +237,12 @@ runs:
240237
241238
# Add all dependency image tags as build args using outputs from compute-recursive-tags step
242239
BUILD_ARGS="${BUILD_ARGS} --build-arg base_IMAGE_TAG=${{ steps.compute-recursive-tags.outputs.base_IMAGE_TAG }}"
243-
BUILD_ARGS="${BUILD_ARGS} --build-arg openssl_IMAGE_TAG=${{ steps.compute-recursive-tags.outputs.openssl_IMAGE_TAG }}"
244240
BUILD_ARGS="${BUILD_ARGS} --build-arg bcc_IMAGE_TAG=${{ steps.compute-recursive-tags.outputs.bcc_IMAGE_TAG }}"
245241
BUILD_ARGS="${BUILD_ARGS} --build-arg libuv_IMAGE_TAG=${{ steps.compute-recursive-tags.outputs.libuv_IMAGE_TAG }}"
246242
BUILD_ARGS="${BUILD_ARGS} --build-arg cpp_misc_IMAGE_TAG=${{ steps.compute-recursive-tags.outputs.cpp_misc_IMAGE_TAG }}"
247243
BUILD_ARGS="${BUILD_ARGS} --build-arg go_IMAGE_TAG=${{ steps.compute-recursive-tags.outputs.go_IMAGE_TAG }}"
248-
BUILD_ARGS="${BUILD_ARGS} --build-arg abseil_cpp_IMAGE_TAG=${{ steps.compute-recursive-tags.outputs.abseil_cpp_IMAGE_TAG }}"
249244
BUILD_ARGS="${BUILD_ARGS} --build-arg libmaxminddb_IMAGE_TAG=${{ steps.compute-recursive-tags.outputs.libmaxminddb_IMAGE_TAG }}"
250245
BUILD_ARGS="${BUILD_ARGS} --build-arg libbpf_IMAGE_TAG=${{ steps.compute-recursive-tags.outputs.libbpf_IMAGE_TAG }}"
251-
BUILD_ARGS="${BUILD_ARGS} --build-arg curl_IMAGE_TAG=${{ steps.compute-recursive-tags.outputs.curl_IMAGE_TAG }}"
252-
BUILD_ARGS="${BUILD_ARGS} --build-arg grpc_cpp_IMAGE_TAG=${{ steps.compute-recursive-tags.outputs.grpc_cpp_IMAGE_TAG }}"
253246
BUILD_ARGS="${BUILD_ARGS} --build-arg aws_sdk_IMAGE_TAG=${{ steps.compute-recursive-tags.outputs.aws_sdk_IMAGE_TAG }}"
254247
BUILD_ARGS="${BUILD_ARGS} --build-arg gcp_cpp_IMAGE_TAG=${{ steps.compute-recursive-tags.outputs.gcp_cpp_IMAGE_TAG }}"
255248
BUILD_ARGS="${BUILD_ARGS} --build-arg opentelemetry_IMAGE_TAG=${{ steps.compute-recursive-tags.outputs.opentelemetry_IMAGE_TAG }}"
@@ -264,6 +257,15 @@ runs:
264257
BUILD_ARGS="${BUILD_ARGS} --build-arg BENV_BASE_IMAGE_VERSION=${BENV_BASE_IMAGE_VERSION}"
265258
fi
266259
260+
# Add CMAKE_BUILD_TYPE (defaults to Release if not set)
261+
CMAKE_BUILD_TYPE="${CMAKE_BUILD_TYPE:-Release}"
262+
BUILD_ARGS="${BUILD_ARGS} --build-arg CMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}"
263+
264+
# Add BUILD_CFLAGS based on build type
265+
if [ "${CMAKE_BUILD_TYPE}" = "Debug" ]; then
266+
BUILD_ARGS="${BUILD_ARGS} --build-arg BUILD_CFLAGS='-O0 -g'"
267+
fi
268+
267269
# Build the image
268270
echo "Building image: ${FULL_IMAGE_TAG}"
269271
echo "Build args: ${BUILD_ARGS}"

0 commit comments

Comments
 (0)