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 FROM node
EXPOSE 8080 EXPOSE 8080
EXPOSE 22
WORKDIR /app WORKDIR /app
COPY . .
VOLUME [ "/data" ] VOLUME [ "/data" ]
EXPOSE 22
RUN apt-get update && apt-get install -y vim ARG PROXY
RUN apt-get install -y git ENV https_proxy=${PROXY}
RUN apt-get install -y openssh-server ENV http_proxy=${PROXY}
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
RUN echo "root:${PASSWD}" | chpasswd RUN export http_proxy=$http_proxy \
RUN rm -f /etc/ssh/ssh_host_rsa_key && \ && export https_proxy=$https_proxy \
ssh-keygen -t rsa -f /etc/ssh/ssh_host_rsa_key -N '' && \ && apt-get update \
rm -f /etc/ssh/ssh_host_dsa_key && \ && apt-get install -y vim \
ssh-keygen -t dsa -f /etc/ssh/ssh_host_dsa_key -N '' && \ && apt-get install -y git \
rm -f /etc/ssh/ssh_host_ecdsa_key && \ && apt-get install -y openssh-server \
ssh-keygen -t ecdsa -f /etc/ssh/ssh_host_ecdsa_key -N '' && \ && npm i -g n \
rm -f /etc/ssh/ssh_host_ed25519_key && \ && npm i -g live-server \
ssh-keygen -t ed25519 -f /etc/ssh/ssh_host_ed25519_key -N '' && touch info.log
RUN sed -i "s/#PermitRootLogin prohibit-password/PermitRootLogin yes/" /etc/ssh/sshd_config
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