math-agent-backend / Dockerfile
abhikamuni's picture
d
c4557af verified
raw
history blame contribute delete
976 Bytes
FROM python:3.11-slim
WORKDIR /code
#Set the env vars for both runtime and buildtime
#This tells the RUN command below where to save the model
ENV HF_HOME="/code/.cache/huggingface"
#--- REMOVED DSPY ENV VAR ---
RUN apt-get update && apt-get install -y --no-install-recommends \
build-essential \
&& rm -rf /var/lib/apt/lists/*
COPY ./requirements.txt /code/requirements.txt
RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt
#--- START: PRE-BAKE MODEL FIX (WITH PERMISSIONS) ---
#1. Create the cache directory
RUN mkdir -p $HF_HOME
#2. Give all users full read/write/execute permissions
RUN chmod -R 777 $HF_HOME
#3. Now, pre-bake the model. It will save to the directory we just made.
RUN python -c "from sentence_transformers import SentenceTransformer; SentenceTransformer('all-MiniLM-L6-v2')"
#--- END: PRE-BAKE MODEL FIX ---
COPY ./app /code/app
EXPOSE 8000
CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "8000"]