Files
ja4-platform/services/ja4ebpf/Dockerfile.package
Jacquin Antoine d75825278e feat: multi-distro VM tests, ja4ebpf eBPF improvements, bot-detector scoring
ja4ebpf:
- Refactor BPF TC capture with improved SYN offset handling and TCP option parsing
- Enhance TLS uprobe SSL hooking for better key extraction
- Add ClickHouse writer improvements for HTTP log materialized views
- Update RPM spec for Rocky Linux 8/9/10, fix systemd service
- Simplify loader with cleaner bpf2go integration

bot-detector:
- Add H2 SETTINGS per-parameter comparison in browser_matcher
- Enhance browser signatures and scoring pipeline
- Improve preprocessing and cycle detection

infra:
- Multi-distro Vagrantfile (centos8, rocky9, rocky10) with per-distro provisioning
- New Makefile targets: vm-up-all, test-vm-matrix, test-vm-centos8/rocky10
- Add debug helpers and run-test-from-host.sh for host-driven VM testing
- Update run-tests-vm.sh for cross-distro compatibility
- Remove accidental binary blob (\004)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-13 01:09:33 +02:00

122 lines
5.2 KiB
Docker

# =============================================================================
# Dockerfile.package — Build multi-distro du RPM ja4ebpf
#
# Cible : RHEL/CentOS/Rocky/AlmaLinux 8, 9 et 10.
# Le BTF natif (/sys/kernel/btf/vmlinux) est disponible sur tous ces kernels.
#
# Stages :
# go-builder : compile le binaire Go statique (clang + bpf2go + go build)
# rpm-el8 : assemble le RPM pour el8 (AlmaLinux 8 / RHEL 8)
# rpm-el9 : assemble le RPM pour el9 (Rocky Linux 9 / RHEL 9)
# rpm-el10 : assemble le RPM pour el10 (AlmaLinux 10)
# output : collecte tous les RPMs dans /output
#
# Usage :
# docker build -f services/ja4ebpf/Dockerfile.package \
# --build-arg BUILD_VERSION=1.2.3 \
# -t ja4ebpf:package \
# .
# docker run --rm -v $(pwd)/dist:/dist ja4ebpf:package
# =============================================================================
ARG BUILD_VERSION=dev
ARG GO_VERSION=1.24.3
# ── Stage 1 : compilation Go ──────────────────────────────────────────────
FROM rockylinux:9 AS go-builder
ARG BUILD_VERSION
ARG GO_VERSION
RUN dnf install -y epel-release dnf-plugins-core && \
dnf config-manager --enable crb && \
dnf install -y --allowerasing \
clang llvm libbpf-devel bpftool \
curl tar gzip && \
dnf clean all
RUN curl -fsSL https://go.dev/dl/go${GO_VERSION}.linux-amd64.tar.gz \
| tar -C /usr/local -xz
ENV PATH="/usr/local/go/bin:${PATH}" \
GOPATH=/go
WORKDIR /build
COPY services/ja4ebpf/go.mod services/ja4ebpf/go.sum* ./services/ja4ebpf/
RUN cd services/ja4ebpf && go mod download 2>/dev/null || go get ./...
COPY services/ja4ebpf/ ./services/ja4ebpf/
WORKDIR /build/services/ja4ebpf
# Génération des bindings eBPF (C → bytecode embarqué en Go)
RUN GOWORK=off go generate ./internal/loader/
# Compilation statique
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 \
go build \
-ldflags="-s -w -X main.version=${BUILD_VERSION} -extldflags=-static" \
-o /out/ja4ebpf \
./cmd/ja4ebpf/
# ── Stage 2 : RPM pour el8 ───────────────────────────────────────────────
FROM almalinux:8 AS rpm-el8
RUN dnf install -y rpm-build rpmdevtools systemd-rpm-macros && dnf clean all && rpmdev-setuptree
COPY --from=go-builder /out/ja4ebpf /root/rpmbuild/SOURCES/ja4ebpf
COPY services/ja4ebpf/packaging/systemd/ja4ebpf.service /root/rpmbuild/SOURCES/ja4ebpf.service
COPY services/ja4ebpf/config.yml.example /root/rpmbuild/SOURCES/config.yml.example
COPY services/ja4ebpf/packaging/rpm/ja4ebpf.spec /root/rpmbuild/SPECS/ja4ebpf.spec
ARG BUILD_VERSION=dev
RUN rpmbuild -bb \
--define "build_version ${BUILD_VERSION}" \
--define "dist .el8" \
/root/rpmbuild/SPECS/ja4ebpf.spec && \
mkdir -p /rpms && find /root/rpmbuild/RPMS -name '*.rpm' -exec cp {} /rpms/ \;
# ── Stage 3 : RPM pour el9 ───────────────────────────────────────────────
FROM rockylinux:9 AS rpm-el9
RUN dnf install -y rpm-build rpmdevtools systemd-rpm-macros && dnf clean all && rpmdev-setuptree
COPY --from=go-builder /out/ja4ebpf /root/rpmbuild/SOURCES/ja4ebpf
COPY services/ja4ebpf/packaging/systemd/ja4ebpf.service /root/rpmbuild/SOURCES/ja4ebpf.service
COPY services/ja4ebpf/config.yml.example /root/rpmbuild/SOURCES/config.yml.example
COPY services/ja4ebpf/packaging/rpm/ja4ebpf.spec /root/rpmbuild/SPECS/ja4ebpf.spec
ARG BUILD_VERSION=dev
RUN rpmbuild -bb \
--define "build_version ${BUILD_VERSION}" \
--define "dist .el9" \
/root/rpmbuild/SPECS/ja4ebpf.spec && \
mkdir -p /rpms && find /root/rpmbuild/RPMS -name '*.rpm' -exec cp {} /rpms/ \;
# ── Stage 4 : RPM pour el10 ──────────────────────────────────────────────
FROM almalinux:10 AS rpm-el10
RUN dnf install -y rpm-build rpmdevtools systemd-rpm-macros && dnf clean all && rpmdev-setuptree
COPY --from=go-builder /out/ja4ebpf /root/rpmbuild/SOURCES/ja4ebpf
COPY services/ja4ebpf/packaging/systemd/ja4ebpf.service /root/rpmbuild/SOURCES/ja4ebpf.service
COPY services/ja4ebpf/config.yml.example /root/rpmbuild/SOURCES/config.yml.example
COPY services/ja4ebpf/packaging/rpm/ja4ebpf.spec /root/rpmbuild/SPECS/ja4ebpf.spec
ARG BUILD_VERSION=dev
RUN rpmbuild -bb \
--define "build_version ${BUILD_VERSION}" \
--define "dist .el10" \
/root/rpmbuild/SPECS/ja4ebpf.spec && \
mkdir -p /rpms && find /root/rpmbuild/RPMS -name '*.rpm' -exec cp {} /rpms/ \;
# ── Stage final : collecte de tous les RPMs ───────────────────────────────
FROM alpine:3.19 AS output
COPY --from=rpm-el8 /rpms/ /output/el8/
COPY --from=rpm-el9 /rpms/ /output/el9/
COPY --from=rpm-el10 /rpms/ /output/el10/
RUN echo "=== RPMs produits ===" && find /output -name '*.rpm' | sort
CMD ["/bin/sh", "-c", "cp -rv /output/. /dist/ && echo 'RPMs copiés dans /dist/'"]