FROM debian:bookworm-slim
 
# update package manager
RUN  apt-get update -y && \
     apt-get upgrade -y && \
     apt-get dist-upgrade -y && \
     apt-get -y autoremove && \
     apt-get clean
 
 
# install required packages
RUN apt-get install -y \
        curl \
        git \
        distcc \
        cmake \
        autoconf \
        autogen \
        automake \
        bison \
        build-essential \
        flex \
        libcppunit-dev \
        libcurl4-openssl-dev \
        libelf-dev \
        libncurses-dev \
        libsigc++-2.0-dev \
        libssl-dev \
        libtool\
        zlib1g-dev \
        pkg-config \
        pkgconf \
        libcurl4-openssl-dev \
        libxmlrpc-c++8-dev
 
# UTF-8 support
RUN apt-get install -y coreutils locales && \
    sed -i -e 's/# en_US.UTF-8 UTF-8/en_US.UTF-8 UTF-8/' /etc/locale.gen && \
    locale-gen && \
    dpkg-reconfigure --frontend=noninteractive locales && \
    update-locale LANG=en_US.UTF-8
 
# set environment variables
ENV LC_ALL=en_US.UTF-8
ENV LANG=en_US.UTF-8
ENV LANGUAGE=en_US.UTF-8
 
RUN mkdir -p /tmp/kitchen
WORKDIR /tmp/kitchen
 
RUN curl -fLs https://github.com/rakshasa/rtorrent/releases/download/v0.10.0/libtorrent-0.14.0.tar.gz -o libtorrent-0.14.0.tar.gz && \
    tar -xvf libtorrent-0.14.0.tar.gz && \
    cd libtorrent-0.14.0 && \
    DISTCC_HOSTS="docker1:35001 docker2:35002" CC=distcc CXX=distcc ./configure && \
    DISTCC_HOSTS="docker1:35001 docker2:35002" CC=distcc CXX=distcc make -j 4 && \
    make install
 
WORKDIR /tmp/kitchen
 
# install rtorrent
RUN curl -fLs https://github.com/rakshasa/rtorrent/releases/download/v0.10.0/rtorrent-0.10.0.tar.gz -o rtorrent-0.10.0.tar.gz && \
    tar -xvf rtorrent-0.10.0.tar.gz && \
    cd rtorrent-0.10.0 && \
    DISTCC_HOSTS="docker:35001 docker:35002" CC=distcc CXX="distcc g++" ./configure --with-xmlrpc-c --with-libcurl && \
    DISTCC_HOSTS="docker:35001 docker:35002" CC=distcc CXX="distcc g++" LDFLAGS="-std=c++11" make -j 4 && \
    make install
 
WORKDIR /tmp
RUN rm -rf /tmp/kitchen
 
# remove packages that will not be used
RUN apt-get purge -y \
        curl \
        git \
        build-essential \
        autoconf \
        automake \
        libtool \
        pkgconf \
        pkg-config && \
    apt-get autoremove -y
 
ENTRYPOINT [ "rtorrent" ]