# This file is part of BOINC.
# http://boinc.berkeley.edu
# Copyright (C) 2023 University of California
#
# BOINC is free software; you can redistribute it and/or modify it
# under the terms of the GNU Lesser General Public License
# as published by the Free Software Foundation,
# either version 3 of the License, or (at your option) any later version.
#
# BOINC is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# See the GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with BOINC.  If not, see <http://www.gnu.org/licenses/>.

# example build usage:
# LINUX: export BUILDKIT_PROGRESS=plain
# WINDOWS: set BUILDKIT_PROGRESS=plain
# docker build -t fedora38-boinc --build-arg PACKAGE=boinc-linux-client --build-arg VERSION=1.0.0-1 -f ./Dockerfile .

ARG DISTRO=fedora
ARG RELEASE=38

FROM $DISTRO:$RELEASE

# All args are cleared after a FROM instruction
ARG RELEASE=38

ARG REPOBASE=https://boinc.berkeley.edu/dl/linux
ARG REPOTYPE=stable
ARG PACKAGE=boinc-linux-client
ARG VERSION=7.23.0-1
ARG REPOKEY=boinc-202305.gpg

USER root

WORKDIR /root

RUN bash -c 'echo "defaultyes=True" >> /etc/dnf/dnf.conf'

RUN bash -c 'echo "fastestmirror=True" >> /etc/dnf/dnf.conf'

RUN bash -c 'echo "max_parallel_downloads=10" >> /etc/dnf/dnf.conf'

RUN bash -c 'dnf update && dnf -y install wget'

RUN bash -c 'cd /etc/yum.repos.d && wget $REPOBASE/$REPOTYPE/fc$RELEASE/boinc-${REPOTYPE}-fc${RELEASE}.repo'

RUN bash -c 'dnf update'

RUN bash -c 'dnf list | grep $PACKAGE'

RUN bash -c 'dnf -y install $PACKAGE-$VERSION'
