build: use huatuo/huatuo-bamai image instead of local compile

Signed-off-by: fanzu8 <tuzengbing@gmail.com>
This commit is contained in:
tuzengbing 2025-07-15 16:05:14 +08:00
parent 67ca28005c
commit 1a95972842
4 changed files with 7 additions and 60 deletions

View File

@ -14,6 +14,5 @@ PROMETHEUS_VERSION=v2.53.3 # LTS v2.53
# Grafana
GRAFANA_VERSION=11.0.0
# Compile and Run huatuo-bamai
BUILD_PATH=/go/huatuo-bamai
# Run huatuo-bamai
RUN_PATH=/home/huatuo-bamai

View File

@ -1,14 +0,0 @@
# https://hub.docker.com/_/golang/tags?name=1.22.4
FROM golang:1.22.4-alpine AS base
ARG RUN_PATH=${RUN_PATH:-/home/huatuo-bamai}
# Install dependencies for build
RUN apk add --no-cache \
make \
clang15 \
libbpf-dev \
bpftool \
curl
ENV PATH=$PATH:/usr/lib/llvm15/bin
WORKDIR ${RUN_PATH}
CMD ["./run.sh"]

View File

@ -30,21 +30,20 @@ services:
- elasticsearch
huatuo-bamai:
build:
context: ./../../ # compile required in Dockerfile
dockerfile: ./build/docker/Dockerfile
image: huatuo/huatuo-bamai:latest
container_name: huatuo-bamai
network_mode: host
privileged: true
environment:
ELASTICSEARCH_HOST: ${ELASTICSEARCH_HOST:-}
ELASTIC_PASSWORD: ${ELASTIC_PASSWORD:-}
BUILD_PATH: ${BUILD_PATH:-}
RUN_PATH: ${RUN_PATH:-}
volumes:
- ../../:${BUILD_PATH}:rw # src
- ./run.sh:${RUN_PATH}/run.sh:ro # run
- /sys/kernel:/sys/kernel
- /sys:/sys
- /run:/run
- ../../huatuo-bamai.conf:${RUN_PATH}/huatuo-bamai.conf:rw
- ./run.sh:${RUN_PATH}/run.sh:ro
command: ["./run.sh"]
depends_on:
- elasticsearch
- prometheus

View File

@ -3,7 +3,6 @@
ELASTICSEARCH_HOST=${ELASTICSEARCH_HOST:-localhost}
ELASTIC_PASSWORD=${ELASTIC_PASSWORD:-huatuo-bamai}
BUILD_PATH=${BUILD_PATH:-/go/huatuo-bamai}
RUN_PATH=${RUN_PATH:-/home/huatuo-bamai}
# Wait for Elasticsearch to be ready
@ -60,42 +59,6 @@ wait_for_elasticsearch() {
fi
}
# Compile and copy huatuo-bamai, .conf, bpf.o, cmd-tools to run path
prepare_run_env() {
# compile huatuo-bamai
if [ ! -x "$BUILD_PATH/_output/bin/huatuo-bamai" ]; then
cd $BUILD_PATH && make clean
bpftool btf dump file /sys/kernel/btf/vmlinux format c > bpf/include/vmlinux.h || {
echo "Failed to dump vmlinux.h"
exit 1
}
make || {
echo "Failed to compile huatuo-bamai"
exit 1
}
fi
# copy huatuo-bamai, .conf, bpf.o, cmd-tools to run path
cp $BUILD_PATH/_output/bin/huatuo-bamai $RUN_PATH/huatuo-bamai || {
echo "Failed to copy huatuo-bamai"
exit 1
}
cp $BUILD_PATH/huatuo-bamai.conf $RUN_PATH/huatuo-bamai.conf || {
echo "Failed to copy huatuo-bamai.conf"
exit 1
}
mkdir -p $RUN_PATH/bpf && cp $BUILD_PATH/bpf/*.o $RUN_PATH/bpf/ || {
echo "Failed to copy bpf files"
exit 1
}
mkdir -p $RUN_PATH/tracer && find $BUILD_PATH/cmd/ -type f -name "*.bin" -exec cp {} $RUN_PATH/tracer/ \; || {
echo "Failed to copy cmd-tools files"
exit 1
}
}
# Prepare run env for huatuo-bamai
prepare_run_env
echo "huatuo-bamai run env is ready."
wait_for_elasticsearch
sleep 5 # Waiting for initialization of Elasticsearch built-in users