FROM --platform=linux/amd64 ubuntu:20.04
MAINTAINER Stefano Alberto Russo <stefano.russo@inaf.it>

#----------------------
# Basics
#----------------------

# Set non-interactive
ENV DEBIAN_FRONTEND noninteractive

# Update first of all
RUN apt-get update

# Utilities
RUN apt-get install -y sudo nano emacs vim screen telnet iputils-ping curl wget unzip git-core python3-pip python3-venv

# Change APT user to allow some container runtimes properly work (i.e. Podman)
RUN groupadd -g 600 _apt
RUN usermod -g 600 _apt

#------------------------
# "Meta" user
#------------------------

# Add group. We chose GID 1000 as default.
RUN groupadd -g 1000 metauser

# Add user. We chose UID 1000 as default
RUN useradd metauser -d /home/metauser -u 1000 -g 1000 -m -s /bin/bash

# Add metuaser user to sudoers
RUN adduser metauser sudo

# No pass sudo (for everyone, actually)
COPY files/sudoers /etc/sudoers

# Prepare for user-space logs
RUN mkdir /home/metauser/.logs && chown metauser:metauser /home/metauser/.logs

# Rename metauser home folder as a "vanilla" home folder
RUN mv /home/metauser /metauser_home_vanilla

# Set container name
ENV CONTAINER_NAME='base'

# Entrypoint
COPY files/base_entrypoint.sh /usr/bin/base_entrypoint.sh
RUN chmod 755 /usr/bin/base_entrypoint.sh
ENTRYPOINT ["/usr/bin/base_entrypoint.sh"]
ENV DEFAULT_ENTRYPOINT_COMMAND="/bin/bash"

# Allow to move the /home_vanilla folder in /home
RUN chmod 777 /home

# Set user
USER metauser

