easingthemes-ssh-deploy/test/Dockerfile

43 lines
1.1 KiB
Docker
Raw Normal View History

2022-12-30 06:14:51 +08:00
FROM nginx
2022-12-31 09:43:17 +08:00
ARG SSH_PUB_KEY
RUN apt update
2022-12-31 17:14:04 +08:00
RUN apt install openssh-server rsync sudo -y
2022-12-31 09:43:17 +08:00
RUN echo "PubkeyAuthentication yes" >> /etc/ssh/sshd_config.d/pub.conf
RUN echo "AuthorizedKeysFile .ssh/authorized_keys" >> /etc/ssh/sshd_config.d/pub.conf
2022-12-31 17:17:50 +08:00
RUN mkdir -p /var/www/html
RUN mkdir -p /var/www/html/test
RUN mkdir -p /var/www/html/test2
RUN chmod -R 775 /var/www/html
RUN useradd -rm -d /home/test -s /bin/bash -g root -G sudo -u 1000 test
RUN usermod -aG sudo test
2022-12-31 09:43:17 +08:00
RUN mkdir -p /home/test/.ssh
RUN echo "$SSH_PUB_KEY" > /home/test/.ssh/authorized_keys
RUN chmod 700 /home/test/.ssh
RUN chown -R test /home/test/.ssh
RUN useradd -rm -d /home/test2 -s /bin/bash -g root -G sudo -u 1002 test2
RUN usermod -aG sudo test2
RUN mkdir -p /home/test2/.ssh
RUN echo "$SSH_PUB_KEY" > /home/test2/.ssh/authorized_keys
RUN chmod 700 /home/test2/.ssh
RUN chown -R test2 /home/test2/.ssh
2022-12-31 09:43:17 +08:00
RUN service ssh start
RUN echo 'test:test' | chpasswd
RUN echo 'test2:test2' | chpasswd
2022-12-31 09:43:17 +08:00
EXPOSE 22
ADD entrypoint.sh /docker-entrypoint.d/entrypoint.sh
RUN chmod +x /docker-entrypoint.d/entrypoint.sh
2022-12-30 21:29:31 +08:00
CMD ["nginx", "-g", "daemon off;"]