- Create RPM maintainer scripts (post, preun, postun) - Add Docker build stages for each target distribution (el7, el8, el9, el10) - Update architecture.yml with supported RPM distributions - Update build.sh to extract distro-specific RPM packages Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
86 lines
3.3 KiB
Bash
Executable File
86 lines
3.3 KiB
Bash
Executable File
#!/bin/bash
|
|
# Build script - everything runs in Docker containers
|
|
set -e
|
|
|
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
cd "$SCRIPT_DIR"
|
|
|
|
VERSION="${VERSION:-1.0.0}"
|
|
OUTPUT_DIR="${SCRIPT_DIR}/dist"
|
|
|
|
echo "=============================================="
|
|
echo " logcorrelator - Docker Build Pipeline"
|
|
echo "=============================================="
|
|
echo ""
|
|
|
|
# Create output directory
|
|
mkdir -p "${OUTPUT_DIR}"
|
|
|
|
# Step 1: Build and test
|
|
echo "[1/4] Building and running tests in container..."
|
|
docker build \
|
|
--target builder \
|
|
-t logcorrelator-builder:latest \
|
|
-f Dockerfile .
|
|
|
|
# Step 2: Build runtime image
|
|
echo "[2/4] Building runtime image..."
|
|
docker build \
|
|
--target runtime \
|
|
-t logcorrelator:${VERSION} \
|
|
-t logcorrelator:latest \
|
|
-f Dockerfile .
|
|
|
|
# Step 3: Build packages (DEB + RPM)
|
|
echo "[3/4] Building DEB and RPM packages in container..."
|
|
docker build \
|
|
--target output \
|
|
--build-arg VERSION="${VERSION}" \
|
|
-t logcorrelator-packager:latest \
|
|
-f Dockerfile.package .
|
|
|
|
# Extract packages from builder container
|
|
echo "[4/4] Extracting packages..."
|
|
mkdir -p "${OUTPUT_DIR}/deb" "${OUTPUT_DIR}/rpm/centos7" "${OUTPUT_DIR}/rpm/rocky8" "${OUTPUT_DIR}/rpm/rocky9" "${OUTPUT_DIR}/rpm/rocky10"
|
|
docker run --rm -v "${OUTPUT_DIR}:/output" logcorrelator-packager:latest \
|
|
sh -c 'cp -r /packages/deb /output/ && cp -r /packages/rpm/centos7 /output/rpm/ && cp -r /packages/rpm/rocky8 /output/rpm/ && cp -r /packages/rpm/rocky9 /output/rpm/ && cp -r /packages/rpm/rocky10 /output/rpm/'
|
|
|
|
echo ""
|
|
echo "=============================================="
|
|
echo " Build Complete!"
|
|
echo "=============================================="
|
|
echo ""
|
|
echo "Artifacts:"
|
|
echo " - Runtime image: logcorrelator:${VERSION}"
|
|
echo " - DEB package: ${OUTPUT_DIR}/deb/logcorrelator_${VERSION}_amd64.deb"
|
|
echo " - RPM CentOS 7: ${OUTPUT_DIR}/rpm/centos7/logcorrelator-${VERSION}-1.el7.x86_64.rpm"
|
|
echo " - RPM Rocky 8: ${OUTPUT_DIR}/rpm/rocky8/logcorrelator-${VERSION}-1.el8.x86_64.rpm"
|
|
echo " - RPM Rocky 9: ${OUTPUT_DIR}/rpm/rocky9/logcorrelator-${VERSION}-1.el9.x86_64.rpm"
|
|
echo " - RPM Rocky 10: ${OUTPUT_DIR}/rpm/rocky10/logcorrelator-${VERSION}-1.el10.x86_64.rpm"
|
|
echo ""
|
|
echo "Usage:"
|
|
echo " # Run with Docker:"
|
|
echo " docker run -d --name logcorrelator \\"
|
|
echo " -v /var/run/logcorrelator:/var/run/logcorrelator \\"
|
|
echo " -v /var/log/logcorrelator:/var/log/logcorrelator \\"
|
|
echo " -v ./config.yml:/etc/logcorrelator/logcorrelator.yml \\"
|
|
echo " logcorrelator:latest"
|
|
echo ""
|
|
echo " # Install DEB on Debian/Ubuntu:"
|
|
echo " sudo dpkg -i ${OUTPUT_DIR}/deb/logcorrelator_${VERSION}_amd64.deb"
|
|
echo " sudo systemctl enable logcorrelator"
|
|
echo " sudo systemctl start logcorrelator"
|
|
echo ""
|
|
echo " # Install RPM on CentOS 7:"
|
|
echo " sudo yum install -y ${OUTPUT_DIR}/rpm/centos7/logcorrelator-${VERSION}-1.el7.x86_64.rpm"
|
|
echo " sudo systemctl enable logcorrelator"
|
|
echo " sudo systemctl start logcorrelator"
|
|
echo ""
|
|
echo " # Install RPM on Rocky Linux 8/9/10:"
|
|
echo " sudo dnf install -y ${OUTPUT_DIR}/rpm/rocky8/logcorrelator-${VERSION}-1.el8.x86_64.rpm"
|
|
echo " sudo dnf install -y ${OUTPUT_DIR}/rpm/rocky9/logcorrelator-${VERSION}-1.el9.x86_64.rpm"
|
|
echo " sudo dnf install -y ${OUTPUT_DIR}/rpm/rocky10/logcorrelator-${VERSION}-1.el10.x86_64.rpm"
|
|
echo " sudo systemctl enable logcorrelator"
|
|
echo " sudo systemctl start logcorrelator"
|
|
echo ""
|