Spaces:
Sleeping
Sleeping
| # Use Ubuntu as base image | |
| FROM ubuntu:22.04 | |
| # Set environment variables | |
| ENV DEBIAN_FRONTEND=noninteractive \ | |
| CODE_SERVER_VERSION=4.96.2 \ | |
| PASSWORD=huggingface | |
| # Install dependencies | |
| RUN apt-get update && apt-get install -y \ | |
| curl \ | |
| wget \ | |
| git \ | |
| sudo \ | |
| vim \ | |
| nano \ | |
| build-essential \ | |
| python3 \ | |
| python3-pip \ | |
| nodejs \ | |
| npm \ | |
| unzip \ | |
| rsync \ | |
| && rm -rf /var/lib/apt/lists/* | |
| # Install Hugging Face CLI for dataset access | |
| RUN pip3 install --no-cache-dir huggingface_hub[cli] | |
| # Ensure huggingface-cli is in PATH for all users | |
| ENV PATH="/usr/local/bin:${PATH}" | |
| # Install code-server | |
| RUN curl -fsSL https://code-server.dev/install.sh | sh | |
| # Create a non-root user | |
| RUN useradd -m -s /bin/bash coder && \ | |
| echo "coder ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers | |
| # Set working directory | |
| WORKDIR /home/coder | |
| # Create workspace directory | |
| RUN mkdir -p /home/coder/workspace && \ | |
| chown -R coder:coder /home/coder | |
| # Switch to non-root user | |
| USER coder | |
| # Expose port 7860 (Hugging Face Spaces default port) | |
| EXPOSE 7860 | |
| # Create config directory | |
| RUN mkdir -p /home/coder/.config/code-server | |
| # Install AI coding assistant extensions that support Gemini | |
| RUN code-server --install-extension Continue.continue || true | |
| # Continue extension supports multiple AI models including Gemini | |
| # Users can configure it with their Gemini API key after launch | |
| # Set up code-server config | |
| RUN echo "bind-addr: 0.0.0.0:7860" > /home/coder/.config/code-server/config.yaml && \ | |
| echo "auth: password" >> /home/coder/.config/code-server/config.yaml && \ | |
| echo "password: ${PASSWORD}" >> /home/coder/.config/code-server/config.yaml && \ | |
| echo "cert: false" >> /home/coder/.config/code-server/config.yaml | |
| # Copy startup and backup scripts | |
| COPY --chown=coder:coder startup.sh /home/coder/startup.sh | |
| COPY --chown=coder:coder backup.sh /home/coder/backup.sh | |
| RUN chmod +x /home/coder/startup.sh /home/coder/backup.sh | |
| # Create symlink for easy access | |
| RUN sudo ln -s /home/coder/backup.sh /usr/local/bin/backup | |
| # Start code-server with persistence | |
| CMD ["/home/coder/startup.sh"] | |