Spaces:
Sleeping
Sleeping
| FROM python:3.11-slim | |
| # Set working directory | |
| WORKDIR /app | |
| # Install required system libraries | |
| RUN apt-get update && apt-get install -y --no-install-recommends \ | |
| libgl1 \ | |
| libglib2.0-0 \ | |
| && rm -rf /var/lib/apt/lists/* | |
| # Create required directories for ChromaDB and HuggingFace | |
| RUN mkdir -p /app/data/chroma_crop_rag /app/cache /app/chroma_storage | |
| # Create a non-root user | |
| RUN useradd -m appuser | |
| # Change ownership of the relevant directories to the non-root user | |
| RUN chown -R appuser:appuser /app | |
| # Set environment variables | |
| ENV HF_HOME=/app/cache | |
| ENV CHROMA_PERSIST_DIR=/app/data/chroma_crop_rag | |
| ENV CHROMA_DB_DIR=/app/chroma_storage | |
| # Copy project files | |
| COPY requirements.txt api.py config.py crop_disease_qa.json /app/ | |
| RUN pip install -U langchain-groq | |
| # Install Python dependencies | |
| RUN pip install --no-cache-dir python-multipart -r requirements.txt | |
| # Switch to the non-root user | |
| USER appuser | |
| # Expose the default port | |
| EXPOSE 7860 | |
| # Run the application | |
| CMD ["python", "api.py"] | |