增加特定用户。

This commit is contained in:
amass 2025-03-11 23:31:09 +08:00
parent feb597a567
commit b50caa85b0

View File

@ -2,8 +2,12 @@ FROM ubuntu:24.04
LABEL maintainer="amass <168062547@qq.com>" LABEL maintainer="amass <168062547@qq.com>"
ENV DEBIAN_FRONTEND=noninteractive ENV DEBIAN_FRONTEND=noninteractive
ARG USER_NAME=amass
ARG USER_UID=1000
ARG USER_GID=100
ENV BOOST_VERSION=1_87_0 ENV BOOST_VERSION=1_87_0
ENV CODE_VERSION=4.97.2 ENV CODE_VERSION=4.98.0
ENV LIBDATACHANNEL_VERSION=0.22.5 ENV LIBDATACHANNEL_VERSION=0.22.5
ENV NNG_VERSION=1.10.1 ENV NNG_VERSION=1.10.1
ENV TCPING_VERSION=2.7.1 ENV TCPING_VERSION=2.7.1
@ -11,7 +15,9 @@ ENV TCPING_VERSION=2.7.1
RUN sed -i 's@//.*archive.ubuntu.com@//mirrors.ustc.edu.cn@g' /etc/apt/sources.list.d/ubuntu.sources \ RUN sed -i 's@//.*archive.ubuntu.com@//mirrors.ustc.edu.cn@g' /etc/apt/sources.list.d/ubuntu.sources \
&& apt update \ && apt update \
&& apt install -y gcc g++ gdb cmake ninja-build pkg-config openssh-server git nano gpg ca-certificates \ && apt install -y gcc g++ gdb cmake ninja-build pkg-config openssh-server git nano gpg ca-certificates \
wget curl rsync lsb-release ubuntu-keyring gnupg2 libssl-dev zlib1g-dev gettext jq bzip2 unzip xz-utils zsh htop tini \ wget curl rsync lsb-release ubuntu-keyring gnupg2 libssl-dev zlib1g-dev gettext jq bzip2 unzip xz-utils \
zsh htop tini sudo gosu \
&& echo 'if [ -f /etc/profile ]; then source /etc/profile; fi' >> /etc/zsh/zprofile \
&& install -m 0755 -d /etc/apt/keyrings \ && install -m 0755 -d /etc/apt/keyrings \
&& curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc \ && curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc \
&& chmod a+r /etc/apt/keyrings/docker.asc \ && chmod a+r /etc/apt/keyrings/docker.asc \
@ -27,30 +33,6 @@ RUN curl -fOL https://github.com/coder/code-server/releases/download/v$CODE_VERS
&& dpkg -i code-server_${CODE_VERSION}_amd64.deb \ && dpkg -i code-server_${CODE_VERSION}_amd64.deb \
&& rm code-server_${CODE_VERSION}_amd64.deb && rm code-server_${CODE_VERSION}_amd64.deb
RUN sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)" \
&& git clone --depth=1 https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions \
&& git clone --depth=1 https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting \
&& git clone --depth=1 https://github.com/romkatv/powerlevel10k.git ${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/themes/powerlevel10k \
&& sed -i 's/ZSH_THEME=".*"/ZSH_THEME="powerlevel10k\/powerlevel10k"/' /root/.zshrc \
&& sed -i 's/plugins=(.*)/plugins=(git z zsh-autosuggestions zsh-syntax-highlighting)/' /root/.zshrc \
&& sed -i 's/^setopt share_history/# setopt share_history/' ~/.oh-my-zsh/lib/history.zsh \
&& echo 'setopt no_share_history' >> ~/.oh-my-zsh/lib/history.zsh \
&& echo 'if [ -f /etc/profile ]; then source /etc/profile; fi' >> /etc/zsh/zprofile \
&& chsh -s /bin/zsh root
RUN git config --global core.quotepath false \
&& git config --global user.email "168062547@qq.com" \
&& git config --global user.name "amass"
RUN mkdir /var/run/sshd \
&& sed -i 's/#Port 22/Port 1022/' /etc/ssh/sshd_config \
&& sed -i 's/#PubkeyAuthentication yes/PubkeyAuthentication yes/' /etc/ssh/sshd_config \
&& mkdir -p /root/.ssh \
&& wget https://cloud.amass.fun/s/id_ed25519/download -O /root/.ssh/authorized_keys \
&& chmod 600 /root/.ssh/authorized_keys && chown root:root /root/.ssh/authorized_keys
EXPOSE 1022
RUN cd /opt \ RUN cd /opt \
&& git clone --depth=1 https://github.com/emscripten-core/emsdk.git \ && git clone --depth=1 https://github.com/emscripten-core/emsdk.git \
&& cd /opt/emsdk \ && cd /opt/emsdk \
@ -147,8 +129,48 @@ ENV LANG=C.UTF-8
ENV LC_ALL=C.UTF-8 ENV LC_ALL=C.UTF-8
ENV TERM=xterm-256color ENV TERM=xterm-256color
ENTRYPOINT ["/usr/bin/tini", "--"] RUN mkdir /var/run/sshd \
CMD ["bash", "-c", "service ssh start && code-server --bind-addr 0.0.0.0:8087"] && sed -i 's/#Port 22/Port 1022/' /etc/ssh/sshd_config \
&& sed -i 's/#PubkeyAuthentication yes/PubkeyAuthentication yes/' /etc/ssh/sshd_config
EXPOSE 1022
RUN set -eux; \
if getent passwd ${USER_UID} >/dev/null; then \
OLD_USER=$(getent passwd ${USER_UID} | cut -d: -f1); \
userdel -rf "$OLD_USER" || true; \
fi; \
if ! getent group ${USER_GID} >/dev/null; then \
groupadd -g ${USER_GID} users; \
fi; \
useradd -u ${USER_UID} -g ${USER_GID} -m -s /bin/zsh ${USER_NAME}; \
usermod -aG sudo ${USER_NAME}; \
echo "${USER_NAME} ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers
RUN mkdir -p /home/${USER_NAME}/.ssh \
&& chown ${USER_UID}:${USER_GID} /home/${USER_NAME}/.ssh \
&& chmod 700 /home/${USER_NAME}/.ssh \
&& wget https://cloud.amass.fun/s/id_ed25519/download -O /home/${USER_NAME}/.ssh/authorized_keys \
&& chown ${USER_UID}:${USER_GID} /home/${USER_NAME}/.ssh/authorized_keys \
&& chmod 600 /home/${USER_NAME}/.ssh/authorized_keys
USER ${USER_NAME}
RUN git config --global core.quotepath false \
&& git config --global user.email "168062547@qq.com" \
&& git config --global user.name ${USER_NAME}
RUN sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)" \
&& git clone --depth=1 https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions \
&& git clone --depth=1 https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting \
&& git clone --depth=1 https://github.com/romkatv/powerlevel10k.git ${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/themes/powerlevel10k \
&& sed -i 's/ZSH_THEME=".*"/ZSH_THEME="powerlevel10k\/powerlevel10k"/' ~/.zshrc \
&& sed -i 's/plugins=(.*)/plugins=(git z zsh-autosuggestions zsh-syntax-highlighting)/' ~/.zshrc \
&& sed -i 's/^setopt share_history/# setopt share_history/' ~/.oh-my-zsh/lib/history.zsh \
&& echo 'setopt no_share_history' >> ~/.oh-my-zsh/lib/history.zsh
USER root
ENTRYPOINT ["/usr/bin/tini", "--"]
CMD ["bash", "-c", "service ssh start && gosu amass code-server --bind-addr 0.0.0.0:8087"]
# CMD ["bash", "-c", "service ssh start && tail -f /dev/null"]
# docker build --no-cache --progress=tty -f ubuntu2404.dockerfile -t registry.cn-shenzhen.aliyuncs.com/amass_toolset/ubuntu_dev:24.04 . # docker build --no-cache --progress=tty -f ubuntu2404.dockerfile -t registry.cn-shenzhen.aliyuncs.com/amass_toolset/ubuntu_dev:24.04 .
# docker push registry.cn-shenzhen.aliyuncs.com/amass_toolset/ubuntu_dev:24.04 # docker push registry.cn-shenzhen.aliyuncs.com/amass_toolset/ubuntu_dev:24.04