File size: 1,034 Bytes
9a1014e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
FROM python:3.11-slim

# Crea y asigna un usuario para HF Spaces (recomendado)
RUN useradd -m -u 1000 user
ENV PATH="/home/user/.local/bin:$PATH"
ENV PYTHONUNBUFFERED=1
ENV PORT=7860
ENV ANONYMIZED_TELEMETRY=False
ENV LOCAL_MODEL_CONTEXT_SIZE=2048
ENV LOCAL_MODEL_MAX_NEW_TOKENS=256
ENV LOCAL_MODEL_THREADS=2
ENV LOCAL_MODEL_BATCH_THREADS=2
ENV LOCAL_MODEL_BATCH_SIZE=256

WORKDIR /home/user/app
RUN chown -R user:user /home/user/app

USER user

COPY --chown=user ./requirements.txt requirements.txt
RUN pip install --no-cache-dir --upgrade -r requirements.txt

COPY --chown=user . /home/user/app
RUN python download_model.py \
    --download-only \
    --repo AlbertiTechnology/qwen3-4b-instruct-gguf \
    --local-dir MODELS/qwen3-4b-instruct-gguf
RUN python index_documents_to_chroma.py \
    --documents-dir documentos/ASTM \
    --persist-dir chroma_db_docs \
    --collection document_context \
    --reset-collection

# Valida la base Chroma generada durante el build y luego inicia la API.
CMD ["python", "-u", "start_hf.py"]