Pikilap commited on
Commit
864d62a
·
verified ·
1 Parent(s): cc94aba

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +114 -49
Dockerfile CHANGED
@@ -16,47 +16,114 @@ ENV DEBIAN_FRONTEND=noninteractive \
16
  # 1) 安装系统基础依赖与 Playwright 运行环境
17
  # ------------------------------------------------------------
18
  RUN apt-get update && apt-get install -y --no-install-recommends \
19
- ca-certificates curl wget git git-lfs sudo zsh locales tzdata \
20
- vim nano jq tree htop tmux zip unzip tar xz-utils \
21
- build-essential python3 python3-pip python3-dev python-is-python3 \
22
- # Playwright & Chrome 运行时库
23
- libasound2 libatk-bridge2.0-0 libatk1.0-0 libc6 libcairo2 libcups2 \
24
- libdbus-1-3 libdrm2 libexpat1 libgbm1 libgcc-s1 libglib2.0-0 libgtk-3-0 \
25
- libnspr4 libnss3 libpango-1.0-0 libpangocairo-1.0-0 libstdc++6 \
26
- libx11-6 libx11-xcb1 libxcb1 libxcomposite1 libxcursor1 libxdamage1 libxext6 \
27
- libxfixes3 libxi6 libxkbcommon0 libxrandr2 libxrender1 libxshmfence1 libxss1 libxtst6 \
28
- libatspi2.0-0 libwayland-client0 libwayland-cursor0 libwayland-egl1 \
29
- && locale-gen en_US.UTF-8 \
30
- && update-locale LANG=en_US.UTF-8 \
31
- && rm -rf /var/lib/apt/lists/*
32
-
33
- # ------------------------------------------------------------
34
- # 2) 安装最新的 Node.js 25 & pnpm
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
35
  # ------------------------------------------------------------
36
  RUN curl -fsSL https://deb.nodesource.com/setup_25.x | bash - \
37
- && apt-get install -y --no-install-recommends nodejs \
38
- && npm install -g pnpm@latest npm@latest \
39
- && npm cache clean --force
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
40
 
41
  # ------------------------------------------------------------
42
- # 3) 安装 code-server & Playwright
43
  # ------------------------------------------------------------
44
  RUN curl -fsSL https://code-server.dev/install.sh | sh \
45
- && python3 -m pip install --no-cache-dir --upgrade pip setuptools wheel \
46
- && python3 -m pip install --no-cache-dir playwright \
47
- && python3 -m playwright install chromium \
48
- && rm -rf /root/.cache/pip
49
 
50
  # ------------------------------------------------------------
51
- # 4) Zsh 极简主题配置 (去框、去除主机名、仅显示 user:path)
52
  # ------------------------------------------------------------
53
  RUN git clone --depth=1 https://github.com/ohmyzsh/ohmyzsh.git "${ZSH}" \
54
- && git clone --depth=1 https://github.com/zsh-users/zsh-autosuggestions "${ZSH}/custom/plugins/zsh-autosuggestions" \
55
- && git clone --depth=1 https://github.com/zsh-users/zsh-syntax-highlighting "${ZSH}/custom/plugins/zsh-syntax-highlighting"
56
 
57
  RUN mkdir -p "${ZSH}/custom/themes" \
58
- && echo 'PROMPT="%F{green}%n%f:%F{cyan}%~%f > "' > "${ZSH}/custom/themes/minimal.zsh-theme" \
59
- && echo 'RPROMPT="%F{240}[%*]%f"' >> "${ZSH}/custom/themes/minimal.zsh-theme"
60
 
61
  RUN cat > /root/.zshrc <<'EOF'
62
  export ZSH="$HOME/.oh-my-zsh"
@@ -72,40 +139,37 @@ bindkey '^ ' autosuggest-accept
72
  EOF
73
 
74
  # ------------------------------------------------------------
75
- # 5) 数据持久化脚本 (智能排除依赖库)
76
  # ------------------------------------------------------------
77
  RUN cat > /root/persistence.py <<'EOF'
78
  import os, sys, tarfile
79
 
80
  BACKUP_NAME = "space_source_backup.tar.gz"
81
 
82
- # 排除列表:这些目录体积巨大且可以重新下载,不进入备份
83
  EXCLUDE_DIRS = {
84
- "node_modules", ".npm", ".pnpm-store", ".cache",
85
  "__pycache__", "venv", ".venv", ".pytest_cache",
86
  "CachedExtensionVSIXs", "workspaceStorage", "logs"
87
  }
88
 
89
  def filter_function(tarinfo):
90
- # 如果当前文件夹名在排除列表中,整个剔除
91
  name = os.path.basename(tarinfo.name)
92
  if name in EXCLUDE_DIRS:
93
- print(f" -> Skipping: {tarinfo.name}")
94
  return None
95
  return tarinfo
96
 
97
  def backup():
98
- print(f"[*] 正在执行智能备份 (已排除 node_modules/venv 等依赖)...")
99
  with tarfile.open(BACKUP_NAME, "w:gz") as tar:
100
- # 只备份根目录下非备份文件本身的内容
101
  for item in os.listdir("/root"):
102
  if item != BACKUP_NAME:
103
  tar.add(os.path.join("/root", item), arcname=item, filter=filter_function)
104
-
105
  size_mb = os.path.getsize(BACKUP_NAME) / (1024 * 1024)
106
  print(f"[+] 备份成功!体积:{size_mb:.2f} MB")
107
  print(f"[!] 请在侧边栏右键点击 {BACKUP_NAME} 选择 'Download' 下载。")
108
- print(f"[提示] 下次还原后,只需重新执行 npm/pnpm install 或 pip install 即可。")
109
 
110
  def restore():
111
  if not os.path.exists(BACKUP_NAME):
@@ -117,16 +181,17 @@ def restore():
117
  print("[+] 还原成功!请重新安装项目依赖。")
118
 
119
  if __name__ == "__main__":
120
- if "--backup" in sys.argv: backup()
121
- elif "--restore" in sys.argv: restore()
 
 
122
  EOF
123
 
124
  # ------------------------------------------------------------
125
- # 6) code-server 设置 (已修复 YAML 语法错误)
126
  # ------------------------------------------------------------
127
  RUN mkdir -p /root/.config/code-server /root/.local/share/code-server/User
128
 
129
- # 使用 cat heredoc 保证 YAML 格式正确
130
  RUN cat > /root/.config/code-server/config.yaml <<'EOF'
131
  bind-addr: 0.0.0.0:7860
132
  auth: none
@@ -134,19 +199,19 @@ EOF
134
 
135
  RUN cat > /root/.local/share/code-server/User/settings.json <<'EOF'
136
  {
137
- "workbench.startupEditor": "none",
138
- "telemetry.telemetryLevel": "off",
139
- "terminal.integrated.defaultProfile.linux": "zsh",
140
- "security.workspace.trust.enabled": false,
141
- "workbench.colorTheme": "Default Dark+"
142
  }
143
  EOF
144
 
145
  # ------------------------------------------------------------
146
- # 7) 最终配置
147
  # ------------------------------------------------------------
148
  WORKDIR /root
149
  EXPOSE 7860
150
- RUN chsh -s $(which zsh) root
151
 
152
  ENTRYPOINT ["code-server", "--bind-addr", "0.0.0.0:7860", "--auth", "none", "/root"]
 
16
  # 1) 安装系统基础依赖与 Playwright 运行环境
17
  # ------------------------------------------------------------
18
  RUN apt-get update && apt-get install -y --no-install-recommends \
19
+ ca-certificates \
20
+ curl \
21
+ wget \
22
+ git \
23
+ git-lfs \
24
+ sudo \
25
+ zsh \
26
+ locales \
27
+ tzdata \
28
+ gnupg \
29
+ vim \
30
+ nano \
31
+ jq \
32
+ tree \
33
+ htop \
34
+ tmux \
35
+ zip \
36
+ unzip \
37
+ tar \
38
+ xz-utils \
39
+ build-essential \
40
+ python3 \
41
+ python3-pip \
42
+ python3-dev \
43
+ python-is-python3 \
44
+ libasound2 \
45
+ libatk-bridge2.0-0 \
46
+ libatk1.0-0 \
47
+ libc6 \
48
+ libcairo2 \
49
+ libcups2 \
50
+ libdbus-1-3 \
51
+ libdrm2 \
52
+ libexpat1 \
53
+ libgbm1 \
54
+ libgcc-s1 \
55
+ libglib2.0-0 \
56
+ libgtk-3-0 \
57
+ libnspr4 \
58
+ libnss3 \
59
+ libpango-1.0-0 \
60
+ libpangocairo-1.0-0 \
61
+ libstdc++6 \
62
+ libx11-6 \
63
+ libx11-xcb1 \
64
+ libxcb1 \
65
+ libxcomposite1 \
66
+ libxcursor1 \
67
+ libxdamage1 \
68
+ libxext6 \
69
+ libxfixes3 \
70
+ libxi6 \
71
+ libxkbcommon0 \
72
+ libxrandr2 \
73
+ libxrender1 \
74
+ libxshmfence1 \
75
+ libxss1 \
76
+ libxtst6 \
77
+ libatspi2.0-0 \
78
+ libwayland-client0 \
79
+ libwayland-cursor0 \
80
+ libwayland-egl1 \
81
+ && locale-gen en_US.UTF-8 \
82
+ && update-locale LANG=en_US.UTF-8 \
83
+ && rm -rf /var/lib/apt/lists/*
84
+
85
+ # ------------------------------------------------------------
86
+ # 2) 安装最新 Node.js 25 / pnpm / npm / Claude Code
87
  # ------------------------------------------------------------
88
  RUN curl -fsSL https://deb.nodesource.com/setup_25.x | bash - \
89
+ && apt-get update \
90
+ && apt-get install -y --no-install-recommends nodejs \
91
+ && npm install -g npm@latest pnpm@latest @anthropic-ai/claude-code \
92
+ && npm cache clean --force \
93
+ && rm -rf /var/lib/apt/lists/*
94
+
95
+ # ------------------------------------------------------------
96
+ # 3) 安装 GitHub CLI (gh)
97
+ # ------------------------------------------------------------
98
+ RUN mkdir -p -m 755 /etc/apt/keyrings \
99
+ && curl -fsSL https://cli.github.com/packages/githubcli-archive-keyring.gpg \
100
+ | gpg --dearmor -o /etc/apt/keyrings/githubcli-archive-keyring.gpg \
101
+ && chmod go+r /etc/apt/keyrings/githubcli-archive-keyring.gpg \
102
+ && echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" \
103
+ > /etc/apt/sources.list.d/github-cli.list \
104
+ && apt-get update \
105
+ && apt-get install -y --no-install-recommends gh \
106
+ && rm -rf /var/lib/apt/lists/*
107
 
108
  # ------------------------------------------------------------
109
+ # 4) 安装 code-server & Playwright
110
  # ------------------------------------------------------------
111
  RUN curl -fsSL https://code-server.dev/install.sh | sh \
112
+ && python3 -m pip install --no-cache-dir --upgrade pip setuptools wheel \
113
+ && python3 -m pip install --no-cache-dir playwright \
114
+ && python3 -m playwright install chromium \
115
+ && rm -rf /root/.cache/pip
116
 
117
  # ------------------------------------------------------------
118
+ # 5) Zsh 极简主题配置 (去框、去除主机名、仅显示 user:path)
119
  # ------------------------------------------------------------
120
  RUN git clone --depth=1 https://github.com/ohmyzsh/ohmyzsh.git "${ZSH}" \
121
+ && git clone --depth=1 https://github.com/zsh-users/zsh-autosuggestions "${ZSH}/custom/plugins/zsh-autosuggestions" \
122
+ && git clone --depth=1 https://github.com/zsh-users/zsh-syntax-highlighting "${ZSH}/custom/plugins/zsh-syntax-highlighting"
123
 
124
  RUN mkdir -p "${ZSH}/custom/themes" \
125
+ && echo 'PROMPT="%F{green}%n%f:%F{cyan}%~%f > "' > "${ZSH}/custom/themes/minimal.zsh-theme" \
126
+ && echo 'RPROMPT="%F{240}[%*]%f"' >> "${ZSH}/custom/themes/minimal.zsh-theme"
127
 
128
  RUN cat > /root/.zshrc <<'EOF'
129
  export ZSH="$HOME/.oh-my-zsh"
 
139
  EOF
140
 
141
  # ------------------------------------------------------------
142
+ # 6) 数据持久化脚本 (智能排除依赖库)
143
  # ------------------------------------------------------------
144
  RUN cat > /root/persistence.py <<'EOF'
145
  import os, sys, tarfile
146
 
147
  BACKUP_NAME = "space_source_backup.tar.gz"
148
 
 
149
  EXCLUDE_DIRS = {
150
+ "node_modules", ".npm", ".pnpm-store", ".cache",
151
  "__pycache__", "venv", ".venv", ".pytest_cache",
152
  "CachedExtensionVSIXs", "workspaceStorage", "logs"
153
  }
154
 
155
  def filter_function(tarinfo):
 
156
  name = os.path.basename(tarinfo.name)
157
  if name in EXCLUDE_DIRS:
158
+ print(f" -> Skipping: {tarinfo.name}")
159
  return None
160
  return tarinfo
161
 
162
  def backup():
163
+ print("[*] 正在执行智能备份 (已排除 node_modules/venv 等依赖)...")
164
  with tarfile.open(BACKUP_NAME, "w:gz") as tar:
 
165
  for item in os.listdir("/root"):
166
  if item != BACKUP_NAME:
167
  tar.add(os.path.join("/root", item), arcname=item, filter=filter_function)
168
+
169
  size_mb = os.path.getsize(BACKUP_NAME) / (1024 * 1024)
170
  print(f"[+] 备份成功!体积:{size_mb:.2f} MB")
171
  print(f"[!] 请在侧边栏右键点击 {BACKUP_NAME} 选择 'Download' 下载。")
172
+ print("[提示] 下次还原后,只需重新执行 npm/pnpm install 或 pip install 即可。")
173
 
174
  def restore():
175
  if not os.path.exists(BACKUP_NAME):
 
181
  print("[+] 还原成功!请重新安装项目依赖。")
182
 
183
  if __name__ == "__main__":
184
+ if "--backup" in sys.argv:
185
+ backup()
186
+ elif "--restore" in sys.argv:
187
+ restore()
188
  EOF
189
 
190
  # ------------------------------------------------------------
191
+ # 7) code-server 设置
192
  # ------------------------------------------------------------
193
  RUN mkdir -p /root/.config/code-server /root/.local/share/code-server/User
194
 
 
195
  RUN cat > /root/.config/code-server/config.yaml <<'EOF'
196
  bind-addr: 0.0.0.0:7860
197
  auth: none
 
199
 
200
  RUN cat > /root/.local/share/code-server/User/settings.json <<'EOF'
201
  {
202
+ "workbench.startupEditor": "none",
203
+ "telemetry.telemetryLevel": "off",
204
+ "terminal.integrated.defaultProfile.linux": "zsh",
205
+ "security.workspace.trust.enabled": false,
206
+ "workbench.colorTheme": "Default Dark+"
207
  }
208
  EOF
209
 
210
  # ------------------------------------------------------------
211
+ # 8) 最终配置
212
  # ------------------------------------------------------------
213
  WORKDIR /root
214
  EXPOSE 7860
215
+ RUN chsh -s "$(which zsh)" root
216
 
217
  ENTRYPOINT ["code-server", "--bind-addr", "0.0.0.0:7860", "--auth", "none", "/root"]