TokenZip-api / Dockerfile
rohitkshirsagar19's picture
Upload 3 files
301dd5b verified
# ── PromptZip FastAPI β€” Hugging Face Docker Space ────────────────────────────
# HF Spaces requires the container to listen on port 7860.
# The Space runs as a non-root user (UID 1000), so we create one here.
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/*
# ---------- Non-root user (matches HF Spaces UID) ----------
RUN useradd -m -u 1000 appuser
WORKDIR /app
# ---------- Python deps ----------
COPY requirements.txt .
RUN pip install --no-cache-dir --upgrade pip \
&& pip install --no-cache-dir -r requirements.txt
# ---------- Application ----------
COPY main.py .
# Pre-download tiktoken encoding data so first request is instant
RUN python -c "import tiktoken; tiktoken.get_encoding('cl100k_base')"
# Switch to non-root
USER appuser
# ---------- Runtime ----------
# HF Spaces exposes exactly port 7860
EXPOSE 7860
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860", "--workers", "1"]