feat: test

This commit is contained in:
mol
2024-01-25 17:56:54 +08:00
parent 7841092515
commit b15abd54d8
2 changed files with 43 additions and 17 deletions

View File

@ -1,26 +1,36 @@
FROM node
EXPOSE 8080
EXPOSE 22
WORKDIR /app
COPY . .
VOLUME [ "/data" ]
EXPOSE 22
RUN apt-get update && apt-get install -y vim
RUN apt-get install -y git
RUN apt-get install -y openssh-server
RUN npm i -g n && npm i -g live-server
RUN git config --global user.name $GIT_USER && git config --global user.email $GIT_EMAIL
ARG PROXY
ENV https_proxy=${PROXY}
ENV http_proxy=${PROXY}
RUN echo "root:${PASSWD}" | chpasswd
RUN rm -f /etc/ssh/ssh_host_rsa_key && \
ssh-keygen -t rsa -f /etc/ssh/ssh_host_rsa_key -N '' && \
rm -f /etc/ssh/ssh_host_dsa_key && \
ssh-keygen -t dsa -f /etc/ssh/ssh_host_dsa_key -N '' && \
rm -f /etc/ssh/ssh_host_ecdsa_key && \
ssh-keygen -t ecdsa -f /etc/ssh/ssh_host_ecdsa_key -N '' && \
rm -f /etc/ssh/ssh_host_ed25519_key && \
ssh-keygen -t ed25519 -f /etc/ssh/ssh_host_ed25519_key -N ''
RUN sed -i "s/#PermitRootLogin prohibit-password/PermitRootLogin yes/" /etc/ssh/sshd_config
RUN export http_proxy=$http_proxy \
&& export https_proxy=$https_proxy \
&& apt-get update \
&& apt-get install -y vim \
&& apt-get install -y git \
&& apt-get install -y openssh-server \
&& npm i -g n \
&& npm i -g live-server \
&& touch info.log
CMD ["/usr/sbin/sshd", "-D"]
RUN rm -f /etc/ssh/ssh_host_rsa_key && \
ssh-keygen -t rsa -f /etc/ssh/ssh_host_rsa_key -N '' && \
rm -f /etc/ssh/ssh_host_dsa_key && \
ssh-keygen -t dsa -f /etc/ssh/ssh_host_dsa_key -N '' && \
rm -f /etc/ssh/ssh_host_ecdsa_key && \
ssh-keygen -t ecdsa -f /etc/ssh/ssh_host_ecdsa_key -N '' && \
rm -f /etc/ssh/ssh_host_ed25519_key && \
ssh-keygen -t ed25519 -f /etc/ssh/ssh_host_ed25519_key -N ''
RUN sed -i "s/#PermitRootLogin prohibit-password/PermitRootLogin yes/" /etc/ssh/sshd_config
ENTRYPOINT ["/app/docker-entry-point.sh"]

16
docker-entry-point.sh Executable file
View File

@ -0,0 +1,16 @@
#!/bin/bash
if [ -n "$ROOT_PASSWD" ]; then
echo "root:${ROOT_PASSWD}" | chpasswd
echo "密码设置完毕" >> /app/info.log
fi
if [ -n "$GIT_USER" ] && [ -n "$GIT_EMAIL" ]; then
git config --global user.name "$GIT_USER"
git config --global user.email "$GIT_EMAIL"
echo "git 用户已设置完毕" >> /app/info.log
fi
service ssh start
tail -f /app/info.log