Files
ja4-platform/services/ja4ebpf/Dockerfile.package
toto 9734e21fe3 chore: suppression des services obsolètes (sentinel, correlator, mod-reqin-log)
Remplacés par l'agent ja4ebpf (eBPF CO-RE). Nettoyage complet :

Supprimé :
- old/ (archive de l'ancienne architecture)
- services/correlator/ (logcorrelator Go)
- services/sentinel/ (capture pcap Go)
- services/mod-reqin-log/ (module Apache C)
- shared/go/ja4common/ (lib Go partagée — plus importée par ja4ebpf)
- tests/integration/platform/ (test correlator+sentinel+httpd)
- tests/integration/docker-compose.yml (compose ancienne archi)
- tests/integration/run-tests.sh (runner correlator/sentinel)
- tests/integration/verify_mvs.py (script orphelin)

Nettoyé :
- go.work : retire ./shared/go/ja4common
- services/ja4ebpf/go.mod : retire replace ja4common (jamais importé)
- services/ja4ebpf/Dockerfile* : retire les COPY ja4common inutiles
- Makefile : retire test-ja4common-python, test-integration*, targets obsolètes
- tests/integration/README.md : réécrit pour l'architecture ja4ebpf

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-04-12 01:48:14 +02:00

112 lines
5.0 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
# ── Stage 1 : compilation Go ──────────────────────────────────────────────
FROM golang:${GO_VERSION}-bookworm AS go-builder
ARG BUILD_VERSION
RUN apt-get update && apt-get install -y --no-install-recommends \
clang llvm libbpf-dev && \
rm -rf /var/lib/apt/lists/*
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/'"]