FROM registry.fedoraproject.org/fedora:rawhide

# Install generic dependencies to build jss
RUN true \
        && dnf update -y --refresh \
        && dnf install -y dnf-plugins-core gcc make rpm-build cmake \
                          java-11-openjdk nss-tools \
                          apache-commons-lang3 gcc-c++ java-11-openjdk-devel \
                          jpackage-utils slf4j nss zlib-devel nss-devel \
                          nspr-devel slf4j-jdk14 junit \
        && mkdir -p /home/sandbox \
        && dnf clean -y all \
        && rm -rf /usr/share/doc /usr/share/doc-base \
                  /usr/share/man /usr/share/locale /usr/share/zoneinfo \
        && true

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

# Perform the actual RPM build
WORKDIR /home/sandbox/jss
CMD true \
        && export JAVA_HOME=/usr/lib/jvm/jre-11-openjdk \
        && export WITH_INTERNET=1 \
        && rm -rf build \
        && mkdir build \
        && cd build \
        && cmake .. \
        && make all \
        && ctest --output-on-failure \
        && make javadoc \
        && true
