FROM python:3.11-slim RUN apt-get update && apt-get install -y curl && rm -rf /var/lib/apt/lists/* RUN curl -fsSL https://ollama.com/install.sh | sh RUN useradd -m -u 1000 user WORKDIR /app ENV OLLAMA_MODELS=/data/models ENV OLLAMA_HOST=0.0.0.0 COPY requirements.txt . RUN pip install --no-cache-dir -r requirements.txt COPY . . RUN chown -R user:user /app USER user EXPOSE 7860 CMD ["sh", "-c", "ollama serve & sleep 5 && ollama pull qwen2.5-coder:7b-instruct-q4_K_M && python app.py"]