Dockerfiles/ubuntu1804.dockerfile

55 lines
2.2 KiB
Docker

FROM ubuntu:18.04
LABEL maintainer="amass <168062547@qq.com>"
ENV DEBIAN_FRONTEND=noninteractive
ARG USER_NAME=amass
ARG USER_UID=1000
ARG GROUP_NAME=amass
ARG USER_GID=1000
RUN apt update \
&& 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 \
bc cpio dosfstools mtools tree htop sudo gosu \
&& wget https://github.com/krallin/tini/releases/download/v0.19.0/tini-amd64 -O /usr/bin/tini \
&& chmod +x /usr/bin/tini \
&& apt clean \
&& rm -fr /var/lib/apt/lists/* /tmp/* /var/tmp/*
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
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} ${GROUP_NAME}; \
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/Z42BPTsfjB53k35/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}
USER root
ENTRYPOINT ["/usr/bin/tini", "--"]
CMD ["bash", "-c", "service ssh start && tail -f /dev/null"]
# docker build --no-cache --progress=tty -f ubuntu1804.dockerfile -t registry.cn-shenzhen.aliyuncs.com/amass_toolset/ubuntu_dev:18.04 .
# docker push registry.cn-shenzhen.aliyuncs.com/amass_toolset/ubuntu_dev:18.04