FROM ubuntu:latest
# for a specific version of ubuntu use a tag like ubuntu:20.04 or similar
COPY files/preseed.txt /tmp/preseed.txt
RUN debconf-set-selections /tmp/preseed.txt &&\
  export DEBIAN_FRONTEND=noninteractive DEBCONF_NONINTERACTIVE_SEEN=true &&\
  apt-get update &&\
  apt-get install -y openssh-server sudo nano less vim

# create default user "jdoe"
RUN useradd -rm -d /home/jdoe -s /bin/bash -G sudo,www-data jdoe
RUN echo 'jdoe:jdpasswd' | chpasswd
RUN apt-get install -y iputils-ping rsyslog dnsutils iproute2 net-tools

# add authorized keys: 
RUN mkdir -p /root/.ssh
COPY files/authorized_keys /root/.ssh/authorized_keys
RUN chmod 700 /root/.ssh && chmod 600 /root/.ssh/*

# clean up apt cache
#RUN apt-get autoclean -y &&\
#  apt-get autoremove -y &&\
#  rm -rf /var/lib/apt/lists/*

# startup script
COPY files/startup.sh /usr/local/bin/startup.sh
RUN chmod 755 /usr/local/bin/*
CMD /bin/bash /usr/local/bin/startup.sh
