File size: 1,779 Bytes
279779a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
221c507
 
 
59a619b
 
 
279779a
 
 
 
 
3f78483
279779a
 
 
 
 
 
 
 
 
 
 
 
 
59a619b
279779a
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
50
51
52
53
54
# ---------------------------------------------------------------------------
# PayOps OpenEnv — Production Dockerfile
# ---------------------------------------------------------------------------
# Builds a lightweight, reproducible container that runs the FastAPI server.
# Compatible with HuggingFace Spaces (port 7860) and local development (8000).
# ---------------------------------------------------------------------------

FROM python:3.11-slim

# Non-root user for security
RUN useradd -m -u 1000 appuser

WORKDIR /app

# Install system dependencies
RUN apt-get update && \
    apt-get install -y --no-install-recommends curl && \
    rm -rf /var/lib/apt/lists/*

# Copy and install Python dependencies first (layer caching)
COPY requirements.txt ./
RUN pip install --no-cache-dir -r requirements.txt

# Copy project source
COPY . /app/payops_env

# Also copy openenv.yaml to WORKDIR so validators can find it at /app/openenv.yaml
COPY openenv.yaml /app/openenv.yaml

# Both /app (for payops_env.*) and /app/payops_env (for server.*) on PYTHONPATH
# This matches the openenv.yaml app: server.app:app path and platform example format
ENV PYTHONPATH="/app:/app/payops_env"

# HuggingFace Spaces requires port 7860; default to 7860
ENV PORT=7860

# Runtime env vars (overridden at deploy time via HF Space secrets)
# HF_TOKEN / OPENAI_API_KEY are injected at runtime — not baked into the image
ENV API_BASE_URL="" \
    MODEL_NAME="" \
    PAYOPS_BASE_URL="http://localhost:7860"

# Switch to non-root user
USER appuser

EXPOSE 7860

# Health check
HEALTHCHECK --interval=30s --timeout=10s --start-period=15s --retries=3 \
    CMD curl -f http://localhost:${PORT}/health || exit 1

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