FROM python:3.9 WORKDIR /app # Install required Python packages COPY ./requirements.txt requirements.txt RUN pip install --no-cache-dir --upgrade -r requirements.txt # Copy application code COPY app/ app/ # Create directories for the Hugging Face cache and application data RUN mkdir -p /app/cache && \ mkdir -p /app/app/vector_store && \ mkdir -p /app/app/uploads && \ mkdir -p /app/app/log_dir && \ mkdir -p /app/app/models && \ # Adjust ownership to allow writing chown -R nobody:nogroup /app/cache && \ chown -R nobody:nogroup /app/app WORKDIR /app RUN mkdir -p app/app/models/models--sentence-transformers--all-MiniLM-L6-v2 && \ chmod -R 777 app/app/models/models--sentence-transformers--all-MiniLM-L6-v2 # Set environment variable for Hugging Face cache ENV HF_HOME=/app/cache # Set to a non-root user USER nobody # Define volumes for data persistence VOLUME /app/app/vector_store VOLUME /app/app/uploads VOLUME /app/app/log_dir VOLUME /app/app/models VOLUME /app/cache VOLUME /app/app/models/models--sentence-transformers--all-MiniLM-L6-v2 # Command to run the application CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "7860"]