# This Dockerfile is a minimal example for a Ubuntu 24.04 test suite target container.
FROM ubuntu:24.04

ENV AUTH_KEYS=/root/.ssh/authorized_keys

ARG CLIENT_PUBLIC_KEY
ARG ADDITIONAL_PACKAGES
ARG DEBIAN_FRONTEND=noninteractive

# Install Python so Ansible remediations can work
# Don't clean all, as the test scenario may require package install.
RUN true \
        && apt update \
        && apt install -y openscap-utils openscap-scanner \
                          openssh-server python3 python3-apt \
                          $ADDITIONAL_PACKAGES \
        && true

RUN true \
        && ssh-keygen -A \
        && mkdir -p /root/.ssh \
        && printf "%s\n" "$CLIENT_PUBLIC_KEY" >> "$AUTH_KEYS" \
        && chmod og-rw /root/.ssh "$AUTH_KEYS" \
        && sed -i '/session\s\+required\s\+pam_loginuid.so/d' /etc/pam.d/sshd \
        && echo CPE_NAME="cpe:/o:canonical:ubuntu_linux:24.04" >> /etc/os-release

RUN mkdir /run/sshd
CMD ["/usr/sbin/sshd", "-D"]
