FROM python:3.11-slim # Set environment variables ENV PYTHONUNBUFFERED=1 ENV PYTHONDONTWRITEBYTECODE=1 ENV PYTHONPATH=/app # Set work directory WORKDIR /app # Install system dependencies RUN apt-get update && apt-get install -y \ build-essential \ libpq-dev \ postgresql-client \ curl \ ffmpeg \ && rm -rf /var/lib/apt/lists/* # Copy requirements and install Python dependencies COPY requirements.txt . COPY tests/requirements-test.txt ./tests/ RUN pip install --no-cache-dir -r requirements.txt && \ pip install --no-cache-dir -r tests/requirements-test.txt # Optional: Download spaCy English model for NLP processing (commented out for faster builds) # Uncomment if you install requirements-nlp.txt and need entity extraction # RUN python -m spacy download en_core_web_sm # Copy application code COPY . . # Copy and make migration script executable COPY scripts/migrate.sh /usr/local/bin/migrate.sh RUN chmod +x /usr/local/bin/migrate.sh # Create logs directory RUN mkdir -p logs # Expose port EXPOSE 8000 # Health check HEALTHCHECK --interval=30s --timeout=30s --start-period=5s --retries=3 \ CMD curl -f http://localhost:8000/health || exit 1 # Run the application CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "8000", "--reload"]