version: '3.8'

services:
  builder:
    image: fedora:latest
    volumes:
      - ../release:/release:rw
      - .:/pkg:ro
      - ../..:/src:ro
    command: >
      bash -c "
        echo Building wikiman-${PKGVER}-${PKGREL} for Fedora... &&
        export PKGVER="${PKGVER}" &&
        export PKGREL="${PKGREL}" &&
        echo 'max_parallel_downloads=10' >> /etc/dnf/dnf.conf &&
        dnf install -y rpm-build make &&
        mkdir -p ~/rpmbuild/SOURCES &&
        mkdir -p ~/rpmbuild/SPECS &&
        cp /src/pkg/rpm/.spec ~/rpmbuild/SPECS/wikiman.spec &&
        cp -arp /src ~/wikiman-${PKGVER} &&
        cd ~
        tar czf ~/rpmbuild/SOURCES/${PKGVER}.tar.gz ./wikiman-${PKGVER} &&
        rpmbuild -bb ~/rpmbuild/SPECS/wikiman.spec &&
        mv ~/rpmbuild/RPMS/noarch/wikiman-${PKGVER}-${PKGREL}.* /release/wikiman-${PKGVER}-${PKGREL}.noarch.rpm &&
        chown ${UID}:${UID} /release/wikiman-${PKGVER}-${PKGREL}.noarch.rpm &&
        echo Build completed successfully!
      "