File size: 894 Bytes
cb330aa
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2e6a03e
cb330aa
2e6a03e
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
FROM python:3.11-slim

# System deps
RUN apt-get update && apt-get install -y --no-install-recommends \
    build-essential curl \
    && rm -rf /var/lib/apt/lists/*

WORKDIR /app

# Install Python dependencies first (layer cache)
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt

# Copy project
COPY . .

EXPOSE 7860

# Runtime environment variables
# HF_TOKEN must be supplied at runtime as a Space Secret — never hardcoded here.
ENV PORT=7860 \
    API_BASE_URL="https://router.huggingface.co/v1" \
    MODEL_NAME="meta-llama/Meta-Llama-3-8B-Instruct" \
    LOCAL_IMAGE_NAME="synapse-x"

# Health-check so HF Spaces detects readiness
HEALTHCHECK --interval=30s --timeout=10s --start-period=15s --retries=3 \
    CMD sh -c 'curl -sf "http://127.0.0.1:${PORT:-7860}/health" || exit 1'

CMD ["sh", "-c", "uvicorn server.app:app --host 0.0.0.0 --port ${PORT:-7860}"]