Multi-ai-chat / Dockerfile
Bc-AI's picture
Update Dockerfile
9706e1c verified
Raw
History Blame Contribute Delete
1.35 kB
FROM nvidia/cuda:12.1.1-cudnn8-devel-ubuntu22.04
ENV DEBIAN_FRONTEND=noninteractive
ENV PYTHONUNBUFFERED=1
ENV CUDA_HOME=/usr/local/cuda
ENV PATH="${CUDA_HOME}/bin:${PATH}"
ENV LD_LIBRARY_PATH="${CUDA_HOME}/lib64:${LD_LIBRARY_PATH}"
# Install system dependencies
RUN apt-get update && apt-get install -y \
python3.10 \
python3-pip \
python3.10-dev \
git \
wget \
curl \
&& rm -rf /var/lib/apt/lists/*
RUN ln -s /usr/bin/python3.10 /usr/bin/python
WORKDIR /app
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
COPY . .
# βœ… FIX: Create cache directories with proper permissions
RUN mkdir -p /app/model_cache /app/static && \
chmod -R 777 /app/model_cache && \
chmod -R 755 /app/static
# βœ… Set cache environment variables
ENV HF_HOME=/app/model_cache
ENV TRANSFORMERS_CACHE=/app/model_cache
ENV HF_HUB_CACHE=/app/model_cache
ENV HUGGINGFACE_HUB_CACHE=/app/model_cache
# βœ… Optional: Pre-download a model during build (faster startup)
# Uncomment to pre-cache Phi-3 (smallest, fastest):
# RUN python -c "from transformers import AutoTokenizer, AutoModelForCausalLM; \
# AutoTokenizer.from_pretrained('microsoft/Phi-3-mini-4k-instruct'); \
# print('Tokenizer cached')"
EXPOSE 7860
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860", "--workers", "1"]