phlam / Dockerfile
noisemarseille
ivf
f2bb329
Raw History Blame Contribute Delete
1.73 kB
# PHLAM (CPU) -- Hugging Face Space (Docker SDK), CPU-only free tier.
FROM python:3.10-slim
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 \
PORT=7860 \
ESM_MODEL=facebook/esm2_t12_35M_UR50D \
REFERENCE_DATA_DIR=/data/reference/ \
IMGVR_DATA_DIR=/data/imgvr_inphared \
MODELS_DATA_DIR=/data/models
WORKDIR /home/user/app
COPY --chown=user requirements.txt .
RUN pip install --no-cache-dir --upgrade pip \
&& pip install --no-cache-dir torch --index-url https://download.pytorch.org/whl/cpu \
&& pip install --no-cache-dir -r requirements.txt
# Bake the ESM-2 weights into the image so the first request isn't a cold download.
RUN python -c "from transformers import AutoTokenizer, AutoModel; m='facebook/esm2_t12_35M_UR50D'; AutoTokenizer.from_pretrained(m); AutoModel.from_pretrained(m)"
# reference_min.index / reference_min.parquet are NOT baked in -- they arrive
# via hfmount at REFERENCE_DATA_DIR (mounted_drive/reference/reference/) when
# the Space runs.
COPY --chown=user . .
EXPOSE 7860
# --timeout 900: /analyze's synchronous path (ESM/PHLAM load, annotation
# retriever's first touch of reference_min.* on hfmount) can be slow on a
# cold start over a network-mounted bucket -- this is gunicorn's worker
# silence timeout, not a hard request cap; background jobs (neighbor
# search, synteny) run in threads and never block a worker at all, so they
# aren't bound by this regardless of how long the FAISS indexes take.
CMD ["gunicorn", "app:app", \
"--workers", "1", "--threads", "4", "--worker-class", "gthread", \
"--timeout", "900", "--bind", "0.0.0.0:7860"]