FROM debian:11

ARG TRAVIS_JOB_NUMBER

# Setup
RUN apt-get update -y -qq
RUN apt-get install -y apt-utils build-essential file wget bzip2 git gcc g++ cmake cmake-data ninja-build qtbase5-dev-tools qtdeclarative5-dev -qq


RUN mkdir -p /src/
RUN git clone https://github.com/aymara/nind /src/nind

RUN mkdir -p /src/nind/build

# Build
WORKDIR /src/nind/build
RUN cmake -G Ninja -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_BUILD_TYPE=Release ..
RUN ninja package
RUN echo "export packagefile=`find /src/nind/build/ -maxdepth 1 -name *.deb`" > /envfile
RUN echo "export fullname=\$(basename -- \$packagefile)" >> /envfile
RUN echo "export extension=\${fullname##*.}" >> /envfile
RUN echo "export filename=\${fullname%.*}" >> /envfile
RUN . /envfile && install -D ${packagefile} "/usr/share/apps/nind/packages/${filename}-debian11.deb"


# install github-release to be able to deploy packages
RUN /usr/bin/wget https://github.com/aktau/github-release/releases/download/v0.7.2/linux-amd64-github-release.tar.bz2 && /bin/tar xjf linux-amd64-github-release.tar.bz2 && /bin/cp bin/linux/amd64/github-release /usr/bin
