FROM debian:trixie-slim

ENV LANG=C.UTF-8

# Slim images exclude man pages through a dpkg path filter. Removing it and
# reinstalling the preinstalled essentials restores their man pages.
RUN rm -f /etc/dpkg/dpkg.cfg.d/docker \
 && apt-get update \
 && apt-get install -y --no-install-recommends --reinstall \
      bash coreutils findutils grep sed \
 && apt-get install -y --no-install-recommends \
      gawk less tree file vim-tiny nano man-db manpages jq procps htop \
      figlet cowsay fortune-mod fortunes-min sl curl wget \
 && rm -rf /var/lib/apt/lists/*

# The content directory is mounted read only as the home directory, so all
# shell configuration lives in /etc.
# Setuid binaries are useless under no-new-privileges, so they are stripped
# to keep the attack surface minimal even if that option is ever dropped.
RUN useradd --uid 1000 --no-create-home --home-dir /home/guest --shell /bin/bash guest \
 && mkdir /home/guest \
 && find / -xdev -perm /6000 -type f -exec chmod a-s {} +

COPY etc/ /etc/
COPY --chmod=0755 bin/status /usr/local/bin/status

ENV PATH=/usr/local/bin:/usr/bin:/bin:/usr/games
USER guest
WORKDIR /home/guest
# Startup files in the home directory belong to the content, so bash only
# reads the system wide configuration.
CMD ["/bin/bash", "--rcfile", "/etc/bash.bashrc", "-i"]
