Spaces:
Sleeping
Sleeping
| FROM python:3.11-slim | |
| WORKDIR /rag-application | |
| # Install system dependencies | |
| RUN apt-get update && \ | |
| apt-get install -y curl | |
| # Install Ollama | |
| RUN curl -fsSL https://ollama.com/install.sh | sh | |
| RUN pip install poetry | |
| # Copy only the needed files first to leverage Docker cache | |
| COPY pyproject.toml poetry.lock /rag-application/ | |
| # Install dependencies | |
| RUN poetry config virtualenvs.create false \ | |
| && poetry lock \ | |
| && poetry install --no-interaction --no-ansi --no-root | |
| # Copy the rest of the application files | |
| COPY . /rag-application | |
| # Copy the startup script and make it executable | |
| COPY install_model_in_ollama.sh /rag-application/install_model_in_ollama.sh | |
| RUN chmod +x /rag-application/install_model_in_ollama.sh | |
| RUN mkdir -p /.ollama && \ | |
| chown -R 1000:1000 /.ollama | |
| # Expose port 5000 for the Flask app | |
| EXPOSE 5000 | |
| # Define environment variable to ensure the Flask app runs in a container | |
| ENV PYTHONUNBUFFERED=1 | |
| # Run the command to start the Gunicorn server | |
| CMD ["/rag-application/install_model_in_ollama.sh"] | |
| # CMD ["gunicorn", "-c", "gunicorn.py", "app:app"] |