Ahmed Javed
add files
524409f unverified
Raw
History Blame
2.07 kB
# ── Base image β€” CPU-only PyTorch to keep image size manageable ──────────────
FROM python:3.10-slim
# HuggingFace Spaces runs as a non-root user; create it early
RUN useradd -m -u 1000 appuser
WORKDIR /app
# ── System dependencies ───────────────────────────────────────────────────────
RUN apt-get update && apt-get install -y --no-install-recommends \
build-essential \
libsndfile1 \
ffmpeg \
git \
espeak-ng \
&& rm -rf /var/lib/apt/lists/*
# ── Python dependencies ───────────────────────────────────────────────────────
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
# ── Application code ──────────────────────────────────────────────────────────
COPY main.py .
COPY download_models.py .
COPY embeddings/ ./embeddings/
# ── Entrypoint script ─────────────────────────────────────────────────────────
# Runs model download first (idempotent), then starts the server.
# /tmp/models persists for the lifetime of the Space container so
# subsequent restarts skip the download and boot instantly.
COPY entrypoint.sh .
RUN chmod +x entrypoint.sh
# ── Permissions ───────────────────────────────────────────────────────────────
RUN chown -R appuser:appuser /app
USER appuser
# ── HuggingFace Spaces expects the app on port 7860 ──────────────────────────
ENV PORT=7860
EXPOSE 7860
CMD ["./entrypoint.sh"]