diff --git a/packaging/Dockerfile.deb b/packaging/Dockerfile.deb deleted file mode 100644 index 9b7fffe..0000000 --- a/packaging/Dockerfile.deb +++ /dev/null @@ -1,38 +0,0 @@ -# Dockerfile for building DEB packages for Debian/Ubuntu -# Use Go 1.24 as base to ensure correct Go version -FROM golang:1.24-bookworm AS builder - -# Install DEB build tools -RUN apt-get update && apt-get install -y \ - dpkg-dev \ - fakeroot \ - lintian \ - libpcap-dev \ - && rm -rf /var/lib/apt/lists/* - -WORKDIR /app - -# Copy source code -COPY . . - -# Build binary -ARG VERSION=1.0.0 -RUN mkdir -p dist && \ - CGO_ENABLED=1 GOOS=linux GOARCH=amd64 \ - go build -buildvcs=false -o dist/ja4sentinel-linux-amd64 ./cmd/ja4sentinel - -# Build DEB for Debian/Ubuntu -ARG ARCH=amd64 -RUN mkdir -p /app/packages && \ - ./packaging/build-deb.sh "${VERSION}" "${ARCH}" "debian" && \ - cp /app/build/deb/*.deb /app/packages/ && \ - cp /app/build/deb/*.sha256 /app/packages/ 2>/dev/null || true - -# Final stage - minimal image with just the packages -FROM alpine:latest - -WORKDIR /packages -COPY --from=builder /app/packages/ /packages/ - -# Output list of packages -CMD ["sh", "-c", "ls -la /packages/ && echo '---' && cat /packages/*.sha256 2>/dev/null || true"] diff --git a/packaging/Dockerfile.rpm b/packaging/Dockerfile.rpm deleted file mode 100644 index ef39146..0000000 --- a/packaging/Dockerfile.rpm +++ /dev/null @@ -1,43 +0,0 @@ -# Dockerfile for building RPM packages for Rocky Linux -# Use Rocky Linux 9 as the build environment for correct RPM dependencies -FROM rockylinux:9 AS builder - -# Install Go and RPM build tools -# CRB repository needed for some development packages -RUN dnf install -y epel-release && \ - dnf install -y \ - golang \ - rpm-build \ - rpmdevtools \ - gcc \ - make \ - git \ - && dnf install -y --enablerepo=crb libpcap-devel \ - && dnf clean all - -# Verify Go version -RUN go version - -WORKDIR /app - -# Copy source code -COPY . . - -# Build binary -ARG VERSION=1.0.0 -RUN mkdir -p dist && \ - CGO_ENABLED=1 GOOS=linux GOARCH=amd64 \ - go build -buildvcs=false -o dist/ja4sentinel-linux-amd64 ./cmd/ja4sentinel - -# Build RPM for Rocky Linux (RHEL compatible) -ARG ARCH=x86_64 -RUN mkdir -p /app/packages && \ - ./packaging/build-rpm.sh "${VERSION}" "${ARCH}" "rocky" && \ - cp /app/build/rpm/*.rpm /app/packages/ - -# Final stage - minimal image with just the RPM -FROM alpine:latest - -COPY --from=builder /app/packages/ /packages/ - -CMD ["ls", "-la", "/packages/"] diff --git a/packaging/build-deb.sh b/packaging/build-deb.sh deleted file mode 100755 index db47c7e..0000000 --- a/packaging/build-deb.sh +++ /dev/null @@ -1,107 +0,0 @@ -#!/bin/bash -# Build script for .deb package -# Usage: ./build-deb.sh [version] [architecture] [distribution] -# distribution: debian, ubuntu (default: debian) - -set -e - -# Sanitize version for Debian package (must start with digit) -VERSION="${1:-1.0.0}" -ARCH="${2:-amd64}" -DIST="${3:-debian}" -PACKAGE_NAME="ja4sentinel" - -# Convert git version to Debian-compatible format -# Remove 'v' prefix if present, replace invalid chars with '-' -DEB_VERSION="${VERSION#v}" -DEB_VERSION="${DEB_VERSION//+/-}" - -echo "=== Building ${PACKAGE_NAME} ${DEB_VERSION} for ${DIST} (${ARCH}) ===" - -# Directories -SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" -PROJECT_ROOT="$(dirname "$SCRIPT_DIR")" -BUILD_DIR="${PROJECT_ROOT}/build/deb" -PACKAGE_DIR="${BUILD_DIR}/${PACKAGE_NAME}_${DEB_VERSION}_${ARCH}" - -# Clean and create build directory -rm -rf "${BUILD_DIR}" -mkdir -p "${PACKAGE_DIR}" - -# Create package structure -mkdir -p "${PACKAGE_DIR}/usr/bin" -mkdir -p "${PACKAGE_DIR}/etc/ja4sentinel" -mkdir -p "${PACKAGE_DIR}/var/lib/ja4sentinel" -mkdir -p "${PACKAGE_DIR}/var/log/ja4sentinel" -mkdir -p "${PACKAGE_DIR}/var/run/ja4sentinel" -mkdir -p "${PACKAGE_DIR}/usr/lib/systemd/system" -mkdir -p "${PACKAGE_DIR}/usr/share/ja4sentinel" -mkdir -p "${PACKAGE_DIR}/DEBIAN" - -# Copy binary (build if not exists) -if [ ! -f "${PROJECT_ROOT}/dist/ja4sentinel-linux-amd64" ]; then - echo "Building binary..." - cd "${PROJECT_ROOT}" - make build-linux -fi -cp "${PROJECT_ROOT}/dist/ja4sentinel-linux-amd64" "${PACKAGE_DIR}/usr/bin/ja4sentinel" -chmod 755 "${PACKAGE_DIR}/usr/bin/ja4sentinel" - -# Copy systemd service -cp "${SCRIPT_DIR}/systemd/ja4sentinel.service" "${PACKAGE_DIR}/usr/lib/systemd/system/ja4sentinel.service" -chmod 644 "${PACKAGE_DIR}/usr/lib/systemd/system/ja4sentinel.service" - -# Copy default config -cp "${SCRIPT_DIR}/systemd/config.yml" "${PACKAGE_DIR}/etc/ja4sentinel/config.yml.default" -cp "${SCRIPT_DIR}/systemd/config.yml" "${PACKAGE_DIR}/usr/share/ja4sentinel/config.yml" -chmod 640 "${PACKAGE_DIR}/etc/ja4sentinel/config.yml.default" -chmod 640 "${PACKAGE_DIR}/usr/share/ja4sentinel/config.yml" - -# Copy maintainer scripts -cp "${SCRIPT_DIR}/deb/postinst" "${PACKAGE_DIR}/DEBIAN/postinst" -cp "${SCRIPT_DIR}/deb/prerm" "${PACKAGE_DIR}/DEBIAN/prerm" -cp "${SCRIPT_DIR}/deb/postrm" "${PACKAGE_DIR}/DEBIAN/postrm" -chmod 755 "${PACKAGE_DIR}/DEBIAN/postinst" -chmod 755 "${PACKAGE_DIR}/DEBIAN/prerm" -chmod 755 "${PACKAGE_DIR}/DEBIAN/postrm" - -# Create control file -cat > "${PACKAGE_DIR}/DEBIAN/control" << EOF -Package: ${PACKAGE_NAME} -Version: ${DEB_VERSION} -Section: net -Priority: optional -Architecture: ${ARCH} -Depends: systemd, libpcap0.8 -Maintainer: JA4Sentinel Team -Description: JA4 TLS fingerprinting daemon - JA4Sentinel is a Go-based tool for capturing network traffic on Linux servers, - extracting client-side TLS handshakes, generating JA4 signatures, enriching - with IP/TCP metadata, and logging results to configurable outputs. - . - Features: - - Network packet capture with BPF filters - - TLS ClientHello extraction - - JA4/JA3 fingerprint generation - - IP/TCP metadata enrichment - - Multiple output formats (stdout, file, UNIX socket) - - Structured JSON logging for systemd/journald -Homepage: https://github.com/your-repo/ja4sentinel -EOF - -# Create conffiles -echo "/etc/ja4sentinel/config.yml.default" > "${PACKAGE_DIR}/DEBIAN/conffiles" - -# Build the package -echo "Building .deb package..." -cd "${BUILD_DIR}" -dpkg-deb --build "${PACKAGE_NAME}_${DEB_VERSION}_${ARCH}" - -# Calculate checksum -cd "${BUILD_DIR}" -sha256sum "${PACKAGE_NAME}_${DEB_VERSION}_${ARCH}.deb" > "${PACKAGE_NAME}_${DEB_VERSION}_${ARCH}.deb.sha256" - -echo "" -echo "=== Build complete ===" -echo "Package: ${BUILD_DIR}/${PACKAGE_NAME}_${DEB_VERSION}_${ARCH}.deb" -echo "Checksum: $(cat ${PACKAGE_NAME}_${DEB_VERSION}_${ARCH}.deb.sha256)" diff --git a/packaging/build-rpm.sh b/packaging/build-rpm.sh deleted file mode 100755 index 521dcf5..0000000 --- a/packaging/build-rpm.sh +++ /dev/null @@ -1,76 +0,0 @@ -#!/bin/bash -# Build script for .rpm package -# Usage: ./build-rpm.sh [version] [architecture] [distribution] -# distribution: rocky, rhel, centos (default: rocky) - -set -e - -# Sanitize version for RPM package (must start with digit) -VERSION="${1:-1.0.0}" -ARCH="${2:-x86_64}" -DIST="${3:-rocky}" -PACKAGE_NAME="ja4sentinel" - -# Convert git version to RPM-compatible format -# Remove 'v' prefix if present, replace invalid chars with '-' -RPM_VERSION="${VERSION#v}" -RPM_VERSION="${RPM_VERSION//+/-}" - -echo "=== Building ${PACKAGE_NAME} ${RPM_VERSION} for ${DIST} (${ARCH}) ===" - -# Directories -SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" -PROJECT_ROOT="$(dirname "$SCRIPT_DIR")" -BUILD_DIR="${PROJECT_ROOT}/build/rpm" -RPMBUILD_DIR="${BUILD_DIR}/rpmbuild" - -# Clean and create build directory -rm -rf "${BUILD_DIR}" -mkdir -p "${RPMBUILD_DIR}/BUILD" -mkdir -p "${RPMBUILD_DIR}/RPMS" -mkdir -p "${RPMBUILD_DIR}/SOURCES" -mkdir -p "${RPMBUILD_DIR}/SPECS" -mkdir -p "${RPMBUILD_DIR}/SRPMS" - -# Copy binary (build if not exists) -if [ ! -f "${PROJECT_ROOT}/dist/ja4sentinel-linux-amd64" ]; then - echo "Building binary..." - cd "${PROJECT_ROOT}" - make build-linux -fi -cp "${PROJECT_ROOT}/dist/ja4sentinel-linux-amd64" "${RPMBUILD_DIR}/SOURCES/ja4sentinel" -chmod 755 "${RPMBUILD_DIR}/SOURCES/ja4sentinel" - -# Copy systemd service -cp "${SCRIPT_DIR}/systemd/ja4sentinel.service" "${RPMBUILD_DIR}/SOURCES/ja4sentinel.service" -chmod 644 "${RPMBUILD_DIR}/SOURCES/ja4sentinel.service" - -# Copy default config -cp "${SCRIPT_DIR}/systemd/config.yml" "${RPMBUILD_DIR}/SOURCES/config.yml" -chmod 640 "${RPMBUILD_DIR}/SOURCES/config.yml" - -# Copy spec file and update version -sed "s/Version: .*/Version: ${RPM_VERSION}/" "${SCRIPT_DIR}/rpm/ja4sentinel.spec" > "${RPMBUILD_DIR}/SPECS/ja4sentinel.spec" - -# Build the RPM package -echo "Building .rpm package..." -rpmbuild -bb \ - --define "_topdir ${RPMBUILD_DIR}" \ - --define "_arch ${ARCH}" \ - "${RPMBUILD_DIR}/SPECS/ja4sentinel.spec" - -# Copy RPM to build directory -find "${RPMBUILD_DIR}/RPMS" -name "*.rpm" -exec cp {} "${BUILD_DIR}/" \; - -# Calculate checksum -cd "${BUILD_DIR}" -for rpm_file in *.rpm; do - if [ -f "$rpm_file" ]; then - sha256sum "$rpm_file" > "${rpm_file}.sha256" - fi -done - -echo "" -echo "=== Build complete ===" -echo "Package: ${BUILD_DIR}/${PACKAGE_NAME}-${VERSION}-1.${ARCH}.rpm" -ls -la "${BUILD_DIR}"/*.rpm 2>/dev/null || true diff --git a/packaging/test/Dockerfile.deb b/packaging/test/Dockerfile.deb deleted file mode 100644 index 888d170..0000000 --- a/packaging/test/Dockerfile.deb +++ /dev/null @@ -1,31 +0,0 @@ -# Dockerfile for testing DEB package installation on Debian/Ubuntu -FROM debian:bookworm-slim - -ENV DEBIAN_FRONTEND=noninteractive - -# Install dependencies -RUN apt-get update && apt-get install -y \ - libpcap0.8 \ - systemd \ - && rm -rf /var/lib/apt/lists/* - -# Create systemd directory (needed for service installation) -RUN mkdir -p /etc/systemd/system - -# Copy DEB package -COPY *.deb /tmp/ja4sentinel.deb - -# Install the package -RUN dpkg -i /tmp/ja4sentinel.deb || apt-get install -f -y - -# Verify installation -RUN echo "=== Verifying installation ===" && \ - which ja4sentinel && \ - ja4sentinel --version && \ - ls -la /etc/ja4sentinel/ && \ - ls -la /var/lib/ja4sentinel/ && \ - ls -la /usr/lib/systemd/system/ja4sentinel.service && \ - echo "=== Installation successful ===" - -# Default command: run tests -CMD ["/test-install.sh"] diff --git a/packaging/test/Dockerfile.rpm b/packaging/test/Dockerfile.rpm deleted file mode 100644 index 07159ae..0000000 --- a/packaging/test/Dockerfile.rpm +++ /dev/null @@ -1,27 +0,0 @@ -# Dockerfile for testing RPM package installation on Rocky Linux -FROM rockylinux:9 - -# Install systemd only (libpcap will be installed as dependency of ja4sentinel) -RUN dnf install -y systemd && dnf clean all - -# Create systemd directory (needed for service installation) -RUN mkdir -p /etc/systemd/system - -# Copy RPM package -COPY *.rpm /tmp/ja4sentinel.rpm - -# Install the package (libpcap dependency should be pulled automatically) -# If it fails, install libpcap first and retry -RUN dnf install -y /tmp/ja4sentinel.rpm || (echo "First attempt failed, installing libpcap..." && dnf install -y libpcap && dnf install -y /tmp/ja4sentinel.rpm) - -# Verify installation -RUN echo "=== Verifying installation ===" && \ - command -v ja4sentinel && \ - ja4sentinel --version && \ - ls -la /etc/ja4sentinel/ && \ - ls -la /var/lib/ja4sentinel/ && \ - ls -la /usr/lib/systemd/system/ja4sentinel.service && \ - echo "=== Installation successful ===" - -# Default command: run tests -CMD ["/test-install.sh"]