File size: 1,291 Bytes
46258b3
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
d7b2379
 
46258b3
d7b2379
 
46258b3
 
 
 
 
 
 
 
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
# HF Space Dockerfile for OpenHands Simplified Backend (Phase 1)
# Runs FastAPI on port 7860 (HF Space default).

FROM python:3.11-slim

ENV PYTHONDONTWRITEBYTECODE=1 \
    PYTHONUNBUFFERED=1 \
    PIP_NO_CACHE_DIR=1 \
    PIP_DISABLE_PIP_VERSION_CHECK=1 \
    PORT=7860 \
    HOME=/home/user

# Non-root user expected by HF Spaces
RUN useradd -m -u 1000 user
WORKDIR /home/user/app

# System deps (minimal)
RUN apt-get update && apt-get install -y --no-install-recommends \
        curl ca-certificates \
    && rm -rf /var/lib/apt/lists/*

# Python deps
COPY --chown=user:user requirements.txt /home/user/app/requirements.txt
RUN pip install --no-cache-dir -r /home/user/app/requirements.txt

# App code
COPY --chown=user:user . /home/user/app/backend
# Phase-2: SQLite task DB lives under /home/user/app/data (writable by `user`).
RUN mkdir -p /home/user/app/data && chown -R user:user /home/user/app
# Make package importable as `backend`
ENV PYTHONPATH=/home/user/app \
    TASK_DB_PATH=/home/user/app/data/tasks.db

USER user
EXPOSE 7860

HEALTHCHECK --interval=30s --timeout=5s --start-period=20s --retries=3 \
    CMD curl -fsS http://localhost:7860/health || exit 1

CMD ["uvicorn", "backend.app:app", "--host", "0.0.0.0", "--port", "7860", "--workers", "1", "--log-level", "info"]