Spaces:
Sleeping
Sleeping
| # Start from the official Ollama base image | |
| FROM ollama/ollama | |
| # --- BUILD ARGUMENT --- | |
| # Allows you to specify the model to download when building the image. | |
| ENV OLLAMA_MODEL=qwen3:1.7b | |
| # --- ENVIRONMENT VARIABLES --- | |
| ENV OLLAMA_HOST=0.0.0.0 | |
| ENV OLLAMA_ORIGINS='*' | |
| # Optional: Set your own API key as environment variable, otherwise one will be auto-generated | |
| # ENV OLLAMA_API_KEY=your_secure_api_key_here | |
| # 1. Install Python and PIP | |
| RUN apt-get update && apt-get install -y python3 python3-pip curl | |
| # 2. Copy your application files into the container | |
| WORKDIR /app | |
| COPY ./main.py /app/main.py | |
| COPY ./start.sh /app/start.sh | |
| COPY ./chat.html /app/chat.html | |
| COPY ./static /app/static | |
| RUN chmod +x /app/start.sh | |
| # 3. Install Python dependencies for the FastAPI gateway | |
| RUN pip3 install fastapi uvicorn requests --break-system-packages | |
| # Expose the port the FastAPI gateway will listen on | |
| EXPOSE 7860 | |
| # Pre-pull the specified LLM model during the build process | |
| RUN if [ -n "$OLLAMA_MODEL" ]; then \ | |
| ollama serve & \ | |
| sleep 5 && \ | |
| ollama pull $OLLAMA_MODEL && \ | |
| pkill ollama; \ | |
| fi | |
| # Set the command to run when the container starts | |
| ENTRYPOINT ["/app/start.sh"] | |