nanochat-20b-chat / Dockerfile
Thewhey-Brian
Fix uid 1000 error: create user and set cache env vars early
c015721
# Dockerfile for Hugging Face Spaces deployment
FROM python:3.10-slim
# Create a user with uid 1000 (typical HF Spaces user)
RUN useradd -m -u 1000 user
# Install system dependencies including Rust (needed for rustbpe)
RUN apt-get update && apt-get install -y \
build-essential \
curl \
&& curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y \
&& . $HOME/.cargo/env \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
# Add Rust to PATH
ENV PATH="/root/.cargo/bin:${PATH}"
# Set working directory
WORKDIR /app
# Copy project files
COPY . /app
# Install Python dependencies
RUN pip install --no-cache-dir -r requirements.txt
# Build and install the Rust component
RUN . $HOME/.cargo/env && maturin build --release && pip install --no-cache-dir rustbpe/target/wheels/*.whl
# Create data directory for model checkpoints with proper permissions
RUN mkdir -p /data && chmod 777 /data
# Set environment variables
ENV NANOCHAT_BASE_DIR=/data
ENV PYTHONUNBUFFERED=1
ENV HF_HOME=/data/.cache/huggingface
ENV TORCHINDUCTOR_CACHE_DIR=/data/.cache/torch
# Expose port 7860 (HF Spaces default)
EXPOSE 7860
# Run the application
CMD ["python", "app.py"]