MindMedic / Dockerfile
MoizK's picture
Update Dockerfile
9c3b266 verified
# Use Python 3.10 slim image as base
FROM python:3.10-slim
# Install system dependencies
RUN apt-get update && \
apt-get install -y \
build-essential \
git \
poppler-utils \
&& rm -rf /var/lib/apt/lists/*
# Set working directory
WORKDIR /app
# Pre-create all runtime & cache dirs with open perms
RUN mkdir -p \
/app/.files \
/app/.chainlit \
/app/.cache \
/app/model_cache \
/app/vectorstore/db_faiss \
/app/data && \
chmod -R a+rwx /app/.files /app/.chainlit /app/.cache /app/model_cache /app/vectorstore /app/data
# Environment variables
ENV PYTHONUNBUFFERED=1
ENV TRANSFORMERS_CACHE=/app/model_cache
ENV HF_HOME=/app/model_cache
ENV TORCH_HOME=/app/model_cache
ENV CHAINLIT_HOST=0.0.0.0
ENV CHAINLIT_PORT=7860
# Install Python deps
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
# Copy your application code
COPY model.py ingest.py chainlit.md download_assets.py ./
# Pre‐warm large models into the cache (so first startup is fast)
RUN python -c "\
from transformers import AutoTokenizer, AutoModelForSeq2SeqLM; \
AutoTokenizer.from_pretrained('google/flan-t5-base'); \
AutoModelForSeq2SeqLM.from_pretrained('google/flan-t5-base'); \
from sentence_transformers import SentenceTransformer; \
SentenceTransformer('sentence-transformers/all-MiniLM-L6-v2')\
"
# Expose Chainlit’s port
EXPOSE 7860
# On container start, download your assets then launch Chainlit
CMD ["sh", "-c", "\
python download_assets.py && \
exec chainlit run model.py --host 0.0.0.0 --port 7860\
"]