Build Builder Images #4
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: 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: Create inline Dockerfile | |
| run: | | |
| cat > Dockerfile.builder <<'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 | |
| - name: Build and push builder image | |
| uses: docker/build-push-action@v5 | |
| with: | |
| context: . | |
| file: Dockerfile.builder | |
| 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 }} |