creatorpulse-api / Dockerfile
ayushgupta7777's picture
fix(docker): explicit CACHEBUST arg to force fresh clone on rebuild
2449346
Raw
History Blame Contribute Delete
1.8 kB
# HF Spaces (Docker SDK) β€” CreatorPulse India API.
# Builds from the public GitHub repo; serves FastAPI on the HF-required port 7860.
FROM python:3.11-slim
RUN apt-get update && apt-get install -y --no-install-recommends git \
&& rm -rf /var/lib/apt/lists/*
# HF Spaces runs the container as uid 1000 β€” set up that user + a writable model cache.
RUN useradd -m -u 1000 user
USER user
ENV HOME=/home/user \
PATH=/home/user/.local/bin:$PATH \
HF_HOME=/home/user/.cache/huggingface \
PYTHONUNBUFFERED=1
WORKDIR /home/user/app
# Pull the app + committed models/*.joblib from GitHub (single source of truth).
# Cache-bust: when main HEAD moves, this ref JSON changes and invalidates the clone
# layer below, so each rebuild re-clones fresh HEAD (a bare clone is cached forever).
ARG CACHEBUST=unset
RUN echo "cache-bust=$CACHEBUST"
ADD https://api.github.com/repos/ayushgupta07xx/CreatorPulse-India/git/refs/heads/main /tmp/ref.json
RUN git clone --depth 1 https://github.com/ayushgupta07xx/CreatorPulse-India.git .
# CPU-only torch FIRST so sentence-transformers finds it satisfied and never pulls the
# multi-GB CUDA stack (the Space has no GPU). Then the core package (-e .) brings the
# runtime deps (fastapi/uvicorn/sqlalchemy/psycopg2/redis/pandas/numpy/pydantic), and
# finally only the ML libs the API loads at runtime β€” deliberately NOT the full [ml]
# extra, which drags prophet/mlflow/bertopic/optuna, none needed to serve.
RUN pip install --user --no-cache-dir torch --index-url https://download.pytorch.org/whl/cpu \
&& pip install --user --no-cache-dir -e . \
&& pip install --user --no-cache-dir \
"sentence-transformers>=3.0" "scikit-learn>=1.5" "xgboost>=2.0"
EXPOSE 7860
CMD ["uvicorn", "apps.api.main:app", "--host", "0.0.0.0", "--port", "7860"]