FROM opensuse/tumbleweed

# Set locale to prevent UTF-8 errors
ENV LANG=C.UTF-8
ENV LC_ALL=C.UTF-8

RUN zypper refresh && \
    zypper install -y \
        gcc \
        gcc-c++ \
        git \
        htop \
        intltool \
        lftp \
        libffi-devel \
        libopenssl-devel \
        librsync-devel \
        lsof \
        make \
        nano \
        openssl \
        par2cmdline \
        python3 \
        python3-cryptography \
        python3-devel \
        python3-pip \
        rclone \
        rdiff \
        rsync \
        timezone \
        which

WORKDIR /root/
COPY requirements.dev ./
COPY requirements.txt ./

RUN <<EOF
set -e
# install requirements
# don't muck about with venv setup in isolated environ
python3 -m pip config set global.break-system-packages true
python3 -m pip install -U --ignore-installed -r requirements.dev
python3 -m pip install -U --ignore-installed -r requirements.txt

# cleanup the noise left over
echo "Cleaning up"
rm -rf /root/.cache/pip
rm -rf /root/requirements.*
rm -rf /var/lib/apt/lists/*
EOF

COPY gnupg/ /root/.gnupg/
RUN <<EOF
set -e
# fixup /root/.bashrc
cat <<CAT >> /root/.bashrc
# added by dupCI
alias ll='ls -l'
alias la='ls -A'
CAT
cat <<CAT >> /root/.bash_profile
# added by dupCI
gpg-agent --daemon --enable-ssh-support --verbose
GPG_TTY=$(tty)
export GPG_TTY
CAT
chmod -R 700 /root/.gnupg
EOF

ENV DOCKER_GNUPGHOME=/root/.gnupg

WORKDIR /root/duplicity/
RUN <<EOF
set -e
# fixup /root/.bashrc
cat <<CAT >> /root/.bashrc
# added for interactive use
alias ll='ls -l'
alias la='ls -A'
GPG_TTY=\$(tty)
export GPG_TTY
CAT
cat <<CAT >> /root/.bash_profile
# added for interactive use
test -f ~/.bashrc && . ~/.bashrc
CAT
EOF

CMD ["/bin/bash"]
