sunee3 / Dockerfile
sagarmythos
DevAI Studio HCBH v3.1 - clean deploy, no binaries
df6cd5e
Raw History Blame Contribute Delete
3.33 kB
# ─────────────────────────────────────────────────────────────────────────────
# DevAI Studio v4.9.2 β€” STORAGE-OPTIMIZED Dockerfile
# Target: Hugging Face Spaces (CPU basic, 50 GB free storage)
#
# Key changes vs original:
# 1. Ollama is NOT installed at build time (~150 MB saved).
# It installs lazily inside entrypoint.sh on first Private Mode request.
# 2. NO local model weights are pre-bundled (~22 GB saved).
# 3. Same Python + framework stack as original β€” all functionality intact.
# ─────────────────────────────────────────────────────────────────────────────
FROM python:3.10-slim
ENV DEBIAN_FRONTEND=noninteractive \
PYTHONDONTWRITEBYTECODE=1 \
PYTHONUNBUFFERED=1 \
PIP_NO_CACHE_DIR=1 \
PIP_DISABLE_PIP_VERSION_CHECK=1 \
GRADIO_ANALYTICS_ENABLED=false
# ── System deps ───────────────────────────────────────────────────────────────
# curl: needed by entrypoint.sh to install Ollama on demand
# git: needed by DevAI Studio's git_operations module
# build-essential: torch/transformers compile deps
RUN apt-get update && apt-get install -y --no-install-recommends \
git \
curl \
ca-certificates \
build-essential \
libgomp1 \
&& rm -rf /var/lib/apt/lists/*
# ── Non-root user (HF Spaces convention) ─────────────────────────────────────
RUN useradd -m -u 1000 devai
USER devai
ENV HOME=/home/devai \
PATH=/home/devai/.local/bin:$PATH \
WORKSPACE_DIR=/home/devai/workspace \
TRANSFORMERS_CACHE=/home/devai/.cache/huggingface \
HF_HOME=/home/devai/.cache/huggingface
WORKDIR /home/devai/app
# ── Python dependencies (only on-disk cost at build time) ────────────────────
COPY --chown=devai:devai requirements.txt ./requirements.txt
RUN pip install --user --upgrade pip \
&& pip install --user -r requirements.txt
# ── Project code ─────────────────────────────────────────────────────────────
COPY --chown=devai:devai . .
# ── Runtime config ───────────────────────────────────────────────────────────
ENV GRADIO_SERVER_NAME=0.0.0.0 \
GRADIO_SERVER_PORT=7860 \
PORT=7860 \
# Tell DevAI that Ollama isn't installed yet; it'll be installed lazily
DEVAI_OLLAMA_INSTALLED=false
# ── Replace CMD with our smart bootstrap ─────────────────────────────────────
COPY --chown=devai:devai entrypoint.sh /home/devai/entrypoint.sh
RUN chmod +x /home/devai/entrypoint.sh
EXPOSE 7860
CMD ["/home/devai/entrypoint.sh"]