FROM alpine:3.12.1 ARG SSH_USER="hub" ARG UID="1001" ENV SSH_USER ${SSH_USER} # secrets: # - host_ssh_key # - authorized_keys USER root RUN apk update &&\ apk upgrade &&\ apk add openssh &&\ mkdir /var/run/sshd &&\ mkdir -p /etc/ssh &&\ ln -s /run/secrets/host_ssh_key /etc/ssh/ssh_host_key &&\ echo 'root:nonvisibleroot' | chpasswd &&\ addgroup --gid $UID -S $SSH_USER &&\ adduser \ -S -G $SSH_USER \ --uid $UID \ --shell /bin/sh \ --home /home/$SSH_USER \ $SSH_USER &&\ echo 'hub:nonvisiblehub' | chpasswd &&\ mkdir "/home/$SSH_USER/.ssh" &&\ chown "$SSH_USER" "/home/$SSH_USER/.ssh" &&\ chmod 700 "/home/$SSH_USER/.ssh" COPY sshd_config /etc/ssh/sshd_config ADD start.sh / EXPOSE 22 CMD ["sh", "/start.sh"]