Spaces:
Paused
Paused
| FROM modelscope-registry.us-west-1.cr.aliyuncs.com/modelscope-repo/modelscope:ubuntu22.04-py311-torch2.3.1-1.28.0 | |
| ENV DEBIAN_FRONTEND=noninteractive \ | |
| TZ=Asia/Shanghai | |
| # Remove any third-party apt sources and install basic utilities | |
| RUN rm -f /etc/apt/sources.list.d/*.list && \ | |
| apt-get update && apt-get install -y --no-install-recommends \ | |
| curl \ | |
| ca-certificates \ | |
| sudo \ | |
| git \ | |
| wget \ | |
| procps \ | |
| git-lfs \ | |
| zip \ | |
| unzip \ | |
| htop \ | |
| vim \ | |
| nano \ | |
| bzip2 \ | |
| libx11-6 \ | |
| build-essential \ | |
| libsndfile-dev \ | |
| software-properties-common \ | |
| && rm -rf /var/lib/apt/lists/* | |
| # Add cloudflare gpg key | |
| RUN mkdir -p --mode=0755 /usr/share/keyrings && \ | |
| curl -fsSL https://pkg.cloudflare.com/cloudflare-main.gpg | tee /usr/share/keyrings/cloudflare-main.gpg >/dev/null | |
| # Add this repo to your apt repositories | |
| RUN echo 'deb [signed-by=/usr/share/keyrings/cloudflare-main.gpg] https://pkg.cloudflare.com/cloudflared any main' | tee /etc/apt/sources.list.d/cloudflared.list | |
| # install cloudflared | |
| RUN apt-get update && apt-get install -y cloudflared && rm -rf /var/lib/apt/lists/* | |
| # Install Node.js for Jupyter extensions | |
| RUN curl -sL https://deb.nodesource.com/setup_21.x | bash - && \ | |
| apt-get install -y nodejs && \ | |
| npm install -g configurable-http-proxy | |
| # Define error handling function and install Claude Code CLI | |
| RUN handle_error() { echo "错误: $1" >&2; exit 1; } && \ | |
| npm install -g @anthropic-ai/claude-code || handle_error "安装Claude Code CLI失败" | |
| # Create a working directory | |
| WORKDIR /app | |
| # Create a non-root user and switch to it | |
| RUN adduser --disabled-password --gecos '' --shell /bin/bash user \ | |
| && chown -R user:user /app | |
| RUN echo "user ALL=(ALL) NOPASSWD:ALL" > /etc/sudoers.d/90-user | |
| USER user | |
| # All users can use /home/user as their home directory | |
| ENV HOME=/home/user | |
| RUN mkdir $HOME/.cache $HOME/.config \ | |
| && chmod -R 777 $HOME | |
| # Set up the Conda environment with Python 3.11 | |
| ENV CONDA_AUTO_UPDATE_CONDA=false \ | |
| PATH=$HOME/miniconda/bin:$PATH | |
| RUN curl -sLo ~/miniconda.sh https://repo.continuum.io/miniconda/Miniconda3-py311_23.5.2-0-Linux-x86_64.sh \ | |
| && chmod +x ~/miniconda.sh \ | |
| && ~/miniconda.sh -b -p ~/miniconda \ | |
| && rm ~/miniconda.sh \ | |
| && conda clean -ya | |
| WORKDIR $HOME/app | |
| ####################################### | |
| # Start root user section | |
| ####################################### | |
| USER root | |
| # Create data directory | |
| RUN mkdir /data && chown user:user /data | |
| ####################################### | |
| # End root user section | |
| ####################################### | |
| USER user | |
| # Install Python packages using conda and pip | |
| RUN conda install -c conda-forge python=3.11 && \ | |
| pip install --no-cache-dir --upgrade pip | |
| # Copy requirements and install Python packages | |
| COPY --chown=user requirements.txt $HOME/app/ | |
| RUN pip install --no-cache-dir --upgrade -r requirements.txt | |
| # Copy the current directory contents into the container | |
| COPY --chown=user . $HOME/app | |
| RUN chmod +x start_server.sh | |
| # Set environment variables | |
| ENV PYTHONUNBUFFERED=1 \ | |
| GRADIO_ALLOW_FLAGGING=never \ | |
| GRADIO_NUM_PORTS=1 \ | |
| GRADIO_SERVER_NAME=0.0.0.0 \ | |
| GRADIO_THEME=huggingface \ | |
| SYSTEM=spaces \ | |
| SHELL=/bin/bash \ | |
| JUPYTER_TOKEN=huggingface | |
| CMD ["./start_server.sh"] | |