File size: 1,288 Bytes
31cee57
50f4256
3c31a2a
 
 
50f4256
3c31a2a
 
 
 
50f4256
 
31cee57
 
 
50f4256
 
 
 
3c31a2a
50f4256
dc1b199
50f4256
 
 
 
dc1b199
50f4256
 
dc1b199
50f4256
 
 
 
 
 
31cee57
50f4256
31cee57
50f4256
31cee57
dc1b199
50f4256
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
# syntax=docker/dockerfile:1.6
# Hugging Face Spaces — v2 backend (reference-only, canonical RICS L3 schema).
FROM python:3.11-slim AS production

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

ENV PIP_DISABLE_PIP_VERSION_CHECK=1 \
    PIP_NO_CACHE_DIR=1 \
    PYTHONUNBUFFERED=1 \
    PYTHONDONTWRITEBYTECODE=1 \
    HOME=/home/user \
    PORT=7860 \
    DATA_DIR=/data \
    MASTER_TEMPLATE_AUTO_INGEST=false \
    REFERENCE_AUTO_INGEST_ENABLED=false

WORKDIR /app

COPY backend/requirements.txt ./backend/requirements.txt
RUN pip install --upgrade pip && \
    pip install -r backend/requirements.txt && \
    python -m spacy download en_core_web_sm

COPY backend ./backend
COPY frontend ./frontend

RUN groupadd -g 1000 appgroup && \
    useradd -u 1000 -g appgroup -d /home/user -m -s /sbin/nologin appuser && \
    mkdir -p /data/tmp /data/hf_cache && \
    chown -R appuser:appgroup /app /data /home/user

USER appuser

EXPOSE 7860

HEALTHCHECK --interval=30s --timeout=10s --start-period=120s --retries=3 \
    CMD curl -fsS "http://127.0.0.1:${PORT:-7860}/health" || exit 1

CMD ["sh", "-c", "exec uvicorn backend.main:app --host 0.0.0.0 --port ${PORT:-7860} --workers 1"]