Team Ai
Apppublic

sin601/claude-code

sourceHugging Faceupdated 7mo agoView on Hugging Face
0likes
Dockerfile88 linesDownload Raw Back to root
1# HF Spaces Claude Code Deployment2# 精简版 - 仅包含必要依赖3 4FROM ubuntu:22.045 6# 设置环境变量7ENV DEBIAN_FRONTEND=noninteractive8ENV LANG=C.UTF-89ENV LC_ALL=C.UTF-810ENV HOME=/root11ENV WORK_DIR=/workspace12ENV CONFIG_DIR=/config13 14# 设置工作目录15WORKDIR /app16 17# 安装最小化依赖(仅必需)18RUN apt-get update && apt-get install -y --no-install-recommends \19    curl \20    wget \21    git \22    ca-certificates \23    jq \24    unzip \25    procps \26    && rm -rf /var/lib/apt/lists/* \27    && apt-get clean28 29# 安装 Node.js 20.x (Claude Code 需要)30RUN curl -fsSL https://deb.nodesource.com/setup_20.x | bash - \31    && apt-get install -y nodejs \32    && rm -rf /var/lib/apt/lists/* \33    && node --version \34    && npm --version35 36# 安装 Claude Code CLI37RUN npm install -g @anthropic-ai/claude-code \38    && claude --version || echo "Claude Code installed"39 40# 安装 ttyd (Web Terminal) - 使用最新版本41RUN ARCH=$(uname -m) && \42    if [ "$ARCH" = "x86_64" ]; then TTYD_ARCH="x86_64"; \43    elif [ "$ARCH" = "aarch64" ]; then TTYD_ARCH="aarch64"; \44    else TTYD_ARCH="$ARCH"; fi && \45    wget -q "https://github.com/tsl0922/ttyd/releases/download/1.7.7/ttyd.${TTYD_ARCH}" -O /usr/local/bin/ttyd && \46    chmod +x /usr/local/bin/ttyd && \47    ttyd --version48 49# 下载并安装 CLIProxyAPI50RUN ARCH=$(uname -m) && \51    if [ "$ARCH" = "x86_64" ]; then CPA_ARCH="amd64"; \52    elif [ "$ARCH" = "aarch64" ]; then CPA_ARCH="arm64"; \53    else CPA_ARCH="$ARCH"; fi && \54    wget -q "https://github.com/router-for-me/CLIProxyAPI/releases/download/v6.9.4/CLIProxyAPI_6.9.4_linux_amd64.tar.gz" -O /tmp/cliproxyapi.tar.gz && \55    tar -xzf /tmp/cliproxyapi.tar.gz -C /usr/local/bin && \56    chmod +x /usr/local/bin/cliproxyapi && \57    rm -f /tmp/cliproxyapi.tar.gz58 59# 创建必要目录60RUN mkdir -p ${WORK_DIR} ${CONFIG_DIR} ${HOME}/.claude ${HOME}/.cli-proxy-api61 62# 设置 Git 全局配置63RUN git config --global user.email "user@hf-space.local" && \64    git config --global user.name "HF Space User" && \65    git config --global init.defaultBranch main && \66    git config --global pull.rebase false && \67    git config --global credential.helper store68 69# 复制项目文件70COPY scripts/ /app/scripts/71COPY config/ /app/config/72 73# 设置脚本权限74RUN chmod +x /app/scripts/*.sh75 76# 暴露端口 (HF Spaces 要求)77EXPOSE 786078 79# 健康检查80HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \81    CMD curl -f http://localhost:7860/ || exit 182 83# 设置工作目录84WORKDIR ${WORK_DIR}85 86# 入口点87ENTRYPOINT ["/app/scripts/entrypoint.sh"]88