Build Builder Images #9
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Build Builder Images | |
| on: | |
| workflow_dispatch: # Manual trigger | |
| schedule: | |
| - cron: '0 0 * * 0' # Weekly on Sunday | |
| push: | |
| paths: | |
| - 'scripts/build-dependencies.sh' | |
| jobs: | |
| build-builder: | |
| runs-on: ubuntu-latest | |
| strategy: | |
| matrix: | |
| distro: [debian, ubuntu] | |
| codename: [bookworm, bullseye, trixie, focal, jammy, noble, plucky, questing, resolute] | |
| exclude: | |
| - distro: debian | |
| codename: focal | |
| - distro: debian | |
| codename: jammy | |
| - distro: debian | |
| codename: noble | |
| - distro: debian | |
| codename: plucky | |
| - distro: debian | |
| codename: questing | |
| - distro: debian | |
| codename: resolute | |
| - distro: ubuntu | |
| codename: bookworm | |
| - distro: ubuntu | |
| codename: bullseye | |
| - distro: ubuntu | |
| codename: trixie | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Debug - Show current directory and files | |
| run: | | |
| echo "Current directory:" | |
| pwd | |
| echo "Directory contents:" | |
| ls -la | |
| echo "Scripts directory:" | |
| ls -la scripts/ || echo "scripts/ not found" | |
| echo "Looking for build-dependencies.sh:" | |
| find . -name "build-dependencies.sh" -type f | |
| - name: Setup QEMU | |
| uses: docker/setup-qemu-action@v3 | |
| - name: Setup Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Login to GitHub Container Registry | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Prepare build context | |
| run: | | |
| # Verify we're in the right place | |
| echo "Working directory: $(pwd)" | |
| # Verify the script exists | |
| if [ ! -f "scripts/build-dependencies.sh" ]; then | |
| echo "ERROR: scripts/build-dependencies.sh not found!" | |
| echo "Contents of current directory:" | |
| ls -la | |
| echo "Contents of scripts directory (if exists):" | |
| ls -la scripts/ || echo "scripts directory not found" | |
| exit 1 | |
| fi | |
| # Create a clean build directory | |
| mkdir -p docker-build-context/scripts | |
| # Copy the build script | |
| cp scripts/build-dependencies.sh docker-build-context/scripts/ | |
| # Verify it's there | |
| echo "Build context contents:" | |
| ls -la docker-build-context/ | |
| ls -la docker-build-context/scripts/ | |
| # Create Dockerfile in the build context | |
| cat > docker-build-context/Dockerfile <<'EOF' | |
| ARG DISTRO=debian | |
| ARG CODENAME=bookworm | |
| FROM ${DISTRO}:${CODENAME} | |
| # Install build dependencies | |
| RUN apt-get update && apt-get install -y \ | |
| debhelper cmake g++ git pkg-config \ | |
| libusb-1.0-0-dev libzmq3-dev libpq-dev \ | |
| libssl-dev libsqlite3-dev zlib1g-dev \ | |
| libairspy-dev libairspyhf-dev libhackrf-dev \ | |
| && rm -rf /var/lib/apt/lists/* | |
| # Create directory for pre-built dependencies | |
| RUN mkdir -p /deps | |
| # Copy build script | |
| COPY scripts/build-dependencies.sh /tmp/build-dependencies.sh | |
| RUN chmod +x /tmp/build-dependencies.sh | |
| # Build dependencies and store in /deps | |
| WORKDIR /tmp/build | |
| RUN /tmp/build-dependencies.sh /usr/lib/ais-catcher NMEA2000 /tmp/build && \ | |
| mv rtl-sdr /deps/ && \ | |
| mv rfone_host /deps/ && \ | |
| mv NMEA2000 /deps/ && \ | |
| rm -rf /tmp/build | |
| # Set working directory for builds | |
| WORKDIR /workspace | |
| EOF | |
| echo "Dockerfile created:" | |
| cat docker-build-context/Dockerfile | |
| - name: Build and push builder image | |
| uses: docker/build-push-action@v5 | |
| with: | |
| context: ./docker-build-context | |
| file: ./docker-build-context/Dockerfile | |
| build-args: | | |
| DISTRO=${{ matrix.distro }} | |
| CODENAME=${{ matrix.codename }} | |
| platforms: linux/amd64,linux/arm64,linux/arm/v7 | |
| push: true | |
| tags: | | |
| ghcr.io/${{ github.repository_owner }}/ais-catcher-builder:${{ matrix.distro }}-${{ matrix.codename }} | |
| ghcr.io/${{ github.repository_owner }}/ais-catcher-builder:${{ matrix.distro }}-${{ matrix.codename }}-${{ github.sha }} | |
| cache-from: type=gha,scope=${{ matrix.distro }}-${{ matrix.codename }} | |
| cache-to: type=gha,mode=max,scope=${{ matrix.distro }}-${{ matrix.codename }} |