Spaces:
Running
Running
| # Use Python 3.11 slim base image | |
| FROM python:3.11-slim | |
| # Set working directory | |
| WORKDIR /app | |
| # Set environment variables | |
| ENV PYTHONPATH=/app | |
| ENV PYTHONUNBUFFERED=1 | |
| ENV PYTHONIOENCODING=utf-8 | |
| ENV LIGHTRAG_HOST=127.0.0.1 | |
| ENV LIGHTRAG_PORT=9621 | |
| ENV API_PORT=8000 | |
| # Install system dependencies | |
| RUN apt-get update && apt-get install -y \ | |
| build-essential \ | |
| curl \ | |
| && rm -rf /var/lib/apt/lists/* | |
| # Copy requirements first for better caching | |
| COPY requirements.txt . | |
| # Install Python dependencies | |
| RUN pip install --no-cache-dir --upgrade pip && \ | |
| pip install --no-cache-dir -r requirements.txt | |
| # Copy application files | |
| COPY . . | |
| # Create non-root user for security | |
| RUN useradd -m -u 1000 appuser && chown -R appuser:appuser /app | |
| RUN chmod +x /app/startup.sh && chown appuser:appuser /app/startup.sh | |
| USER appuser | |
| EXPOSE 8000 | |
| HEALTHCHECK --interval=30s --timeout=30s --start-period=60s --retries=3 \ | |
| CMD sh -c 'curl -f http://localhost:${PORT:-8000}/health || exit 1' | |
| CMD ["/app/startup.sh"] |