Update Dockerfile
Browse files- Dockerfile +219 -173
Dockerfile
CHANGED
|
@@ -1,6 +1,7 @@
|
|
| 1 |
FROM ubuntu:22.04
|
| 2 |
|
| 3 |
-
|
|
|
|
| 4 |
ENV DEBIAN_FRONTEND=noninteractive \
|
| 5 |
TZ=Asia/Shanghai \
|
| 6 |
LANG=en_US.UTF-8 \
|
|
@@ -10,179 +11,232 @@ ENV DEBIAN_FRONTEND=noninteractive \
|
|
| 10 |
NPM_CONFIG_UPDATE_NOTIFIER=false \
|
| 11 |
PLAYWRIGHT_BROWSERS_PATH=/root/.cache/ms-playwright \
|
| 12 |
PORT=7860 \
|
| 13 |
-
HOME=/root
|
|
|
|
|
|
|
| 14 |
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
#
|
| 18 |
RUN apt-get update && apt-get install -y --no-install-recommends \
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
netcat-openbsd \
|
| 54 |
-
telnet \
|
| 55 |
-
traceroute \
|
| 56 |
-
# 进程/系统工具
|
| 57 |
-
procps \
|
| 58 |
-
htop \
|
| 59 |
-
tmux \
|
| 60 |
-
screen \
|
| 61 |
-
lsof \
|
| 62 |
-
strace \
|
| 63 |
-
psmisc \
|
| 64 |
-
# 构建工具链(编译任何软件都可能需要)
|
| 65 |
-
build-essential \
|
| 66 |
-
pkg-config \
|
| 67 |
-
cmake \
|
| 68 |
-
ninja-build \
|
| 69 |
-
autoconf \
|
| 70 |
-
automake \
|
| 71 |
-
libtool \
|
| 72 |
-
m4 \
|
| 73 |
-
flex \
|
| 74 |
-
bison \
|
| 75 |
-
# Python开发头文件(编译Python包需要)
|
| 76 |
-
python3 \
|
| 77 |
-
python3-pip \
|
| 78 |
-
python3-venv \
|
| 79 |
-
python3-dev \
|
| 80 |
-
python-is-python3 \
|
| 81 |
-
libssl-dev \
|
| 82 |
-
zlib1g-dev \
|
| 83 |
-
libbz2-dev \
|
| 84 |
-
libreadline-dev \
|
| 85 |
-
libsqlite3-dev \
|
| 86 |
-
libncurses5-dev \
|
| 87 |
-
libncursesw5-dev \
|
| 88 |
-
libffi-dev \
|
| 89 |
-
liblzma-dev \
|
| 90 |
-
# 多媒体/字体(Chrome和Playwright需要)
|
| 91 |
-
ffmpeg \
|
| 92 |
-
fonts-liberation \
|
| 93 |
-
fonts-noto-cjk \
|
| 94 |
-
fonts-noto-color-emoji \
|
| 95 |
-
fontconfig \
|
| 96 |
-
libfontconfig1 \
|
| 97 |
-
libfreetype6 \
|
| 98 |
-
# Playwright/Chromium 运行的所有系统依赖(Ubuntu 22.04)
|
| 99 |
-
libasound2 \
|
| 100 |
-
libatk-bridge2.0-0 \
|
| 101 |
-
libatk1.0-0 \
|
| 102 |
-
libc6 \
|
| 103 |
-
libcairo2 \
|
| 104 |
-
libcups2 \
|
| 105 |
-
libdbus-1-3 \
|
| 106 |
-
libdrm2 \
|
| 107 |
-
libexpat1 \
|
| 108 |
-
libgbm1 \
|
| 109 |
-
libgcc-s1 \
|
| 110 |
-
libglib2.0-0 \
|
| 111 |
-
libgtk-3-0 \
|
| 112 |
-
libnspr4 \
|
| 113 |
-
libnss3 \
|
| 114 |
-
libpango-1.0-0 \
|
| 115 |
-
libpangocairo-1.0-0 \
|
| 116 |
-
libstdc++6 \
|
| 117 |
-
libx11-6 \
|
| 118 |
-
libx11-xcb1 \
|
| 119 |
-
libxcb1 \
|
| 120 |
-
libxcomposite1 \
|
| 121 |
-
libxcursor1 \
|
| 122 |
-
libxdamage1 \
|
| 123 |
-
libxext6 \
|
| 124 |
-
libxfixes3 \
|
| 125 |
-
libxi6 \
|
| 126 |
-
libxkbcommon0 \
|
| 127 |
-
libxrandr2 \
|
| 128 |
-
libxrender1 \
|
| 129 |
-
libxshmfence1 \
|
| 130 |
-
libxss1 \
|
| 131 |
-
libxtst6 \
|
| 132 |
-
# 其他常用库
|
| 133 |
-
libxml2-dev \
|
| 134 |
-
libxslt1-dev \
|
| 135 |
-
libjpeg-dev \
|
| 136 |
-
libpng-dev \
|
| 137 |
-
libtiff-dev \
|
| 138 |
-
libopenjp2-7-dev \
|
| 139 |
-
libwebp-dev \
|
| 140 |
-
libmagic-dev \
|
| 141 |
-
tesseract-ocr \
|
| 142 |
&& locale-gen en_US.UTF-8 \
|
| 143 |
&& update-locale LANG=en_US.UTF-8 \
|
| 144 |
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
|
| 145 |
|
| 146 |
-
#
|
| 147 |
-
|
| 148 |
-
|
| 149 |
-
|
| 150 |
-
|
| 151 |
-
|
| 152 |
-
|
| 153 |
-
|
| 154 |
-
|
| 155 |
-
|
| 156 |
-
|
| 157 |
-
|
| 158 |
-
|
| 159 |
-
|
| 160 |
-
#
|
| 161 |
RUN curl -fsSL https://deb.nodesource.com/setup_20.x | bash - \
|
| 162 |
-
&& apt-get install -y nodejs \
|
| 163 |
&& npm install -g npm@latest \
|
| 164 |
&& rm -rf /var/lib/apt/lists/*
|
| 165 |
|
| 166 |
-
#
|
| 167 |
-
|
| 168 |
-
|
| 169 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 170 |
|
| 171 |
-
#
|
| 172 |
-
RUN
|
| 173 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 174 |
|
| 175 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 176 |
RUN mkdir -p /root/.config/code-server \
|
| 177 |
&& mkdir -p /root/.local/share/code-server/User \
|
| 178 |
-
&& cat > /root/.config/code-server/config.yaml <<
|
| 179 |
bind-addr: 0.0.0.0:7860
|
| 180 |
auth: none
|
| 181 |
disable-telemetry: true
|
| 182 |
disable-update-check: true
|
| 183 |
EOF
|
| 184 |
|
| 185 |
-
#
|
| 186 |
RUN cat > /root/.local/share/code-server/User/settings.json <<'EOF'
|
| 187 |
{
|
| 188 |
"workbench.colorTheme": "Default Dark+",
|
|
@@ -193,15 +247,13 @@ RUN cat > /root/.local/share/code-server/User/settings.json <<'EOF'
|
|
| 193 |
"extensions.autoUpdate": false,
|
| 194 |
"security.workspace.trust.enabled": false,
|
| 195 |
"security.workspace.trust.startupPrompt": "never",
|
| 196 |
-
"terminal.integrated.defaultProfile.linux": "
|
| 197 |
"terminal.integrated.profiles.linux": {
|
| 198 |
-
"
|
| 199 |
-
|
| 200 |
-
"icon": "terminal-bash"
|
| 201 |
-
}
|
| 202 |
},
|
|
|
|
| 203 |
"python.defaultInterpreterPath": "/usr/bin/python3",
|
| 204 |
-
"python.terminal.activateEnvironmentInTerminal": true,
|
| 205 |
"git.enableSmartCommit": true,
|
| 206 |
"git.confirmSync": false,
|
| 207 |
"editor.formatOnSave": true,
|
|
@@ -209,18 +261,15 @@ RUN cat > /root/.local/share/code-server/User/settings.json <<'EOF'
|
|
| 209 |
"editor.tabSize": 4,
|
| 210 |
"editor.insertSpaces": true,
|
| 211 |
"editor.wordWrap": "on",
|
| 212 |
-
"files.exclude": {
|
| 213 |
-
"**/.git": false
|
| 214 |
-
},
|
| 215 |
"explorer.confirmDragAndDrop": false,
|
| 216 |
"explorer.confirmDelete": false
|
| 217 |
}
|
| 218 |
EOF
|
| 219 |
|
| 220 |
-
# 预装常用扩展(不阻塞构建
|
| 221 |
RUN code-server --install-extension ms-python.python --force || true \
|
| 222 |
&& code-server --install-extension ms-toolsai.jupyter --force || true \
|
| 223 |
-
&& code-server --install-extension ms-toolsai.vscode-jupyter-cell-tags --force || true \
|
| 224 |
&& code-server --install-extension ms-azuretools.vscode-docker --force || true \
|
| 225 |
&& code-server --install-extension redhat.vscode-yaml --force || true \
|
| 226 |
&& code-server --install-extension formulahendry.auto-close-tag --force || true \
|
|
@@ -234,14 +283,11 @@ RUN code-server --install-extension ms-python.python --force || true \
|
|
| 234 |
&& code-server --install-extension yzhang.markdown-all-in-one --force || true \
|
| 235 |
|| true
|
| 236 |
|
| 237 |
-
#
|
| 238 |
-
RUN mkdir -p /
|
| 239 |
-
|
| 240 |
-
|
| 241 |
-
WORKDIR /data/workspace
|
| 242 |
|
| 243 |
-
# 暴露 HF Space 默认端口
|
| 244 |
EXPOSE 7860
|
| 245 |
|
| 246 |
-
#
|
| 247 |
-
|
|
|
|
| 1 |
FROM ubuntu:22.04
|
| 2 |
|
| 3 |
+
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
|
| 4 |
+
|
| 5 |
ENV DEBIAN_FRONTEND=noninteractive \
|
| 6 |
TZ=Asia/Shanghai \
|
| 7 |
LANG=en_US.UTF-8 \
|
|
|
|
| 11 |
NPM_CONFIG_UPDATE_NOTIFIER=false \
|
| 12 |
PLAYWRIGHT_BROWSERS_PATH=/root/.cache/ms-playwright \
|
| 13 |
PORT=7860 \
|
| 14 |
+
HOME=/root \
|
| 15 |
+
ZSH=/root/.oh-my-zsh \
|
| 16 |
+
RUN_AS_ROOT=1
|
| 17 |
|
| 18 |
+
# ------------------------------------------------------------
|
| 19 |
+
# 1) 系统基础 + 所有编译/运行依赖(含 Playwright/Chromium 全量系统库)
|
| 20 |
+
# ------------------------------------------------------------
|
| 21 |
RUN apt-get update && apt-get install -y --no-install-recommends \
|
| 22 |
+
ca-certificates curl wget git git-lfs sudo \
|
| 23 |
+
gnupg dirmngr lsb-release software-properties-common \
|
| 24 |
+
locales tzdata apt-transport-https \
|
| 25 |
+
# 常用工具
|
| 26 |
+
vim nano less jq tree htop tmux screen \
|
| 27 |
+
zip unzip p7zip-full tar xz-utils bzip2 gzip \
|
| 28 |
+
rsync openssh-client net-tools dnsutils iputils-ping \
|
| 29 |
+
netcat-openbsd telnet traceroute \
|
| 30 |
+
# 构建工具链
|
| 31 |
+
build-essential pkg-config cmake ninja-build \
|
| 32 |
+
autoconf automake libtool m4 flex bison \
|
| 33 |
+
# Python 开发头文件
|
| 34 |
+
python3 python3-pip python3-venv python3-dev python-is-python3 \
|
| 35 |
+
libssl-dev zlib1g-dev libbz2-dev libreadline-dev \
|
| 36 |
+
libsqlite3-dev libncurses5-dev libncursesw5-dev \
|
| 37 |
+
libffi-dev liblzma-dev \
|
| 38 |
+
# 多媒体/字体/图像库
|
| 39 |
+
ffmpeg fonts-liberation fonts-noto-cjk \
|
| 40 |
+
fonts-noto-color-emoji fontconfig libfontconfig1 libfreetype6 \
|
| 41 |
+
tesseract-ocr libtiff-dev libopenjp2-7-dev libwebp-dev \
|
| 42 |
+
# Playwright/Chromium 运行时全量依赖(Ubuntu 22.04)
|
| 43 |
+
libasound2 libatk-bridge2.0-0 libatk1.0-0 libc6 libcairo2 \
|
| 44 |
+
libcups2 libdbus-1-3 libdrm2 libexpat1 libgbm1 libgcc-s1 \
|
| 45 |
+
libglib2.0-0 libgtk-3-0 libnspr4 libnss3 libpango-1.0-0 \
|
| 46 |
+
libpangocairo-1.0-0 libstdc++6 libx11-6 libx11-xcb1 libxcb1 \
|
| 47 |
+
libxcomposite1 libxcursor1 libxdamage1 libxext6 libxfixes3 \
|
| 48 |
+
libxi6 libxkbcommon0 libxrandr2 libxrender1 libxshmfence1 \
|
| 49 |
+
libxss1 libxtst6 libatspi2.0-0 libwayland-client0 \
|
| 50 |
+
libwayland-cursor0 libwayland-egl1 libwayland-server0 \
|
| 51 |
+
libxkbfile1 libcurl4 \
|
| 52 |
+
# Zsh 必备
|
| 53 |
+
zsh fonts-powerline \
|
| 54 |
+
# Docker 依赖
|
| 55 |
+
iptables \
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 56 |
&& locale-gen en_US.UTF-8 \
|
| 57 |
&& update-locale LANG=en_US.UTF-8 \
|
| 58 |
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
|
| 59 |
|
| 60 |
+
# ------------------------------------------------------------
|
| 61 |
+
# 2) 安装 Docker CLI(容器内可用 docker 命令,如 HF Spaces 支持 DinD)
|
| 62 |
+
# ------------------------------------------------------------
|
| 63 |
+
RUN install -m 0755 -d /etc/apt/keyrings \
|
| 64 |
+
&& curl -fsSL https://download.docker.com/linux/ubuntu/gpg | gpg --dearmor -o /etc/apt/keyrings/docker.gpg \
|
| 65 |
+
&& chmod a+r /etc/apt/keyrings/docker.gpg \
|
| 66 |
+
&& echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu jammy stable" \
|
| 67 |
+
> /etc/apt/sources.list.d/docker.list \
|
| 68 |
+
&& apt-get update \
|
| 69 |
+
&& apt-get install -y --no-install-recommends docker-ce-cli docker-compose-plugin docker-buildx-plugin \
|
| 70 |
+
&& rm -rf /var/lib/apt/lists/*
|
| 71 |
+
|
| 72 |
+
# ------------------------------------------------------------
|
| 73 |
+
# 3) 安装 Node.js 20.x(Playwright 需要)
|
| 74 |
+
# ------------------------------------------------------------
|
| 75 |
RUN curl -fsSL https://deb.nodesource.com/setup_20.x | bash - \
|
| 76 |
+
&& apt-get install -y --no-install-recommends nodejs \
|
| 77 |
&& npm install -g npm@latest \
|
| 78 |
&& rm -rf /var/lib/apt/lists/*
|
| 79 |
|
| 80 |
+
# ------------------------------------------------------------
|
| 81 |
+
# 4) Zsh + Oh-my-zsh + Powerlevel10k(完美主题配置)
|
| 82 |
+
# ------------------------------------------------------------
|
| 83 |
+
RUN sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)" "" --unattended \
|
| 84 |
+
&& git clone --depth=1 https://github.com/romkatv/powerlevel10k.git ${ZSH}/custom/themes/powerlevel10k \
|
| 85 |
+
&& git clone --depth=1 https://github.com/zsh-users/zsh-autosuggestions ${ZSH}/custom/plugins/zsh-autosuggestions \
|
| 86 |
+
&& git clone --depth=1 https://github.com/zsh-users/zsh-syntax-highlighting ${ZSH}/custom/plugins/zsh-syntax-highlighting \
|
| 87 |
+
&& git clone --depth=1 https://github.com/zsh-users/zsh-completions ${ZSH}/custom/plugins/zsh-completions
|
| 88 |
|
| 89 |
+
# Powerlevel10k 配置(高度优化、美观且兼容无 Nerd Fonts 环境)
|
| 90 |
+
RUN cat > /root/.p10k.zsh <<'EOF'
|
| 91 |
+
# 简化的 Powerlevel10k 配置,避免字体缺失导致的乱码
|
| 92 |
+
'status'=forground%or%K{016c}F{11::+-% } -%<<
|
| 93 |
+
POWERLEVEL9K_DISABLE_HOT_RELOAD=true
|
| 94 |
+
|
| 95 |
+
# 左侧提示符元素
|
| 96 |
+
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(os_icon context dir vcs)
|
| 97 |
+
# 右侧提示符元素
|
| 98 |
+
POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS=(status root_indicator background_jobs time)
|
| 99 |
+
|
| 100 |
+
# 目录颜色
|
| 101 |
+
POWERLEVEL9K_DIR_BACKGROUND='blue'
|
| 102 |
+
POWERLEVEL9K_DIR_FOREGROUND='white'
|
| 103 |
+
POWERLEVEL9K_SHORTEN_STRATEGY="truncate_middle"
|
| 104 |
+
POWERLEVEL9K_SHORTEN_DIR_LENGTH=3
|
| 105 |
+
|
| 106 |
+
# Git 状态
|
| 107 |
+
POWERLEVEL9K_VCS_CLEAN_BACKGROUND='green'
|
| 108 |
+
POWERLEVEL9K_VCS_CLEAN_FOREGROUND='black'
|
| 109 |
+
POWERLEVEL9K_VCS_MODIFIED_BACKGROUND='yellow'
|
| 110 |
+
POWERLEVEL9K_VCS_MODIFIED_FOREGROUND='black'
|
| 111 |
+
POWERLEVEL9K_VCS_UNTRACKED_BACKGROUND='magenta'
|
| 112 |
+
POWERLEVEL9K_VCS_UNTRACKED_FOREGROUND='black'
|
| 113 |
+
|
| 114 |
+
# 状态码
|
| 115 |
+
POWERLEVEL9K_STATUS_OK_BACKGROUND='black'
|
| 116 |
+
POWERLEVEL9K_STATUS_OK_FOREGROUND='green'
|
| 117 |
+
POWERLEVEL9K_STATUS_ERROR_BACKGROUND='black'
|
| 118 |
+
POWERLEVEL9K_STATUS_ERROR_FOREGROUND='red'
|
| 119 |
+
|
| 120 |
+
# 时间
|
| 121 |
+
POWERLEVEL9K_TIME_BACKGROUND='black'
|
| 122 |
+
POWERLEVEL9K_TIME_FOREGROUND='white'
|
| 123 |
+
POWERLEVEL9K_TIME_FORMAT='%D{%H:%M:%S}'
|
| 124 |
+
|
| 125 |
+
# 隐藏用户@主机(已经是 root)缩减长度
|
| 126 |
+
POWERLEVEL9K_CONTEXT_TEMPLATE="%n"
|
| 127 |
+
POWERLEVEL9K_CONTEXT_DEFAULT_BACKGROUND='black'
|
| 128 |
+
POWERLEVEL9K_CONTEXT_DEFAULT_FOREGROUND='white'
|
| 129 |
+
|
| 130 |
+
# 图标调整(避免乱码)
|
| 131 |
+
POWERLEVEL9K_OS_ICON_CONTENT_EXPANSION='⭐'
|
| 132 |
+
POWERLEVEL9K_VCS_BRANCH_ICON=''
|
| 133 |
+
|
| 134 |
+
# Instant Prompt(加速启动)
|
| 135 |
+
if [[ -r "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh" ]]; then
|
| 136 |
+
source "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh"
|
| 137 |
+
fi
|
| 138 |
+
EOF
|
| 139 |
+
|
| 140 |
+
# Zsh 主配置
|
| 141 |
+
RUN cat > /root/.zshrc <<'EOF'
|
| 142 |
+
export ZSH="$HOME/.oh-my-zsh"
|
| 143 |
+
export LANG=en_US.UTF-8
|
| 144 |
+
export LC_ALL=en_US.UTF-8
|
| 145 |
+
|
| 146 |
+
ZSH_THEME="powerlevel10k/powerlevel10k"
|
| 147 |
+
plugins=(
|
| 148 |
+
git
|
| 149 |
+
zsh-autosuggestions
|
| 150 |
+
zsh-syntax-highlighting
|
| 151 |
+
zsh-completions
|
| 152 |
+
docker
|
| 153 |
+
docker-compose
|
| 154 |
+
command-not-found
|
| 155 |
+
)
|
| 156 |
+
|
| 157 |
+
source $ZSH/oh-my-zsh.sh
|
| 158 |
+
|
| 159 |
+
# 历史记录优化
|
| 160 |
+
HISTFILE=~/.zsh_history
|
| 161 |
+
HISTSIZE=10000
|
| 162 |
+
SAVEHIST=10000
|
| 163 |
+
setopt appendhistory
|
| 164 |
+
setopt sharehistory
|
| 165 |
+
setopt hist_ignore_space
|
| 166 |
+
setopt hist_ignore_all_dups
|
| 167 |
+
|
| 168 |
+
# 别名
|
| 169 |
+
alias ll='ls -alF'
|
| 170 |
+
alias la='ls -A'
|
| 171 |
+
alias l='ls -CF'
|
| 172 |
+
alias ..='cd ..'
|
| 173 |
+
alias ...='cd ../..'
|
| 174 |
+
alias python='python3'
|
| 175 |
+
alias pip='pip3'
|
| 176 |
+
alias zshconfig='nano ~/.zshrc'
|
| 177 |
+
alias cls='clear'
|
| 178 |
+
|
| 179 |
+
# Powerlevel10k 配置
|
| 180 |
+
[[ -f ~/.p10k.zsh ]] && source ~/.p10k.zsh
|
| 181 |
+
|
| 182 |
+
# 自动补全
|
| 183 |
+
autoload -Uz compinit && compinit -C
|
| 184 |
+
EOF
|
| 185 |
|
| 186 |
+
RUN chsh -s $(which zsh) root
|
| 187 |
+
|
| 188 |
+
# ------------------------------------------------------------
|
| 189 |
+
# 5) Python Playwright + 浏览器
|
| 190 |
+
# ------------------------------------------------------------
|
| 191 |
+
RUN python3 -m pip install --no-cache-dir --upgrade pip setuptools wheel \
|
| 192 |
+
&& python3 -m pip install --no-cache-dir \
|
| 193 |
+
playwright \
|
| 194 |
+
pyautogui \
|
| 195 |
+
pillow \
|
| 196 |
+
numpy \
|
| 197 |
+
pandas \
|
| 198 |
+
requests \
|
| 199 |
+
beautifulsoup4 \
|
| 200 |
+
lxml \
|
| 201 |
+
fake-useragent \
|
| 202 |
+
scrapy \
|
| 203 |
+
&& python3 -m playwright install chromium \
|
| 204 |
+
&& python3 -m playwright install-deps chromium \
|
| 205 |
+
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* /root/.cache/pip
|
| 206 |
+
|
| 207 |
+
# ------------------------------------------------------------
|
| 208 |
+
# 6) Google Chrome(仅 amd64,arm64 跳过)
|
| 209 |
+
# ------------------------------------------------------------
|
| 210 |
+
RUN arch="$(dpkg --print-architecture)" \
|
| 211 |
+
&& if [ "${arch}" = "amd64" ]; then \
|
| 212 |
+
install -m 0755 -d /etc/apt/keyrings \
|
| 213 |
+
&& curl -fsSL https://dl.google.com/linux/linux_signing_key.pub | gpg --dearmor -o /etc/apt/keyrings/google-chrome.gpg \
|
| 214 |
+
&& chmod a+r /etc/apt/keyrings/google-chrome.gpg \
|
| 215 |
+
&& echo "deb [arch=amd64 signed-by=/etc/apt/keyrings/google-chrome.gpg] http://dl.google.com/linux/chrome/deb/ stable main" \
|
| 216 |
+
> /etc/apt/sources.list.d/google-chrome.list \
|
| 217 |
+
&& apt-get update \
|
| 218 |
+
&& apt-get install -y --no-install-recommends google-chrome-stable \
|
| 219 |
+
&& rm -rf /var/lib/apt/lists/*; \
|
| 220 |
+
else echo "Skip Chrome on ${arch}"; fi
|
| 221 |
+
|
| 222 |
+
# ------------------------------------------------------------
|
| 223 |
+
# 7) Code-server(VS Code Web)
|
| 224 |
+
# ------------------------------------------------------------
|
| 225 |
+
RUN curl -fsSL https://code-server.dev/install.sh | sh
|
| 226 |
+
|
| 227 |
+
# ------------------------------------------------------------
|
| 228 |
+
# 8) Code-server 配置(root 用户、优化体验)
|
| 229 |
+
# ------------------------------------------------------------
|
| 230 |
RUN mkdir -p /root/.config/code-server \
|
| 231 |
&& mkdir -p /root/.local/share/code-server/User \
|
| 232 |
+
&& cat > /root/.config/code-server/config.yaml <<EOF
|
| 233 |
bind-addr: 0.0.0.0:7860
|
| 234 |
auth: none
|
| 235 |
disable-telemetry: true
|
| 236 |
disable-update-check: true
|
| 237 |
EOF
|
| 238 |
|
| 239 |
+
# VS Code 用户设置(最佳实践)
|
| 240 |
RUN cat > /root/.local/share/code-server/User/settings.json <<'EOF'
|
| 241 |
{
|
| 242 |
"workbench.colorTheme": "Default Dark+",
|
|
|
|
| 247 |
"extensions.autoUpdate": false,
|
| 248 |
"security.workspace.trust.enabled": false,
|
| 249 |
"security.workspace.trust.startupPrompt": "never",
|
| 250 |
+
"terminal.integrated.defaultProfile.linux": "zsh",
|
| 251 |
"terminal.integrated.profiles.linux": {
|
| 252 |
+
"zsh": { "path": "/usr/bin/zsh", "icon": "terminal" },
|
| 253 |
+
"bash": { "path": "/bin/bash", "icon": "terminal-bash" }
|
|
|
|
|
|
|
| 254 |
},
|
| 255 |
+
"terminal.integrated.fontFamily": "monospace",
|
| 256 |
"python.defaultInterpreterPath": "/usr/bin/python3",
|
|
|
|
| 257 |
"git.enableSmartCommit": true,
|
| 258 |
"git.confirmSync": false,
|
| 259 |
"editor.formatOnSave": true,
|
|
|
|
| 261 |
"editor.tabSize": 4,
|
| 262 |
"editor.insertSpaces": true,
|
| 263 |
"editor.wordWrap": "on",
|
| 264 |
+
"files.exclude": { "**/.git": false },
|
|
|
|
|
|
|
| 265 |
"explorer.confirmDragAndDrop": false,
|
| 266 |
"explorer.confirmDelete": false
|
| 267 |
}
|
| 268 |
EOF
|
| 269 |
|
| 270 |
+
# 预装常用扩展(不阻塞构建)
|
| 271 |
RUN code-server --install-extension ms-python.python --force || true \
|
| 272 |
&& code-server --install-extension ms-toolsai.jupyter --force || true \
|
|
|
|
| 273 |
&& code-server --install-extension ms-azuretools.vscode-docker --force || true \
|
| 274 |
&& code-server --install-extension redhat.vscode-yaml --force || true \
|
| 275 |
&& code-server --install-extension formulahendry.auto-close-tag --force || true \
|
|
|
|
| 283 |
&& code-server --install-extension yzhang.markdown-all-in-one --force || true \
|
| 284 |
|| true
|
| 285 |
|
| 286 |
+
# 工作目录
|
| 287 |
+
RUN mkdir -p /workspace
|
| 288 |
+
WORKDIR /workspace
|
|
|
|
|
|
|
| 289 |
|
|
|
|
| 290 |
EXPOSE 7860
|
| 291 |
|
| 292 |
+
# 直接用 root 启动(符合你的要求)
|
| 293 |
+
CMD ["/usr/bin/code-server", "--bind-addr", "0.0.0.0:7860", "--auth", "none", "--disable-telemetry", "--disable-update-check", "/workspace"]
|