#FROM ubuntu:focal-20201008
FROM ubuntu@sha256:1d7b639619bdca2d008eca2d5293e3c43ff84cbee597ff76de3b7a7de3e84956

ENV DEBIAN_FRONTEND noninteractive

ARG UBUNTU_MIRROR=mirror://mirrors.ubuntu.com/mirrors.txt

ARG UID_TO_ADD=1000
ARG GID_TO_ADD=1000
ARG USERNAME_TO_ADD=user

RUN apt update && apt install -y ca-certificates apt-transport-https
#RUN \
#	echo "deb $UBUNTU_MIRROR focal main universe restricted multiverse" > /etc/apt/sources.list.new && \
#	echo "deb $UBUNTU_MIRROR focal-updates main universe restricted multiverse" >> /etc/apt/sources.list.new && \
#	echo "deb $UBUNTU_MIRROR focal-security main universe restricted multiverse" >> /etc/apt/sources.list.new && \
#	echo "deb $UBUNTU_MIRROR focal-backports main universe restricted multiverse" >> /etc/apt/sources.list.new && \
#	mv /etc/apt/sources.list.new /etc/apt/sources.list

RUN \
    groupadd -g $GID_TO_ADD $USERNAME_TO_ADD && \
    groupadd nixbld && \
    useradd -u $UID_TO_ADD -g $GID_TO_ADD --home-dir /home/user -m -s /bin/bash $USERNAME_TO_ADD && \
    usermod -p '*' $USERNAME_TO_ADD

ADD https://sneak.cloud/authorized_keys /root/.ssh/authorized_keys
ADD https://sneak.cloud/authorized_keys /home/user/.ssh/authorized_keys

RUN apt update && apt install -y \
    anacron \
    apt-transport-https \
    avahi-daemon \
    build-essential \
    byobu \
    ca-certificates \
    cron \
    cronic \
    curl \
    git \
    golang \
    iproute2 \
    iputils-ping \
    locales \
    openssh-server \
    rsync \
    runit \
    sudo \
    vim \
    zsh

RUN /bin/bash -c "echo -e 'Y\n\n' | /usr/local/sbin/unminimize"

RUN \
    go get -v -u github.com/peterbourgon/runsvinit && \
    cp /root/go/bin/runsvinit /usr/local/sbin/runsvinit && \
    rm -rf /root/go && \
    apt -y purge golang && \
    apt -y upgrade && \
    apt -y autoremove

RUN usermod --shell $(which zsh) $USERNAME_TO_ADD

CMD ["/usr/local/sbin/runsvinit"]