FROM debian:testing

# Install generic dependencies to build jss
RUN true \
        && export DEBIAN_FRONTEND=noninteractive \
        && apt-get update \
        && apt-get dist-upgrade -y \
        && apt-get install -y debhelper libnss3-dev libnss3-tools libnss3 \
                              openjdk-11-jdk pkg-config quilt g++ mercurial \
                              zlib1g-dev libslf4j-java liblog4j2-java \
                              libcommons-lang3-java libjaxb-api-java cmake \
                              zip unzip junit4 \
        && mkdir -p /home/sandbox \
        && apt-get autoremove -y \
        && apt-get clean -y \
        && apt-get autoclean -y \
        && 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 build
WORKDIR /home/sandbox/jss
CMD true \
        && export JAVA_HOME=/usr/lib/jvm/java-11-openjdk-amd64 \
        && rm -rf build \
        && mkdir build \
        && cd build \
        && cmake .. \
        && make all \
        && ctest --output-on-failure \
        && make javadoc \
        && true
