Spaces:
Paused
Paused
File size: 1,997 Bytes
d727210 cdc63ea 220acb1 cdc63ea d727210 221c507 220acb1 59a619b d727210 0f139ff d727210 0f139ff afdab52 0f139ff d727210 59a619b d727210 | 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 55 56 57 58 59 60 | # ---------------------------------------------------------------------------
# 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
# Build trigger — change this to force HF Space Docker rebuild
LABEL build.version="2026-04-12-v6"
# 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
# Copy graders.py to /app so platform can `import graders` from /app on PYTHONPATH
COPY graders.py /app/graders.py
# 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"]
|