FROM centos:7

# Install generic dependencies to build jss
RUN true \
        && yum update -y \
        && yum install -y yum-plugins-core gcc make rpm-build yum-builddep \
        && yum-builddep -y jss \
        && mkdir -p /home/sandbox \
        && yum 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 \
        && bash ./build.sh spec \
        && yum-builddep -y /root/build/jss/SPECS/jss.spec \
        && bash ./build.sh --with-timestamp --with-commit-id rpm \
        && yum install -y /root/build/jss/RPMS/*.rpm \
        && true
