FROM registry.fedoraproject.org/fedora:34

# Install generic dependencies to build jss and pki
RUN true \
        && dnf update -y --refresh \
        && dnf install -y dnf-plugins-core gcc make rpm-build \
        && dnf copr -y enable ${JSS_4_6_REPO:-@pki/10.12} \
        && dnf build-dep -y jss pki-core \
        && mkdir -p /home/sandbox \
        && git clone -b v10.11 https://github.com/dogtagpki/pki /home/sandbox/pki \
        && dnf clean -y all \
        && true

# Link in the current version of jss from the git repository
WORKDIR /home/sandbox
COPY . /home/sandbox/jss

# Install dependencies from the spec file in case they've changed
# since the last release on this platform.
RUN true \
        && dnf build-dep -y --spec /home/sandbox/jss/jss.spec \
        && dnf build-dep -y --spec /home/sandbox/pki/pki.spec \
        && true

# Perform the actual RPM build
WORKDIR /home/sandbox/jss
CMD true \
        && bash ./build.sh --with-timestamp --with-commit-id rpm \
        && dnf install -y /root/build/jss/RPMS/*.rpm \
        && cd /home/sandbox/pki \
        && bash ./build.sh --with-timestamp --with-commit-id rpm \
        && dnf install -y /root/build/pki/RPMS/*.rpm \
        && true
