File size: 1,789 Bytes
cc15101
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
# ── The Abyss β€” backend for Hugging Face Spaces (Docker SDK) ──────────────────
# Single CPU container: FastAPI + uvicorn serving the from-scratch Abyss-1 model.
# The model checkpoint is pulled from the HF Hub at boot (set ABYSS_HF_REPO),
# so it is NOT baked into this image β€” that keeps the Space small.
#
# This folder is assembled by assemble.py, which copies server/, ml/ (model +
# tokenizer) and agent/ next to this Dockerfile before you push to the Space.
FROM python:3.11-slim

ENV PYTHONUNBUFFERED=1 \
    PYTHONDONTWRITEBYTECODE=1 \
    PIP_NO_CACHE_DIR=1

# Build tools for any wheels that need to compile; removed afterwards.
RUN apt-get update && apt-get install -y --no-install-recommends build-essential \
    && rm -rf /var/lib/apt/lists/*

WORKDIR /app

# CPU-only PyTorch first (small; avoids pulling multi-GB CUDA wheels).
RUN pip install --no-cache-dir torch --index-url https://download.pytorch.org/whl/cpu

# The rest of the Python deps.
COPY requirements_server.txt .
RUN pip install --no-cache-dir -r requirements_server.txt

# Non-root user β€” Hugging Face Spaces runs the container as uid 1000.
RUN useradd -m -u 1000 appuser
ENV HOME=/home/appuser \
    PATH=/home/appuser/.local/bin:$PATH \
    HF_HOME=/home/appuser/.cache/huggingface

# Application code (staged alongside this Dockerfile by assemble.py).
COPY server/ ./server/
COPY ml/ ./ml/
COPY agent/ ./agent/
COPY run_server.py .

# Make /app writable by the runtime user β€” the SQLite DB (conversation.db) and
# the agent's sandboxed workspace are created here at runtime.
RUN chown -R appuser:appuser /app
USER appuser

# HF Spaces expects the app on 7860 (declared via app_port in README.md).
ENV PORT=7860
EXPOSE 7860

CMD ["python", "run_server.py"]