FROM continuumio/miniconda3:latest AS conda-base
FROM ubuntu:24.04
ARG GENERAL_MIRROR=mirrors.huaweicloud.com
ARG CONDA_MIRROR=https://mirrors.tuna.tsinghua.edu.cn/anaconda
ARG REPO_SCRIPT_URL=https://mirrors.tuna.tsinghua.edu.cn/git/git-repo
ARG REPO_GIT_URL=https://mirrors.ustc.edu.cn/aosp/git-repo
ENV TZ=Asia/Shanghai \
LANG=C.UTF-8 \
SHELL=/bin/zsh \
DEBIAN_FRONTEND=noninteractive \
PATH=/opt/conda/envs/py312/bin:/opt/conda/bin:$PATH \
REPO_URL=${REPO_GIT_URL}
USER root
WORKDIR /tmp
SHELL ["/bin/bash", "-c"]
RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \
--mount=type=cache,target=/var/lib/apt/lists,sharing=locked \
set -eu && \
rm -f /etc/apt/apt.conf.d/docker-clean && \
arch="$(dpkg --print-architecture)" && \
if [ "${arch}" = "arm64" ]; then \
sed -i "s@//ports.ubuntu.com@//${GENERAL_MIRROR}@g" /etc/apt/sources.list.d/ubuntu.sources; \
else \
sed -i "s@//archive.ubuntu.com@//${GENERAL_MIRROR}@g; s@//security.ubuntu.com@//${GENERAL_MIRROR}@g" /etc/apt/sources.list.d/ubuntu.sources; \
fi && \
apt-get update && \
apt-get install -y --no-install-recommends \
tzdata lsb-release ca-certificates openssl gnupg2 \
curl wget openssh-client iputils-ping net-tools lsof \
zip unzip \
build-essential cmake ninja-build ccache pkg-config \
autoconf automake libtool gperf \
gdb gdbserver lcov \
git git-lfs \
vim htop tree zsh clangd whiptail \
pciutils && \
ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && \
echo $TZ > /etc/timezone
RUN set -eu && \
curl -fsSL ${REPO_SCRIPT_URL} -o /usr/local/bin/repo && \
chmod a+x /usr/local/bin/repo && \
git config --global core.autocrlf input && \
git config --global core.editor vim && \
git config --global color.ui auto && \
git config --global credential.helper "cache --timeout=3600" && \
git config --global alias.lg \
"log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit"
RUN set -eu && \
git clone --depth=1 https://gitcode.com/ohmyzsh/ohmyzsh.git /root/.oh-my-zsh && \
cp /root/.oh-my-zsh/templates/zshrc.zsh-template /root/.zshrc && \
git clone --depth=1 https://gitcode.com/zsh-users/zsh-autosuggestions \
/root/.oh-my-zsh/custom/plugins/zsh-autosuggestions && \
git clone --depth=1 https://gitcode.com/zsh-users/zsh-syntax-highlighting \
/root/.oh-my-zsh/custom/plugins/zsh-syntax-highlighting && \
sed -i 's/plugins=(git)/plugins=(git z zsh-autosuggestions zsh-syntax-highlighting)/' /root/.zshrc && \
sed -i 's/ZSH_THEME="robbyrussell"/ZSH_THEME="agnoster"/' /root/.zshrc && \
chsh -s "$(which zsh)" root
COPY --from=conda-base /opt/conda /opt/conda
RUN set -eu && mkdir -p /etc/conda && cat > /etc/conda/.condarc <<EOF
channels:
- defaults
show_channel_urls: true
default_channels:
- ${CONDA_MIRROR}/pkgs/main
- ${CONDA_MIRROR}/pkgs/r
- ${CONDA_MIRROR}/pkgs/msys2
custom_channels:
conda-forge: ${CONDA_MIRROR}/cloud
pytorch: ${CONDA_MIRROR}/cloud
EOF
RUN set -eu && cat > /etc/pip.conf <<EOF
[global]
index-url = https://${GENERAL_MIRROR}/repository/pypi/simple
trusted-host = ${GENERAL_MIRROR}
default-timeout = 120
EOF
COPY requirements.txt /tmp/requirements.txt
RUN --mount=type=cache,target=/root/.cache/pip,sharing=locked \
set -eu && \
conda create -y -n py312 python=3.12 pip && \
conda run -n py312 pip install -r /tmp/requirements.txt && \
conda clean -afy && \
find /opt/conda -follow -type d -name '__pycache__' -exec rm -rf {} + 2>/dev/null || true && \
rm -f /tmp/requirements.txt
RUN set -eu && \
conda init zsh && \
cat >> /root/.zshrc <<EOF && rm -rf /tmp/*
conda activate py312
echo "\\033[1;36m"
echo " █████╗ ███████╗ ██████╗███████╗███╗ ██╗██████╗ ██████╗"
echo "██╔══██╗██╔════╝██╔════╝██╔════╝████╗ ██║██╔══██╗██╔════╝"
echo "███████║███████╗██║ █████╗ ██╔██╗ ██║██║ ██║██║ "
echo "██╔══██║╚════██║██║ ██╔══╝ ██║╚██╗██║██║ ██║██║ "
echo "██║ ██║███████║╚██████╗███████╗██║ ╚████║██████╔╝╚██████╗"
echo "╚═╝ ╚═╝╚══════╝ ╚═════╝╚══════╝╚═╝ ╚═══╝╚═════╝ ╚═════╝"
echo "\\033[0m"
[ -f /usr/local/Ascend/driver/bin/setenv.bash ] && source /usr/local/Ascend/driver/bin/setenv.bash
EOF
WORKDIR /root
ENTRYPOINT ["/bin/zsh"]