Compare commits
	
		
			25 Commits
		
	
	
		
			7bb7bfc3a5
			...
			test
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| fcbd2c5452 | |||
| 039531ce7b | |||
| 91fe69a0a2 | |||
| 81af16cedf | |||
| 03be79d149 | |||
| 1112e15d80 | |||
| 0c86b453a6 | |||
| 882755ffc8 | |||
| 2854955c74 | |||
| fa06beefdd | |||
| d7f1052305 | |||
| 8ab7ff54b9 | |||
| 993104e122 | |||
| 44a3bc1cf4 | |||
| 44b4aa9e7a | |||
| 7986278926 | |||
| a1752e68c7 | |||
| f3ac36a139 | |||
| f95de88005 | |||
| 9f2e966662 | |||
| baf814e0e5 | |||
| 
						 | 
					0722d1942f | ||
| 1119a38496 | |||
| 91afa98d6b | |||
| f3ce93f8b1 | 
@@ -1,23 +1,25 @@
 | 
			
		||||
name: Zabbix APK Builder
 | 
			
		||||
 | 
			
		||||
on:
 | 
			
		||||
  # Trigger on pushes to main/test branch
 | 
			
		||||
  # Trigger on pushes to main/test branch into the zabbix-apk-builder directory
 | 
			
		||||
  push:
 | 
			
		||||
    branches: [ main, test ]
 | 
			
		||||
    paths: [ 'zabbix-apk-builder/**' ]
 | 
			
		||||
    if: "!contains(gitea.event.head_commit.message, '[ci skip]')"
 | 
			
		||||
 | 
			
		||||
  # Scheduled check for new versions (daily at 6 AM UTC)
 | 
			
		||||
  # Scheduled runs at 06:00 UTC daily
 | 
			
		||||
  schedule:
 | 
			
		||||
    - cron: '0 6 * * *'
 | 
			
		||||
 | 
			
		||||
jobs:
 | 
			
		||||
  check-version:
 | 
			
		||||
    runs-on: ubuntu-latest
 | 
			
		||||
    # Skip the execution if the commit author is the bot itself to prevent loops
 | 
			
		||||
    if: ${{ gitea.event.head_commit.author.name != 'Gitea Action' }}
 | 
			
		||||
    outputs:
 | 
			
		||||
      should_build: ${{ steps.version-check.outputs.should_build }}
 | 
			
		||||
      latest_version: ${{ steps.version-check.outputs.latest_version }}
 | 
			
		||||
      current_version: ${{ steps.version-check.outputs.current_version }}
 | 
			
		||||
      is_push_trigger: ${{ steps.version-check.outputs.is_push_trigger }}
 | 
			
		||||
    
 | 
			
		||||
    steps:
 | 
			
		||||
    - name: Checkout repository
 | 
			
		||||
@@ -28,37 +30,34 @@ jobs:
 | 
			
		||||
      run: |
 | 
			
		||||
        set -euo pipefail
 | 
			
		||||
        
 | 
			
		||||
        # Install jq for JSON parsing
 | 
			
		||||
        sudo apt-get update && sudo apt-get install -y jq
 | 
			
		||||
        # Remove jq installation
 | 
			
		||||
        # apt-get update && apt-get install -y jq
 | 
			
		||||
        
 | 
			
		||||
        # Get current version from APKBUILD
 | 
			
		||||
        # Detect trigger type
 | 
			
		||||
        IS_PUSH="${{ gitea.event_name == 'push' }}"
 | 
			
		||||
        echo "is_push_trigger=${IS_PUSH}" >> "${GITHUB_OUTPUT}"
 | 
			
		||||
        
 | 
			
		||||
        # Get versions
 | 
			
		||||
        CURRENT_VERSION=$(grep '^pkgver=' zabbix-apk-builder/APKBUILD | cut -d'=' -f2)
 | 
			
		||||
        echo "current_version=$CURRENT_VERSION" >> $GITHUB_OUTPUT
 | 
			
		||||
        echo "Current version: $CURRENT_VERSION"
 | 
			
		||||
        
 | 
			
		||||
        # Get latest version from Zabbix API (stable releases only)
 | 
			
		||||
        LATEST_VERSION=$(curl -s "https://git.zabbix.com/rest/api/1.0/projects/ZBX/repos/zabbix/tags?limit=100" | \
 | 
			
		||||
          jq -r '.values[].displayId' | \
 | 
			
		||||
          grep -E '^[0-9]+\.[0-9]+\.[0-9]+$' | \
 | 
			
		||||
          grep -v 'rc\|beta\|alpha' | \
 | 
			
		||||
          sort -V | \
 | 
			
		||||
          tail -1)
 | 
			
		||||
          grep -o '"displayId":"[^"]*"' | cut -d'"' -f4 | \
 | 
			
		||||
          grep -E '^[0-9]+\.[0-9]+\.[0-9]+$' | grep -v 'rc\|beta\|alpha' | \
 | 
			
		||||
          sort -V | tail -1)
 | 
			
		||||
        
 | 
			
		||||
        echo "latest_version=$LATEST_VERSION" >> $GITHUB_OUTPUT
 | 
			
		||||
        echo "Latest version: $LATEST_VERSION"
 | 
			
		||||
        echo "current_version=${CURRENT_VERSION}" >> "${GITHUB_OUTPUT}"
 | 
			
		||||
        echo "latest_version=${LATEST_VERSION}" >> "${GITHUB_OUTPUT}"
 | 
			
		||||
        
 | 
			
		||||
        # Determine if we should build
 | 
			
		||||
        if [ "$CURRENT_VERSION" != "$LATEST_VERSION" ]; then
 | 
			
		||||
          echo "should_build=true" >> $GITHUB_OUTPUT
 | 
			
		||||
          echo "Build required: Version changed"
 | 
			
		||||
        # Always build on push, build on schedule if versions differ
 | 
			
		||||
        if [[ "${IS_PUSH}" == "true" || "${CURRENT_VERSION}" != "${LATEST_VERSION}" ]]; then
 | 
			
		||||
          echo "should_build=true" >> "${GITHUB_OUTPUT}"
 | 
			
		||||
        else
 | 
			
		||||
          echo "should_build=false" >> $GITHUB_OUTPUT
 | 
			
		||||
          echo "No build required: Version unchanged"
 | 
			
		||||
          echo "should_build=false" >> "${GITHUB_OUTPUT}"
 | 
			
		||||
        fi
 | 
			
		||||
 | 
			
		||||
  update-version:
 | 
			
		||||
    needs: [check-version]
 | 
			
		||||
    if: needs.check-version.outputs.should_build == 'true' && needs.check-version.outputs.current_version != needs.check-version.outputs.latest_version
 | 
			
		||||
    needs: check-version
 | 
			
		||||
    # Only update version during scheduled runs when new version is available
 | 
			
		||||
    if: ${{ needs.check-version.outputs.should_build == 'true' && needs.check-version.outputs.is_push_trigger == 'false' && needs.check-version.outputs.current_version != needs.check-version.outputs.latest_version }}
 | 
			
		||||
    runs-on: ubuntu-latest
 | 
			
		||||
    
 | 
			
		||||
    steps:
 | 
			
		||||
@@ -74,10 +73,10 @@ jobs:
 | 
			
		||||
        LATEST_VERSION="${{ needs.check-version.outputs.latest_version }}"
 | 
			
		||||
        CURRENT_VERSION="${{ needs.check-version.outputs.current_version }}"
 | 
			
		||||
        
 | 
			
		||||
        echo "Updating APKBUILD from $CURRENT_VERSION to $LATEST_VERSION"
 | 
			
		||||
        echo "Updating APKBUILD from ${CURRENT_VERSION} to ${LATEST_VERSION}"
 | 
			
		||||
        
 | 
			
		||||
        # Update pkgver
 | 
			
		||||
        sed -i "s/^pkgver=.*/pkgver=$LATEST_VERSION/" zabbix-apk-builder/APKBUILD
 | 
			
		||||
        sed -i "s/^pkgver=.*/pkgver=${LATEST_VERSION}/" zabbix-apk-builder/APKBUILD
 | 
			
		||||
        
 | 
			
		||||
        # Reset pkgrel to 0 for new version
 | 
			
		||||
        sed -i "s/^pkgrel=.*/pkgrel=0/" zabbix-apk-builder/APKBUILD
 | 
			
		||||
@@ -85,28 +84,44 @@ jobs:
 | 
			
		||||
        # Clear checksums (will be regenerated during build)
 | 
			
		||||
        sed -i 's/^sha512sums=.*/sha512sums="SKIP"/' zabbix-apk-builder/APKBUILD
 | 
			
		||||
        
 | 
			
		||||
        # Commit changes
 | 
			
		||||
        # Commit changes with [ci skip] to prevent recursive triggers
 | 
			
		||||
        git config --local user.email "action@gitea.com"
 | 
			
		||||
        git config --local user.name "Gitea Action"
 | 
			
		||||
        git add zabbix-apk-builder/APKBUILD
 | 
			
		||||
        git commit -m "CHANGE: Update Zabbix to version $LATEST_VERSION [ci skip]" || exit 0
 | 
			
		||||
        git commit -m "AUTO: Update Zabbix to version ${LATEST_VERSION} [ci skip]" || exit 0
 | 
			
		||||
        git push
 | 
			
		||||
 | 
			
		||||
  build-packages:
 | 
			
		||||
    needs: [update-version] 
 | 
			
		||||
    if: needs.check-version.outputs.should_build == 'true'
 | 
			
		||||
    # Build packages after version update (for scheduled runs) or immediately (for push runs)
 | 
			
		||||
    needs: [check-version, update-version]
 | 
			
		||||
    # Run if should_build=true AND either update-version ran successfully OR it was skipped due to push trigger
 | 
			
		||||
    if: ${{ needs.check-version.outputs.should_build == 'true' && (success() || needs.check-version.outputs.is_push_trigger == 'true') }}
 | 
			
		||||
    runs-on: ubuntu-latest
 | 
			
		||||
    
 | 
			
		||||
    steps:
 | 
			
		||||
    - name: Checkout repository
 | 
			
		||||
      uses: actions/checkout@v4
 | 
			
		||||
      with:
 | 
			
		||||
        ref: ${{ gitea.head_ref }}
 | 
			
		||||
        # Use token to ensure we get the latest version if it was updated
 | 
			
		||||
        token: ${{ secrets.ACCESS_TOKEN }}
 | 
			
		||||
        ref: ${{ gitea.ref }}
 | 
			
		||||
 | 
			
		||||
    - name: Verify build environment
 | 
			
		||||
      run: |
 | 
			
		||||
        set -euo pipefail
 | 
			
		||||
        
 | 
			
		||||
        echo "=== Build Environment ==="
 | 
			
		||||
        echo "Trigger type: ${{ gitea.event_name }}"
 | 
			
		||||
        echo "Current branch: $(git branch --show-current)"
 | 
			
		||||
        echo "APKBUILD version: $(grep '^pkgver=' zabbix-apk-builder/APKBUILD | cut -d'=' -f2)"
 | 
			
		||||
        echo "Target version: ${{ needs.check-version.outputs.latest_version }}"
 | 
			
		||||
 | 
			
		||||
    - name: Set up Docker Buildx
 | 
			
		||||
      uses: docker/setup-buildx-action@v3
 | 
			
		||||
 | 
			
		||||
    - name: Build Zabbix packages
 | 
			
		||||
      env:
 | 
			
		||||
        CI_RUN_ID: ${{ gitea.run_id }}
 | 
			
		||||
      run: |
 | 
			
		||||
        set -euo pipefail
 | 
			
		||||
        
 | 
			
		||||
@@ -114,53 +129,75 @@ jobs:
 | 
			
		||||
        chmod +x build.sh
 | 
			
		||||
        ./build.sh
 | 
			
		||||
 | 
			
		||||
    - name: List built packages
 | 
			
		||||
    - name: Verify and list built packages
 | 
			
		||||
      run: |
 | 
			
		||||
        set -euo pipefail
 | 
			
		||||
    
 | 
			
		||||
        echo "Built packages:"
 | 
			
		||||
        ls -la zabbix-apk-builder/packages/
 | 
			
		||||
        cd zabbix-apk-builder
 | 
			
		||||
        
 | 
			
		||||
        echo "Package sizes:"
 | 
			
		||||
        du -h zabbix-apk-builder/packages/*.apk || echo "No packages found"
 | 
			
		||||
        # Verify packages exist somewhere
 | 
			
		||||
        PACKAGE_COUNT=$(find packages -name "*.apk" | wc -l)
 | 
			
		||||
        
 | 
			
		||||
        if [[ $PACKAGE_COUNT -eq 0 ]]; then
 | 
			
		||||
          echo "ERROR: No packages found"
 | 
			
		||||
          find packages -type f 2>/dev/null || echo "packages directory is empty"
 | 
			
		||||
          exit 1
 | 
			
		||||
        fi
 | 
			
		||||
        
 | 
			
		||||
        echo "Found $PACKAGE_COUNT packages:"
 | 
			
		||||
        find packages -name "*.apk" -exec ls -lh {} \;
 | 
			
		||||
 | 
			
		||||
    - name: Upload packages as artifacts
 | 
			
		||||
      uses: actions/upload-artifact@v4
 | 
			
		||||
      uses: actions/upload-artifact@v3
 | 
			
		||||
      with:
 | 
			
		||||
        name: zabbix-apk-packages
 | 
			
		||||
        path: zabbix-apk-builder/packages/*.apk
 | 
			
		||||
        name: zabbix-apk-packages-${{ gitea.run_number }}
 | 
			
		||||
        path: zabbix-apk-builder/packages/**/*.apk
 | 
			
		||||
        retention-days: 30
 | 
			
		||||
        if-no-files-found: error
 | 
			
		||||
 | 
			
		||||
  deploy-test:
 | 
			
		||||
    needs: [build-packages] 
 | 
			
		||||
    if: needs.check-version.outputs.should_build == 'true' && gitea.ref == 'refs/heads/test'
 | 
			
		||||
    needs: [check-version, build-packages]
 | 
			
		||||
    if: ${{ needs.check-version.outputs.should_build == 'true' && contains(gitea.ref, 'test') }}
 | 
			
		||||
    runs-on: ubuntu-latest
 | 
			
		||||
    
 | 
			
		||||
    steps:
 | 
			
		||||
    - name: Download packages
 | 
			
		||||
      uses: actions/download-artifact@v4
 | 
			
		||||
      uses: actions/download-artifact@v3
 | 
			
		||||
      with:
 | 
			
		||||
        name: zabbix-apk-packages
 | 
			
		||||
        name: zabbix-apk-packages-${{ gitea.run_number }}
 | 
			
		||||
        path: packages/
 | 
			
		||||
 | 
			
		||||
    - name: Test deployment in Alpine container
 | 
			
		||||
      run: |
 | 
			
		||||
        set -euo pipefail
 | 
			
		||||
        
 | 
			
		||||
        echo "Testing package installation..."
 | 
			
		||||
        # Find packages
 | 
			
		||||
        AGENT_PKG=$(find packages -name "zabbix-agent-*.apk" | head -1)
 | 
			
		||||
        PROXY_PKG=$(find packages -name "zabbix-proxy-*.apk" | head -1)
 | 
			
		||||
        
 | 
			
		||||
        # Test agent package
 | 
			
		||||
        docker run --rm -v $PWD/packages:/packages alpine:latest sh -c "
 | 
			
		||||
          apk add --allow-untrusted /packages/zabbix-agent-*.apk
 | 
			
		||||
          which zabbix_agentd
 | 
			
		||||
          zabbix_agentd --version
 | 
			
		||||
        " || echo "Agent test failed"
 | 
			
		||||
        # Test function
 | 
			
		||||
        test_package() {
 | 
			
		||||
          local pkg="$1"
 | 
			
		||||
          local binary="$2"
 | 
			
		||||
          
 | 
			
		||||
        # Test proxy package  
 | 
			
		||||
        docker run --rm -v $PWD/packages:/packages alpine:latest sh -c "
 | 
			
		||||
          apk add --allow-untrusted /packages/zabbix-proxy-*.apk
 | 
			
		||||
          which zabbix_proxy
 | 
			
		||||
          zabbix_proxy --version
 | 
			
		||||
        " || echo "Proxy test failed"
 | 
			
		||||
          if [[ -f "$pkg" ]]; then
 | 
			
		||||
            echo "Testing $(basename "$pkg")..."
 | 
			
		||||
            CONTAINER_ID=$(docker run -d alpine:latest sleep 30)
 | 
			
		||||
            docker cp "$pkg" "$CONTAINER_ID:/$(basename "$pkg")"
 | 
			
		||||
            if docker exec "$CONTAINER_ID" sh -c "
 | 
			
		||||
              apk add --allow-untrusted /$(basename "$pkg") >/dev/null 2>&1
 | 
			
		||||
              which $binary >/dev/null 2>&1
 | 
			
		||||
              $binary --version >/dev/null 2>&1
 | 
			
		||||
            "; then
 | 
			
		||||
              echo "SUCCESS: $(basename "$pkg") test passed"
 | 
			
		||||
            else
 | 
			
		||||
              echo "FAIL: $(basename "$pkg") test failed"
 | 
			
		||||
            fi
 | 
			
		||||
            docker rm -f "$CONTAINER_ID" >/dev/null
 | 
			
		||||
          else
 | 
			
		||||
            echo "ERROR: Package not found: $pkg"
 | 
			
		||||
          fi
 | 
			
		||||
        }
 | 
			
		||||
        
 | 
			
		||||
        echo "✅ Package deployment test completed"
 | 
			
		||||
        test_package "$AGENT_PKG" "zabbix_agentd"
 | 
			
		||||
        test_package "$PROXY_PKG" "zabbix_proxy"
 | 
			
		||||
							
								
								
									
										1
									
								
								zabbix-apk-builder/.gitignore
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										1
									
								
								zabbix-apk-builder/.gitignore
									
									
									
									
										vendored
									
									
								
							@@ -9,6 +9,7 @@ src/
 | 
			
		||||
 | 
			
		||||
# Backup files
 | 
			
		||||
*.backup
 | 
			
		||||
*.bak
 | 
			
		||||
*~
 | 
			
		||||
 | 
			
		||||
# OS files
 | 
			
		||||
 
 | 
			
		||||
@@ -1,7 +1,7 @@
 | 
			
		||||
# Contributor: Maksym Buz <maksym.buz@zabbix.com>
 | 
			
		||||
# Maintainer: Maksym Buz <maksym.buz@zabbix.com>
 | 
			
		||||
pkgname=zabbix
 | 
			
		||||
pkgver=7.4.1
 | 
			
		||||
pkgver=7.4.2
 | 
			
		||||
pkgrel=0
 | 
			
		||||
pkgdesc="Enterprise-class open source distributed monitoring solution"
 | 
			
		||||
url="https://www.zabbix.com/"
 | 
			
		||||
@@ -138,9 +138,9 @@ proxy() {
 | 
			
		||||
	install -dm755 "$subpkgdir"/var/log/zabbix
 | 
			
		||||
	install -dm755 "$subpkgdir"/var/run/zabbix
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
sha512sums="SKIP"
 | 
			
		||||
3bf1f915c2cd5a59f1dd3afc10dd1a6e596840e576013839d6eae057cd327893f87cc5cec1d32b6a8ca8bd00735c0070327084aae01dc8d3399202f5a3e365c1  zabbix-7.4.2.tar.gz
 | 
			
		||||
# --- TEST --- 
 | 
			
		||||
sha512sums="
 | 
			
		||||
SKIP
 | 
			
		||||
SKIP
 | 
			
		||||
SKIP
 | 
			
		||||
SKIP
 | 
			
		||||
 
 | 
			
		||||
@@ -36,5 +36,32 @@ COPY --chown=builder:builder . /home/builder/zabbix/
 | 
			
		||||
 | 
			
		||||
WORKDIR /home/builder/zabbix
 | 
			
		||||
 | 
			
		||||
# Create build script that just builds packages
 | 
			
		||||
USER root
 | 
			
		||||
RUN cat > /usr/local/bin/build-packages.sh << 'EOF'
 | 
			
		||||
#!/bin/sh
 | 
			
		||||
set -e
 | 
			
		||||
 | 
			
		||||
echo "Building packages as builder user..."
 | 
			
		||||
sudo -u builder sh -c "
 | 
			
		||||
    cd /home/builder/zabbix
 | 
			
		||||
    echo 'Generating checksums...'
 | 
			
		||||
    abuild checksum
 | 
			
		||||
    echo 'Building packages...'
 | 
			
		||||
    abuild -r
 | 
			
		||||
"
 | 
			
		||||
 | 
			
		||||
echo "Build complete! Packages built in /home/builder/packages:"
 | 
			
		||||
find /home/builder/packages -name "*.apk" -exec ls -la {} \;
 | 
			
		||||
 | 
			
		||||
echo "Setting proper permissions on packages..."
 | 
			
		||||
chmod 644 /home/builder/packages/*.apk 2>/dev/null || true
 | 
			
		||||
 | 
			
		||||
echo "Final package list (excluding APKINDEX):"
 | 
			
		||||
find /home/builder/packages -name "*.apk" -exec ls -la {} \;
 | 
			
		||||
EOF
 | 
			
		||||
 | 
			
		||||
RUN chmod +x /usr/local/bin/build-packages.sh
 | 
			
		||||
 | 
			
		||||
# Set build command
 | 
			
		||||
CMD ["abuild", "-r"]
 | 
			
		||||
CMD ["/usr/local/bin/build-packages.sh"]
 | 
			
		||||
@@ -4,8 +4,7 @@ Automated Alpine Linux package builder for Zabbix Agent and Proxy with CI/CD pip
 | 
			
		||||
 | 
			
		||||
## Features
 | 
			
		||||
 | 
			
		||||
- 🔄 **Automatic Version Detection**: Monitors Zabbix releases using official Bitbucket API
 | 
			
		||||
- 🏗️ **Docker-based Building**: Consistent, reproducible builds in isolated environment
 | 
			
		||||
- 🔄 **Automatic Version Detection**: Monitors Zabbix releases using Bitbucket API
 | 
			
		||||
- 🚀 **CI/CD Pipeline**: Full automation from version detection to package deployment
 | 
			
		||||
- 📦 **Multi-package Support**: Builds agent and proxy packages
 | 
			
		||||
- 🧪 **Automated Testing**: Tests package installation in Alpine containers
 | 
			
		||||
@@ -13,34 +12,24 @@ Automated Alpine Linux package builder for Zabbix Agent and Proxy with CI/CD pip
 | 
			
		||||
 | 
			
		||||
## Quick Start
 | 
			
		||||
 | 
			
		||||
### 1. Repository Setup
 | 
			
		||||
### Prerequisites
 | 
			
		||||
 | 
			
		||||
- Docker installed
 | 
			
		||||
- Gitea repository with Actions enabled
 | 
			
		||||
 | 
			
		||||
### Manual Build
 | 
			
		||||
 | 
			
		||||
```bash
 | 
			
		||||
# Clone this repository
 | 
			
		||||
git clone https://git.mbuz.uk/mbuz/Zabbix.git
 | 
			
		||||
# Clone the repository
 | 
			
		||||
git clone <your-gitea-repo>
 | 
			
		||||
cd zabbix-apk-builder
 | 
			
		||||
 | 
			
		||||
# Make build script executable
 | 
			
		||||
chmod +x build.sh
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
### 2. Manual Build
 | 
			
		||||
 | 
			
		||||
```bash
 | 
			
		||||
# Build packages locally
 | 
			
		||||
chmod +x build.sh
 | 
			
		||||
./build.sh
 | 
			
		||||
 | 
			
		||||
# Packages will be in ./packages/
 | 
			
		||||
ls -la packages/
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
### 3. CI/CD Setup
 | 
			
		||||
 | 
			
		||||
```bash
 | 
			
		||||
# Run the setup script
 | 
			
		||||
./setup-cicd.sh
 | 
			
		||||
 | 
			
		||||
# Follow the prompts to configure GitHub secrets
 | 
			
		||||
# Check built packages
 | 
			
		||||
ls -la packages/builder/x86_64/
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
## Package Information
 | 
			
		||||
@@ -51,19 +40,12 @@ ls -la packages/
 | 
			
		||||
2. **zabbix-proxy** - Zabbix Proxy
 | 
			
		||||
3. **zabbix** - Meta package
 | 
			
		||||
 | 
			
		||||
### Current Version
 | 
			
		||||
 | 
			
		||||
- **Zabbix Version**: 7.4.2
 | 
			
		||||
- **Alpine Base**: latest
 | 
			
		||||
- **Architecture**: all
 | 
			
		||||
 | 
			
		||||
## CI/CD Pipeline
 | 
			
		||||
 | 
			
		||||
### Automatic Triggers
 | 
			
		||||
 | 
			
		||||
- **Daily**: Checks for new Zabbix versions at 6 AM UTC
 | 
			
		||||
- **Push**: Builds when code changes in main/test branches
 | 
			
		||||
- **Manual**: Force builds via Gitea Actions
 | 
			
		||||
 | 
			
		||||
### Version Detection
 | 
			
		||||
 | 
			
		||||
@@ -91,48 +73,22 @@ GITEA_SSH_KEY  # SSH private key for Gitea access
 | 
			
		||||
### File Structure
 | 
			
		||||
 | 
			
		||||
```
 | 
			
		||||
.
 | 
			
		||||
└── zabbix-git
 | 
			
		||||
    └── zabbix-apk-builder
 | 
			
		||||
        ├── .gitea/workflows   # Workflows for Gitea actions
 | 
			
		||||
        ├── .gitignore         # Ignore files 
 | 
			
		||||
        ├── APKBUILD           # APKBUILD file for Zabbix
 | 
			
		||||
        ├── Dockerfile         # Dockerfile for building packages
 | 
			
		||||
        ├── README.md          # Project description
 | 
			
		||||
        ├── build.sh           # Script for manual builds
 | 
			
		||||
        ├── packages/          # Directory for built packages
 | 
			
		||||
        ├── zabbix-agent.*     # Agent configuration files
 | 
			
		||||
        └── zabbix-proxy.*     # Proxy configuration files
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
## Usage
 | 
			
		||||
 | 
			
		||||
### Install Packages
 | 
			
		||||
 | 
			
		||||
```bash
 | 
			
		||||
# Add repository
 | 
			
		||||
echo "http://gitea-repo/mbuz/Zabbix/raw/branch/main/alpine/v3.18/main" >> /etc/apk/repositories
 | 
			
		||||
 | 
			
		||||
# Update and install
 | 
			
		||||
apk update
 | 
			
		||||
apk add zabbix-agent
 | 
			
		||||
 | 
			
		||||
# Enable and start
 | 
			
		||||
rc-update add zabbix-agent default
 | 
			
		||||
rc-service zabbix-agent start
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
### Configuration
 | 
			
		||||
 | 
			
		||||
```bash
 | 
			
		||||
# Configure agent
 | 
			
		||||
vim /etc/zabbix/zabbix_agentd.conf
 | 
			
		||||
 | 
			
		||||
# Set server IP
 | 
			
		||||
Server=your.zabbix.server
 | 
			
		||||
 | 
			
		||||
# Restart service
 | 
			
		||||
rc-service zabbix-agent restart
 | 
			
		||||
zabbix-git/
 | 
			
		||||
└── zabbix-apk-builder/
 | 
			
		||||
    ├── .gitea/
 | 
			
		||||
    │   └── workflows/
 | 
			
		||||
    │       └── build.yaml         # Main CI/CD pipeline
 | 
			
		||||
    ├── APKBUILD                   # Alpine package definition
 | 
			
		||||
    ├── Dockerfile                 # Build environment container
 | 
			
		||||
    ├── README.md                  # This file
 | 
			
		||||
    ├── build.sh                   # Local build script
 | 
			
		||||
    ├── packages/                  # Generated packages (gitignored)
 | 
			
		||||
    ├── zabbix-agent.confd         # Agent configuration
 | 
			
		||||
    ├── zabbix-agent.initd         # Agent init script
 | 
			
		||||
    ├── zabbix-agent.pre-install   # Agent pre-install script
 | 
			
		||||
    ├── zabbix-proxy.confd         # Proxy configuration  
 | 
			
		||||
    ├── zabbix-proxy.initd         # Proxy init script
 | 
			
		||||
    └── zabbix-proxy.pre-install   # Proxy pre-install script
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
## Development
 | 
			
		||||
@@ -154,28 +110,16 @@ docker run --rm -it \
 | 
			
		||||
 | 
			
		||||
### Branch Strategy
 | 
			
		||||
 | 
			
		||||
- **main**: Production releases, auto-deployed
 | 
			
		||||
- **test**: Testing and validation, no auto-deploy
 | 
			
		||||
- **main**: Production releases, merge only
 | 
			
		||||
- **test**: Testing and validation
 | 
			
		||||
 | 
			
		||||
### Making Changes
 | 
			
		||||
 | 
			
		||||
1. Create feature branch from `test`
 | 
			
		||||
1. Create feature branch from `main`
 | 
			
		||||
2. Test changes thoroughly
 | 
			
		||||
3. Merge to `test` for CI validation
 | 
			
		||||
4. Merge to `main` for production release
 | 
			
		||||
3. Validate CI
 | 
			
		||||
4. Merge to `main`
 | 
			
		||||
 | 
			
		||||
## Troubleshooting
 | 
			
		||||
 | 
			
		||||
### Build Issues
 | 
			
		||||
 | 
			
		||||
```bash
 | 
			
		||||
# Check build logs
 | 
			
		||||
docker logs $(docker ps -l -q)
 | 
			
		||||
 | 
			
		||||
# Manual build debug
 | 
			
		||||
docker run -it --rm -v $(pwd):/build alpine:3.18 sh
 | 
			
		||||
cd /build && ./build.sh
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
### Version Detection
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -3,52 +3,57 @@
 | 
			
		||||
set -e
 | 
			
		||||
 | 
			
		||||
# Configuration
 | 
			
		||||
PROJECT_DIR="$(pwd)"
 | 
			
		||||
PROJECT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
 | 
			
		||||
IMAGE_NAME="zabbix-apk-builder"
 | 
			
		||||
CONTAINER_NAME="zabbix-build-$$"
 | 
			
		||||
# Use a unique ID from the CI environment if available, otherwise fall back to PID
 | 
			
		||||
UNIQUE_ID="${CI_RUN_ID:-$$}"
 | 
			
		||||
CONTAINER_NAME="zabbix-build-${UNIQUE_ID}"
 | 
			
		||||
OUTPUT_DIR="$PROJECT_DIR/packages"
 | 
			
		||||
 | 
			
		||||
echo "=== Zabbix APK Builder ==="
 | 
			
		||||
echo "Project directory: $PROJECT_DIR"
 | 
			
		||||
echo "Output directory: $OUTPUT_DIR"
 | 
			
		||||
 | 
			
		||||
# Clean up any existing containers
 | 
			
		||||
# Clean up function
 | 
			
		||||
cleanup() {
 | 
			
		||||
    echo "Cleaning up..."
 | 
			
		||||
    docker rm -f "$CONTAINER_NAME" 2>/dev/null || true
 | 
			
		||||
    echo "Cleaning up container..."
 | 
			
		||||
    docker rm -f "$CONTAINER_NAME" >/dev/null 2>&1 || true
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
trap cleanup EXIT
 | 
			
		||||
 | 
			
		||||
# Create output directory
 | 
			
		||||
# Clean and create output directory
 | 
			
		||||
rm -rf "$OUTPUT_DIR"
 | 
			
		||||
mkdir -p "$OUTPUT_DIR"
 | 
			
		||||
 | 
			
		||||
# Build Docker image
 | 
			
		||||
echo "Building Docker image..."
 | 
			
		||||
docker build -t "$IMAGE_NAME" "$PROJECT_DIR"
 | 
			
		||||
 | 
			
		||||
# Run the build in container
 | 
			
		||||
echo "Running package build..."
 | 
			
		||||
docker run --rm \
 | 
			
		||||
    --name "$CONTAINER_NAME" \
 | 
			
		||||
    -v "$OUTPUT_DIR:/output" \
 | 
			
		||||
    "$IMAGE_NAME" \
 | 
			
		||||
    sh -c "
 | 
			
		||||
        set -e
 | 
			
		||||
        echo 'Starting package build...'
 | 
			
		||||
# Run the build in the container
 | 
			
		||||
echo "Running package build in container..."
 | 
			
		||||
docker run --name "$CONTAINER_NAME" "$IMAGE_NAME"
 | 
			
		||||
 | 
			
		||||
        # Generate checksums for APKBUILD
 | 
			
		||||
        echo 'Generating checksums for APKBUILD...'
 | 
			
		||||
        abuild checksum
 | 
			
		||||
# Copy packages from container to host
 | 
			
		||||
echo "Copying packages from container..."
 | 
			
		||||
if docker cp "$CONTAINER_NAME:/home/builder/packages/." "$OUTPUT_DIR/"; then
 | 
			
		||||
    echo "✅ Packages copied successfully"
 | 
			
		||||
    
 | 
			
		||||
        # Build packages
 | 
			
		||||
        abuild -r
 | 
			
		||||
    # Remove APKINDEX files (we only want the .apk packages)
 | 
			
		||||
    echo "Removing repository index files..."
 | 
			
		||||
    find "$OUTPUT_DIR" -name "APKINDEX.tar.gz" -delete 2>/dev/null || true
 | 
			
		||||
    
 | 
			
		||||
        # Copy packages to output
 | 
			
		||||
        echo 'Copying packages to output directory...'
 | 
			
		||||
        find /home/builder/packages -name '*.apk' -exec cp {} /output/ \;
 | 
			
		||||
    "
 | 
			
		||||
echo "Build completed successfully!"
 | 
			
		||||
echo "To install packages:"
 | 
			
		||||
echo "  apk add --allow-untrusted $OUTPUT_DIR/zabbix-agent-*.apk"
 | 
			
		||||
echo "  apk add --allow-untrusted $OUTPUT_DIR/zabbix-proxy-*.apk"
 | 
			
		||||
    # Fix permissions on copied files
 | 
			
		||||
    echo "Fixing file permissions..."
 | 
			
		||||
    find "$OUTPUT_DIR" -name "*.apk" -exec chmod 644 {} \; 2>/dev/null || true
 | 
			
		||||
    
 | 
			
		||||
    echo "Build completed successfully!"
 | 
			
		||||
    echo "Packages are in $OUTPUT_DIR:"
 | 
			
		||||
    find "$OUTPUT_DIR" -name "*.apk" -exec ls -la {} \;
 | 
			
		||||
else
 | 
			
		||||
    echo "❌ Failed to copy packages"
 | 
			
		||||
    echo "Checking what's in the container..."
 | 
			
		||||
    docker exec "$CONTAINER_NAME" find /home/builder -name "*.apk" -exec ls -la {} \; 2>/dev/null || true
 | 
			
		||||
    docker exec "$CONTAINER_NAME" ls -la /home/builder/packages/ 2>/dev/null || true
 | 
			
		||||
    exit 1
 | 
			
		||||
fi
 | 
			
		||||
		Reference in New Issue
	
	Block a user