FROM alpine:3.22

RUN apk add --no-cache \
        openssh-server \
        docker-cli \
        docker-cli-compose \
        git \
        curl \
        wget \
        bash \
        jq \
        vim \
        less \
        htop \
        iproute2 \
        bind-tools \
        tcpdump \
        procps \
        util-linux \
        tree \
        file \
        ca-certificates \
        tzdata \
    && addgroup -g 1001 docker-host \
    && adduser -D -s /bin/bash operator \
    && adduser operator docker-host \
    && passwd -d operator \
    && mkdir -p /home/operator/.ssh \
    && ssh-keygen -A

RUN printf '%s\n' \
        'PasswordAuthentication no' \
        'KbdInteractiveAuthentication no' \
        'PubkeyAuthentication yes' \
        'PermitRootLogin no' \
      >> /etc/ssh/sshd_config

COPY entrypoint.sh /entrypoint.sh
COPY gpuctl /usr/local/bin/gpuctl

RUN sed -i 's/\r$//' /entrypoint.sh /usr/local/bin/gpuctl \
    && chmod +x /entrypoint.sh /usr/local/bin/gpuctl

EXPOSE 22

ENTRYPOINT ["/entrypoint.sh"]