Pikilap commited on
Commit
ebdac77
·
verified ·
1 Parent(s): ee0a899

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +55 -110
Dockerfile CHANGED
@@ -1,5 +1,4 @@
1
  FROM ubuntu:22.04
2
-
3
  SHELL ["/bin/bash", "-o", "pipefail", "-c"]
4
 
5
  ENV DEBIAN_FRONTEND=noninteractive \
@@ -15,7 +14,7 @@ ENV DEBIAN_FRONTEND=noninteractive \
15
  ZSH=/root/.oh-my-zsh
16
 
17
  # ------------------------------------------------------------
18
- # 1) 基础系统 + 所有工具链 + 依赖(修正后的包名)
19
  # ------------------------------------------------------------
20
  RUN apt-get update && apt-get install -y --no-install-recommends \
21
  ca-certificates curl wget git git-lfs sudo \
@@ -36,33 +35,20 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
36
  libmagic-dev \
37
  ffmpeg tesseract-ocr \
38
  fontconfig fonts-liberation fonts-noto-cjk fonts-noto-color-emoji \
39
- iptables uidmap slirp4netns fuse-overlayfs \
40
  libasound2 libatk-bridge2.0-0 libatk1.0-0 libc6 libcairo2 libcups2 \
41
  libdbus-1-3 libdrm2 libexpat1 libgbm1 libgcc-s1 libglib2.0-0 libgtk-3-0 \
42
  libnspr4 libnss3 libpango-1.0-0 libpangocairo-1.0-0 libstdc++6 \
43
  libx11-6 libx11-xcb1 libxcb1 libxcomposite1 libxcursor1 libxdamage1 libxext6 \
44
  libxfixes3 libxi6 libxkbcommon0 libxrandr2 libxrender1 libxshmfence1 libxss1 libxtst6 \
45
- libatspi2.0-0 \
46
- libwayland-client0 libwayland-cursor0 libwayland-egl1 libwayland-server0 \
47
  libxkbfile1 libcurl4 \
48
  && locale-gen en_US.UTF-8 \
49
  && update-locale LANG=en_US.UTF-8 \
50
  && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
51
 
52
  # ------------------------------------------------------------
53
- # 2) Docker Engine (dockerd + cli)
54
- # ------------------------------------------------------------
55
- RUN install -m 0755 -d /etc/apt/keyrings \
56
- && curl -fsSL https://download.docker.com/linux/ubuntu/gpg | gpg --dearmor -o /etc/apt/keyrings/docker.gpg \
57
- && chmod a+r /etc/apt/keyrings/docker.gpg \
58
- && echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu jammy stable" \
59
- > /etc/apt/sources.list.d/docker.list \
60
- && apt-get update \
61
- && apt-get install -y --no-install-recommends docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin \
62
- && rm -rf /var/lib/apt/lists/*
63
-
64
- # ------------------------------------------------------------
65
- # 3) Node.js v25 (使用 NodeSource 官方源,最可靠)
66
  # ------------------------------------------------------------
67
  RUN curl -fsSL https://deb.nodesource.com/setup_25.x | bash - \
68
  && apt-get install -y --no-install-recommends nodejs \
@@ -72,12 +58,12 @@ RUN curl -fsSL https://deb.nodesource.com/setup_25.x | bash - \
72
  && node -v
73
 
74
  # ------------------------------------------------------------
75
- # 4) code-server
76
  # ------------------------------------------------------------
77
  RUN curl -fsSL https://code-server.dev/install.sh | sh
78
 
79
  # ------------------------------------------------------------
80
- # 5) Playwright (Python) + Chromium
81
  # ------------------------------------------------------------
82
  RUN mkdir -p "${PLAYWRIGHT_BROWSERS_PATH}" \
83
  && python3 -m pip install --no-cache-dir --upgrade pip setuptools wheel \
@@ -86,7 +72,7 @@ RUN mkdir -p "${PLAYWRIGHT_BROWSERS_PATH}" \
86
  && rm -rf /root/.cache/pip
87
 
88
  # ------------------------------------------------------------
89
- # 6) Google Chrome (仅 amd64)
90
  # ------------------------------------------------------------
91
  RUN set -eux; \
92
  arch="$(dpkg --print-architecture)"; \
@@ -95,7 +81,7 @@ RUN set -eux; \
95
  curl -fsSL https://dl.google.com/linux/linux_signing_key.pub | gpg --dearmor -o /etc/apt/keyrings/google-chrome.gpg; \
96
  chmod a+r /etc/apt/keyrings/google-chrome.gpg; \
97
  echo "deb [arch=amd64 signed-by=/etc/apt/keyrings/google-chrome.gpg] http://dl.google.com/linux/chrome/deb/ stable main" \
98
- > /etc/apt/sources.list.d/google-chrome.list; \
99
  apt-get update; \
100
  apt-get install -y --no-install-recommends google-chrome-stable; \
101
  rm -rf /var/lib/apt/lists/*; \
@@ -104,53 +90,29 @@ RUN set -eux; \
104
  fi
105
 
106
  # ------------------------------------------------------------
107
- # 7) Zsh + Oh-my-zsh + 自定义主题 (无emoji, 自动配色)
 
 
108
  # ------------------------------------------------------------
109
  RUN git clone --depth=1 https://github.com/ohmyzsh/ohmyzsh.git "${ZSH}" \
110
  && git clone --depth=1 https://github.com/zsh-users/zsh-autosuggestions "${ZSH}/custom/plugins/zsh-autosuggestions" \
111
  && git clone --depth=1 https://github.com/zsh-users/zsh-syntax-highlighting "${ZSH}/custom/plugins/zsh-syntax-highlighting"
112
 
113
- RUN mkdir -p "${ZSH}/custom/themes" \
114
- && cat > "${ZSH}/custom/themes/pure-minimal.zsh-theme" <<'THEME'
115
- # pure-minimal: 自��适应终端配色,无emoji
116
- # 左侧: 用户名@主机名 路径
117
- # 右侧: 时间 HH:MM:SS
118
-
119
- # 颜色定义 (zsh 标准色码)
120
- local user_color='%F{green}'
121
- [[ $EUID -eq 0 ]] && user_color='%F{red}'
122
-
123
- local path_color='%F{cyan}'
124
- local time_color='%F{240}'
125
-
126
- # 左侧提示符: user@host ~/path
127
- PROMPT='${user_color}%n@%m%f ${path_color}%~%f %# '
128
-
129
- # 右侧提示符: 时间
130
- RPROMPT='${time_color}%*%f'
131
-
132
- # 第二行提示符
133
- PROMPT2='%F{yellow}...%f %# '
134
-
135
- # 更新终端标题
136
- precmd() { print -Pn "\e]0;%n@%m: %~\a" }
137
- THEME
138
-
139
  RUN cat > /root/.zshrc <<'EOF'
140
  export ZSH="$HOME/.oh-my-zsh"
 
 
141
 
142
  # 禁用更新提示
143
  zstyle ':omz:update' mode disabled
144
  export ZSH_DISABLE_COMPFIX=true
145
 
146
  # 主题
147
- ZSH_THEME="pure-minimal"
148
 
149
  # 插件
150
  plugins=(
151
  git
152
- docker
153
- docker-compose
154
  zsh-autosuggestions
155
  zsh-syntax-highlighting
156
  command-not-found
@@ -164,7 +126,7 @@ HISTSIZE=50000
164
  SAVEHIST=50000
165
  setopt appendhistory sharehistory hist_ignore_space hist_ignore_all_dups
166
 
167
- # 别名
168
  alias ll='ls -alF --color=auto'
169
  alias la='ls -A --color=auto'
170
  alias l='ls -CF --color=auto'
@@ -175,21 +137,49 @@ alias pip='pip3'
175
  alias zshconfig='nano ~/.zshrc'
176
  alias cls='clear'
177
  alias reload='source ~/.zshrc'
178
- alias d='docker'
179
- alias dc='docker compose'
180
 
181
  # 自动补全优化
182
  autoload -Uz compinit && compinit -C
183
 
184
- # zsh-autosuggestions 快捷键
185
  bindkey '^ ' autosuggest-accept
186
  EOF
187
 
188
- # 默认 shell 改为 zsh
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
189
  RUN chsh -s $(which zsh) root
190
 
191
  # ------------------------------------------------------------
192
- # 8) code-server 配置
193
  # ------------------------------------------------------------
194
  RUN mkdir -p /root/.config/code-server /root/.local/share/code-server/User \
195
  && cat > /root/.config/code-server/config.yaml <<'EOF'
@@ -215,7 +205,7 @@ RUN cat > /root/.local/share/code-server/User/settings.json <<'EOF'
215
  }
216
  EOF
217
 
218
- # 预装常用扩展
219
  RUN code-server --install-extension ms-python.python --force 2>/dev/null || true \
220
  && code-server --install-extension ms-toolsai.jupyter --force 2>/dev/null || true \
221
  && code-server --install-extension ms-azuretools.vscode-docker --force 2>/dev/null || true \
@@ -225,57 +215,12 @@ RUN code-server --install-extension ms-python.python --force 2>/dev/null || true
225
  && code-server --install-extension eamodio.gitlens --force 2>/dev/null || true
226
 
227
  # ------------------------------------------------------------
228
- # 9) 启动脚本 (尝试启动 dockerd,然后启动 code-server)
229
  # ------------------------------------------------------------
230
- RUN cat > /usr/local/bin/start.sh <<'EOF'
231
- #!/usr/bin/env bash
232
- set -euo pipefail
233
-
234
- export HOME="${HOME:-/root}"
235
- export PORT="${PORT:-7860}"
236
-
237
- # 尝试启动 Docker 守护进程 (HF Spaces 可能无特权,失败不阻断)
238
- if command -v dockerd >/dev/null 2>&1; then
239
- if ! docker info >/dev/null 2>&1 2>/dev/null; then
240
- mkdir -p /var/log /var/run /var/lib/docker
241
- echo "[start] attempting to start dockerd..."
242
-
243
- # 后台启动 dockerd
244
- (
245
- dockerd --host=unix:///var/run/docker.sock \
246
- --data-root=/var/lib/docker \
247
- --storage-driver=vfs \
248
- 2>/var/log/dockerd.log
249
- ) &
250
-
251
- # 等待最多5秒
252
- for i in {1..10}; do
253
- if docker info >/dev/null 2>&1 2>/dev/null; then
254
- echo "[start] dockerd is ready"
255
- break
256
- fi
257
- sleep 0.5
258
- done
259
-
260
- if ! docker info >/dev/null 2>&1 2>/dev/null; then
261
- echo "[start] dockerd not available (expected in restricted environments)"
262
- fi
263
- fi
264
- fi
265
 
266
- mkdir -p /workspace
267
- echo "[start] starting code-server on port ${PORT}"
268
-
269
- exec code-server \
270
- --bind-addr "0.0.0.0:${PORT}" \
271
- --auth none \
272
- --disable-telemetry \
273
- --disable-update-check \
274
- /workspace
275
- EOF
276
-
277
- RUN chmod +x /usr/local/bin/start.sh
278
-
279
- WORKDIR /workspace
280
  EXPOSE 7860
281
- CMD ["/usr/local/bin/start.sh"]
 
1
  FROM ubuntu:22.04
 
2
  SHELL ["/bin/bash", "-o", "pipefail", "-c"]
3
 
4
  ENV DEBIAN_FRONTEND=noninteractive \
 
14
  ZSH=/root/.oh-my-zsh
15
 
16
  # ------------------------------------------------------------
17
+ # 1) 基础系统 + 工具链(去除 Docker)
18
  # ------------------------------------------------------------
19
  RUN apt-get update && apt-get install -y --no-install-recommends \
20
  ca-certificates curl wget git git-lfs sudo \
 
35
  libmagic-dev \
36
  ffmpeg tesseract-ocr \
37
  fontconfig fonts-liberation fonts-noto-cjk fonts-noto-color-emoji \
38
+ # Playwright deps
39
  libasound2 libatk-bridge2.0-0 libatk1.0-0 libc6 libcairo2 libcups2 \
40
  libdbus-1-3 libdrm2 libexpat1 libgbm1 libgcc-s1 libglib2.0-0 libgtk-3-0 \
41
  libnspr4 libnss3 libpango-1.0-0 libpangocairo-1.0-0 libstdc++6 \
42
  libx11-6 libx11-xcb1 libxcb1 libxcomposite1 libxcursor1 libxdamage1 libxext6 \
43
  libxfixes3 libxi6 libxkbcommon0 libxrandr2 libxrender1 libxshmfence1 libxss1 libxtst6 \
44
+ libatspi2.0-0 libwayland-client0 libwayland-cursor0 libwayland-egl1 libwayland-server0 \
 
45
  libxkbfile1 libcurl4 \
46
  && locale-gen en_US.UTF-8 \
47
  && update-locale LANG=en_US.UTF-8 \
48
  && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
49
 
50
  # ------------------------------------------------------------
51
+ # 2) Node.js 25
 
 
 
 
 
 
 
 
 
 
 
 
52
  # ------------------------------------------------------------
53
  RUN curl -fsSL https://deb.nodesource.com/setup_25.x | bash - \
54
  && apt-get install -y --no-install-recommends nodejs \
 
58
  && node -v
59
 
60
  # ------------------------------------------------------------
61
+ # 3) code-server
62
  # ------------------------------------------------------------
63
  RUN curl -fsSL https://code-server.dev/install.sh | sh
64
 
65
  # ------------------------------------------------------------
66
+ # 4) Playwright + Chromium
67
  # ------------------------------------------------------------
68
  RUN mkdir -p "${PLAYWRIGHT_BROWSERS_PATH}" \
69
  && python3 -m pip install --no-cache-dir --upgrade pip setuptools wheel \
 
72
  && rm -rf /root/.cache/pip
73
 
74
  # ------------------------------------------------------------
75
+ # 5) Google Chrome (amd64 only)
76
  # ------------------------------------------------------------
77
  RUN set -eux; \
78
  arch="$(dpkg --print-architecture)"; \
 
81
  curl -fsSL https://dl.google.com/linux/linux_signing_key.pub | gpg --dearmor -o /etc/apt/keyrings/google-chrome.gpg; \
82
  chmod a+r /etc/apt/keyrings/google-chrome.gpg; \
83
  echo "deb [arch=amd64 signed-by=/etc/apt/keyrings/google-chrome.gpg] http://dl.google.com/linux/chrome/deb/ stable main" \
84
+ > /etc/apt/sources.list.d/google-chrome.list; \
85
  apt-get update; \
86
  apt-get install -y --no-install-recommends google-chrome-stable; \
87
  rm -rf /var/lib/apt/lists/*; \
 
90
  fi
91
 
92
  # ------------------------------------------------------------
93
+ # 6) Zsh + Oh-my-zsh + 圆角边框主题
94
+ # 左侧:╭─ username ~/path ─╮
95
+ # 右侧:╭─ time ─╯
96
  # ------------------------------------------------------------
97
  RUN git clone --depth=1 https://github.com/ohmyzsh/ohmyzsh.git "${ZSH}" \
98
  && git clone --depth=1 https://github.com/zsh-users/zsh-autosuggestions "${ZSH}/custom/plugins/zsh-autosuggestions" \
99
  && git clone --depth=1 https://github.com/zsh-users/zsh-syntax-highlighting "${ZSH}/custom/plugins/zsh-syntax-highlighting"
100
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
101
  RUN cat > /root/.zshrc <<'EOF'
102
  export ZSH="$HOME/.oh-my-zsh"
103
+ export LANG=en_US.UTF-8
104
+ export LC_ALL=en_US.UTF-8
105
 
106
  # 禁用更新提示
107
  zstyle ':omz:update' mode disabled
108
  export ZSH_DISABLE_COMPFIX=true
109
 
110
  # 主题
111
+ ZSH_THEME="rounded-minimal"
112
 
113
  # 插件
114
  plugins=(
115
  git
 
 
116
  zsh-autosuggestions
117
  zsh-syntax-highlighting
118
  command-not-found
 
126
  SAVEHIST=50000
127
  setopt appendhistory sharehistory hist_ignore_space hist_ignore_all_dups
128
 
129
+ # 常用别名
130
  alias ll='ls -alF --color=auto'
131
  alias la='ls -A --color=auto'
132
  alias l='ls -CF --color=auto'
 
137
  alias zshconfig='nano ~/.zshrc'
138
  alias cls='clear'
139
  alias reload='source ~/.zshrc'
140
+ alias c='clear'
 
141
 
142
  # 自动补全优化
143
  autoload -Uz compinit && compinit -C
144
 
145
+ # zsh-autosuggestions 快捷键:Ctrl+空格接受建议
146
  bindkey '^ ' autosuggest-accept
147
  EOF
148
 
149
+ # 创建自定义圆角主题
150
+ RUN mkdir -p "${ZSH}/custom/themes" \
151
+ && cat > "${ZSH}/custom/themes/rounded-minimal.zsh-theme" <<'THEME'
152
+ # Rounded box theme - 圆角边框风格
153
+ # 左侧:╭─ username ~/path ─╮
154
+ # ╰─▶
155
+ # 右侧:╭─ time ─╯
156
+
157
+ # 颜色定义
158
+ local left_bracket='%F{green}' # 左边框线颜色(绿色)
159
+ local right_bracket='%F{cyan}' # 右边框线颜色(青色)
160
+ local user_color='%F{yellow}' # 用户名(黄色)
161
+ local path_color='%F{blue}' # 路径(蓝色)
162
+ local time_color='%F{240}' # 时间(灰色)
163
+ local reset='%f' # 重置
164
+
165
+ # 提示符内容
166
+ # ╭─ username ~/path ─╮
167
+ # ╰─▶
168
+ PROMPT='${left_bracket}╭─%f ${user_color}%n%f ${path_color}%~%f ${left_bracket}─╮%f
169
+ ${left_bracket}╰─%f '
170
+
171
+ # 右侧提示符:时间带圆角框
172
+ RPROMPT='${right_bracket}╭─%f ${time_color}%*%f ${right_bracket}─╯%f'
173
+
174
+ # 第二行提示符(续行)
175
+ PROMPT2='${left_bracket}│ %_%f${reset} '
176
+ EOF
177
+
178
+ # 设置默认 shell
179
  RUN chsh -s $(which zsh) root
180
 
181
  # ------------------------------------------------------------
182
+ # 7) code-server 配置
183
  # ------------------------------------------------------------
184
  RUN mkdir -p /root/.config/code-server /root/.local/share/code-server/User \
185
  && cat > /root/.config/code-server/config.yaml <<'EOF'
 
205
  }
206
  EOF
207
 
208
+ # 预装扩展
209
  RUN code-server --install-extension ms-python.python --force 2>/dev/null || true \
210
  && code-server --install-extension ms-toolsai.jupyter --force 2>/dev/null || true \
211
  && code-server --install-extension ms-azuretools.vscode-docker --force 2>/dev/null || true \
 
215
  && code-server --install-extension eamodio.gitlens --force 2>/dev/null || true
216
 
217
  # ------------------------------------------------------------
218
+ # 8) 工作目录设为家目录(~)
219
  # ------------------------------------------------------------
220
+ WORKDIR /root
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
221
 
222
+ # ------------------------------------------------------------
223
+ # 9) 启动(直接启动,无 Docker 检查)
224
+ # ------------------------------------------------------------
 
 
 
 
 
 
 
 
 
 
 
225
  EXPOSE 7860
226
+ CMD ["code-server", "--bind-addr", "0.0.0.0:7860", "--auth", "none", "--disable-telemetry", "--disable-update-check", "/root"]