File size: 1,907 Bytes
632b0a7
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
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
54
55
56
57
FROM codercom/code-server:latest

USER root

RUN apt-get update && apt-get install -y \
    git curl wget ca-certificates unzip jq \
    zsh openssh-client rsync \
    nginx apache2-utils \
    build-essential \
 && rm -rf /var/lib/apt/lists/*

 # ---- Python & venv ----
RUN apt-get update && apt-get install -y \
    python3 python3-venv python3-pip \
 && rm -rf /var/lib/apt/lists/*

# ---- 创建虚拟环境 ----
RUN python3 -m venv /opt/venv

# ⭐ 设置环境变量,让虚拟环境自动激活
ENV PATH="/opt/venv/bin:$PATH"
ENV VIRTUAL_ENV=/opt/venv

# ---- 升级 pip 并安装依赖 ----
RUN pip install --no-cache-dir --upgrade pip \
 && pip install --no-cache-dir "huggingface_hub==0.26.*" \
 && python -c "import huggingface_hub; print('huggingface_hub=', huggingface_hub.__version__)"
 
# 安装 Node.js 20 LTS(替代 apt 自带的旧 node)
RUN apt-get update && apt-get install -y --no-install-recommends ca-certificates curl gnupg \
 && curl -fsSL https://deb.nodesource.com/setup_22.x  | bash - \
 && apt-get install -y --no-install-recommends nodejs \
 && rm -rf /var/lib/apt/lists/*

# 让 npm 的 cache 和全局安装目录都落在 coder 的 HOME(后续会被你同步到 dataset)
ENV NPM_CONFIG_CACHE=/home/coder/.npm \
    NPM_CONFIG_PREFIX=/home/coder/.npm-global \
    PATH=/home/coder/.npm-global/bin:$PATH

# 确保目录存在且归属正确
RUN mkdir -p /home/coder/.npm /home/coder/.npm-global \
 && chown -R coder:coder /home/coder/.npm /home/coder/.npm-global

# 用 coder 用户安装全局 CLI(推荐)
USER coder
RUN npm i -g @cometix/codex @anthropic-ai/claude-code

# 切回 root(如果你后面还要装 nginx 等;否则可不切回)
USER root
 
COPY entrypoint.sh /entrypoint.sh
COPY sync_home.py /sync_home.py
COPY nginx.conf.template /etc/nginx/templates/nginx.conf.template
RUN chmod +x /entrypoint.sh

EXPOSE 7860
ENTRYPOINT ["/entrypoint.sh"]